36 #ifdef GRINS_HAVE_CANTERA
40 #ifdef GRINS_HAVE_ANTIOCH
45 #include "libmesh/composite_function.h"
46 #include "libmesh/const_function.h"
50 libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> >
53 std::vector<std::string>& var_names,
54 const std::string& section )
58 std::string bc_id_string = StringUtilities::T_to_string<BoundaryID>( *(
_bc_ids->begin()) );
62 std::string input_string = section+
"/"+var_input_string+
"_"+bc_id_string;
64 unsigned int n_comps = input.vector_variable_size(input_string);
66 if( var_names.size() > n_comps )
67 libmesh_error_msg(
"ERROR: Insufficient number of variable components in "+input_string+
"!");
69 libMesh::UniquePtr<libMesh::CompositeFunction<libMesh::Number> >
72 this->
add_funcs(input,system,input_string,var_names,*(remapped_func.get()));
74 return libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> >(remapped_func.release());
79 const std::string& input_string,
80 const std::vector<std::string>& var_names,
83 for(
unsigned int n = 0; n < var_names.size(); n++ )
85 std::vector<VariableIndex> dbc_vars(1,system.variable_number(var_names[n]));
86 libMesh::Number value = input(input_string, 0.0, n);
87 libMesh::ConstFunction<libMesh::Number> const_func(value);
88 composite_func.attach_subfunction(const_func, dbc_vars);
93 #if defined(GRINS_HAVE_ANTIOCH) || defined(GRINS_HAVE_CANTERA)
96 const std::string& input_string,
97 const std::vector<std::string>& var_names,
102 const std::string& input_string,
103 const std::vector<std::string>& var_names,
107 const unsigned int n_vars = var_names.size();
110 std::vector<libMesh::Number> species_mole_fracs(n_vars);
111 libMesh::Number invalid_num = std::numeric_limits<libMesh::Number>::max();
113 if( input.vector_variable_size(input_string) != n_vars )
114 libmesh_error_msg(
"ERROR: Expected "+StringUtilities::T_to_string<unsigned int>(n_vars)+
" components in "+input_string);
116 for(
unsigned int v = 0; v < n_vars; v++ )
117 species_mole_fracs[v] = input(input_string,invalid_num,v);
120 libMesh::Number sum = 0.0;
121 for(
unsigned int v = 0; v < n_vars; v++ )
122 sum += species_mole_fracs[v];
124 libMesh::Number tol = std::numeric_limits<libMesh::Number>::epsilon()*10;
125 if( std::abs(sum-1.0) > tol )
126 libmesh_error_msg(
"ERROR: Mole fractions do not sum to 1! Found sum = "+StringUtilities::T_to_string<libMesh::Number>(sum));
130 #if defined(GRINS_HAVE_ANTIOCH) || defined(GRINS_HAVE_CANTERA)
134 GRINSPrivate::VariableWarehouse::get_variable_subclass<SpeciesMassFractionsVariable>
138 std::string thermochem_lib;
143 if( thermochem_lib ==
"cantera" )
145 #ifdef GRINS_HAVE_CANTERA
146 this->convert_mole_fracs_and_add_to_func<CanteraMixture>(input,
151 libmesh_error_msg(
"Error: Cantera not enabled in this configuration. Reconfigure using --with-cantera option.");
154 else if( thermochem_lib ==
"antioch" )
156 #ifdef GRINS_HAVE_ANTIOCH
157 this->convert_mole_fracs_and_add_to_func<AntiochChemistry>(input,
162 libmesh_error_msg(
"Error: Antioch not enabled in this configuration. Reconfigure using --with-antioch option.");
166 libmesh_error_msg(
"ERROR: Invalid thermochemistry library "+thermochem_lib+
"!");
169 template<
typename ChemistryType>
172 (
const GetPot& input,
const std::vector<libMesh::Number>& species_mole_fracs,
176 const std::string& material = species_fe_var.
material();
181 libMesh::UniquePtr<ChemistryType> chem_ptr;
184 const ChemistryType & chem = *chem_ptr;
186 const unsigned int n_vars = species_mole_fracs.size();
188 libMesh::Real M = 0.0;
189 for(
unsigned int s = 0; s < n_vars; s++ )
190 M += species_mole_fracs[s]*chem.M(s);
193 for(
unsigned int s = 0; s < n_vars; s++ )
195 libMesh::Number species_mass_fracs =species_mole_fracs[s]*chem.M(s)/M;
197 std::vector<VariableIndex> var_idx(1,species_fe_var.
species(s));
199 libMesh::ConstFunction<libMesh::Number> const_func(species_mass_fracs);
200 composite_func.attach_subfunction(const_func,var_idx);
205 #ifdef GRINS_HAVE_CANTERA
209 #ifdef GRINS_HAVE_ANTIOCH
210 template void PrescribedMoleFractionsDirichletOldStyleBCFactory::convert_mole_fracs_and_add_to_func<AntiochChemistry>(
const GetPot&,
const std::vector<libMesh::Number>&,
const SpeciesMassFractionsVariable&,
libMesh::CompositeFunction<libMesh::Number>& )
const;
virtual void add_funcs(const GetPot &input, MultiphysicsSystem &system, const std::string &input_string, const std::vector< std::string > &var_names, libMesh::CompositeFunction< libMesh::Number > &composite_func) const
VariableIndex species(unsigned int species) const
static void parse_thermochemistry_model(const GetPot &input, const std::string &physics, std::string &model)
Determine thermochemistry model type.
static PhysicsName reacting_low_mach_navier_stokes()
void convert_mole_fracs_and_add_to_func(const GetPot &input, const std::vector< libMesh::Number > &species_mole_fracs, const SpeciesMassFractionsVariable &species_fe_var, libMesh::CompositeFunction< libMesh::Number > &composite_func) const
static const std::set< BoundaryID > * _bc_ids
BoundaryID for constructing a particular boundary condition.
static std::string species_mass_fractions_section()
Interface with libMesh for solving Multiphysics problems.
void build_chemistry(const GetPot &input, const std::string &material, libMesh::UniquePtr< ChemistryType > &chem_ptr)
virtual libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > build_func(const GetPot &input, MultiphysicsSystem &system, std::vector< std::string > &var_names, const std::string §ion)
Builds the FunctionBase object for boundary condition.
virtual std::string var_input_string()=0
virtual void add_funcs(const GetPot &input, MultiphysicsSystem &system, const std::string &input_string, const std::vector< std::string > &var_names, libMesh::CompositeFunction< libMesh::Number > &composite_func) const
const std::string & material() const