GRINS-0.7.0
gas_solid_catalytic_wall_neumann_bc_factory_impl.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 // This class
27 
28 // GRINS
29 #include "grins/string_utils.h"
30 
31 #ifdef GRINS_HAVE_CANTERA
32 #include "grins/cantera_mixture.h"
33 #endif
34 
35 #ifdef GRINS_HAVE_ANTIOCH
37 #endif
38 
39 namespace GRINS
40 {
41  // To avoid compiler warnings without GRINS or Cantera
42 #if defined(GRINS_HAVE_ANTIOCH) || defined(GRINS_HAVE_CANTERA)
43  SharedPtr<NeumannBCAbstract>
45  ( const GetPot& input, const std::string& reaction,SharedPtr<CatalycityBase>& gamma_ptr,
46  const std::vector<VariableIndex>& species_vars,const std::string& material,
47  VariableIndex T_var,libMesh::Real p0,const std::string& thermochem_lib )
48 #else
49  SharedPtr<NeumannBCAbstract>
51  ( const GetPot& /*input*/, const std::string& reaction,SharedPtr<CatalycityBase>& /*gamma_ptr*/,
52  const std::vector<VariableIndex>& /*species_vars*/,const std::string& /*material*/,
53  VariableIndex /*T_var*/,libMesh::Real /*p0*/,const std::string& thermochem_lib )
54 #endif
55  {
56  std::string gas_reactant;
57  std::string solid_reactant;
58  std::string product;
59  this->parse_reactants_and_product(reaction,gas_reactant,solid_reactant,product);
60 
61  // Now construct the Neumann BC
62  SharedPtr<NeumannBCAbstract> catalytic_wall;
63 
64  if( thermochem_lib == "cantera" )
65  {
66 #ifdef GRINS_HAVE_CANTERA
67  this->build_wall_ptr<CanteraMixture>(input,material,gamma_ptr,gas_reactant,solid_reactant,
68  product,species_vars,T_var,p0,catalytic_wall);
69 #else
70  libmesh_error_msg("Error: Cantera not enabled in this configuration. Reconfigure using --with-cantera option.");
71 #endif
72  }
73  else if( thermochem_lib == "antioch" )
74  {
75 #ifdef GRINS_HAVE_ANTIOCH
76  this->build_wall_ptr<AntiochChemistry>(input,material,gamma_ptr,gas_reactant,solid_reactant,
77  product,species_vars,T_var,p0,catalytic_wall);
78 #else
79  libmesh_error_msg("Error: Antioch not enabled in this configuration. Reconfigure using --with-antioch option.");
80 #endif
81  }
82  else
83  libmesh_error_msg("ERROR: Invalid thermochemistry library "+thermochem_lib+"!");
84 
85  return catalytic_wall;
86  }
87 
89  std::string& gas_reactant,
90  std::string& solid_reactant,
91  std::string& product ) const
92  {
93  /* We are expecting reactions of the form
94  X+Y(s)->Z or
95  Y(s)+X->X
96  So, first we'll split on the "->", then split the reactants up and
97  figure out which is the gas species and which is the solid species. */
98  std::vector<std::string> partners;
99  StringUtilities::split_string(reaction, "->", partners);
100 
101  const std::string pre_split_reactants = partners[0];
102  product = partners[1];
103 
104  std::vector<std::string> split_reactants;
105  StringUtilities::split_string(pre_split_reactants, "+", split_reactants);
106 
107  // We can only handle two reactants currently
108  if( split_reactants.size() != 2 )
109  {
110  std::string error_msg = "ERROR: Currently, GasSolidCatalyticWall boundary condition only supports\n";
111  error_msg += " reactions of the form X+Y(s)->Z or Y(s)+X->X. Found ";
112  error_msg += StringUtilities::T_to_string<unsigned int>(split_reactants.size())+" reactants.\n";
113  libmesh_error_msg(error_msg);
114  }
115 
116 
117  // Check if the first reactant is the solid one
118  if( split_reactants[0].find("(s)") == split_reactants[0].npos )
119  {
120  // If not found, check the second reactant and error out if not found.
121  if( split_reactants[1].find("(s)") == split_reactants[1].npos )
122  {
123  std::string error_msg = "ERROR: could not find solid reactant for GasSolidCatalyticWall!\n";
124  error_msg += " Found reactants "+split_reactants[0]+", "+split_reactants[1]+"\n";
125  libmesh_error_msg(error_msg);
126  }
127  else
128  {
129  gas_reactant = split_reactants[0];
130  solid_reactant = split_reactants[1].substr(0,split_reactants[1].find("(s)"));
131  }
132  }
133  // Found (s) in the first reactant
134  else
135  {
136  // Check that there's not 2 solid reactants
137  if( split_reactants[1].find("(s)") != split_reactants[1].npos )
138  {
139  std::string error_msg = "ERROR: can have only one solid reactant for GasSolidCatalyticWall!\n";
140  error_msg += " Found reactants "+split_reactants[0]+", "+split_reactants[1]+"\n";
141  libmesh_error_msg(error_msg);
142  }
143 
144  gas_reactant = split_reactants[1];
145  solid_reactant = split_reactants[0].substr(0,split_reactants[0].find("(s)"));
146  }
147  }
148 
149 } // end namespace GRINS
unsigned int VariableIndex
More descriptive name of the type used for variable indices.
Definition: var_typedefs.h:42
SharedPtr< NeumannBCAbstract > build_catalytic_wall(const GetPot &input, const std::string &reaction, SharedPtr< CatalycityBase > &gamma_ptr, const std::vector< VariableIndex > &species_vars, const std::string &material, VariableIndex T_var, libMesh::Real p0, const std::string &thermochem_lib)
void parse_reactants_and_product(const std::string &reaction, std::string &gas_reactant, std::string &solid_reactant, std::string &product) const
GRINS namespace.
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
Definition: string_utils.C:31

Generated on Thu Jun 2 2016 21:52:27 for GRINS-0.7.0 by  doxygen 1.8.10