25 #ifndef GRINS_VARIABLE_FACTORY_H
26 #define GRINS_VARIABLE_FACTORY_H
34 #include "libmesh/factory.h"
52 virtual libMesh::UniquePtr<FEVariablesBase>
create();
58 static std::vector<std::string>
build_var_names(
const std::string& name );
98 virtual libMesh::UniquePtr<FEVariablesBase>
build_fe_var(
const std::vector<std::string>& var_names,
99 const std::vector<VariableIndex>& var_indices,
100 const std::set<libMesh::subdomain_id_type>& subdomain_ids ) =0;
103 virtual std::vector<std::string>
parse_var_names(
const GetPot& input,
const std::string& var_section ) =0;
105 virtual std::string
parse_fe_family_impl(
const GetPot& input,
const std::string& var_section ) =0;
107 virtual std::string
parse_fe_order_impl(
const GetPot& input,
const std::string& var_section ) =0;
110 const std::string& var_section,
111 const std::string& option,
112 const std::string& default_val )
const
114 std::string input_sec = var_section+
"/"+option;
115 if(!input.have_variable(input_sec))
116 libmesh_error_msg(
"ERROR: Could not find Variable input option "+input_sec);
118 return input(input_sec,default_val);
155 return this->
parse_var_option(input,var_section,std::string(
"fe_family"),std::string(
"DIE!"));
160 return this->
parse_var_option(input,var_section,std::string(
"order"),std::string(
"DIE!"));
166 template<
typename VariableType>
179 virtual libMesh::UniquePtr<FEVariablesBase>
181 const std::vector<VariableIndex>& var_indices,
182 const std::set<libMesh::subdomain_id_type>& subdomain_ids )
184 return libMesh::UniquePtr<FEVariablesBase>(
new VariableType(var_names,var_indices,subdomain_ids) );
188 virtual std::vector<std::string>
189 parse_var_names(
const GetPot& input,
const std::string& var_section );
196 template<
typename VariableType>
211 if( input.have_variable(var_section+
"/fe_family") )
212 libmesh_error_msg(
"ERROR: Cannot specify fe_family for ScalarVariable. It is implicitly SCALAR!");
214 return std::string(
"SCALAR");
222 template<
typename VariableType>
240 virtual std::vector<std::string>
parse_var_names(
const GetPot& input,
const std::string& var_section );
242 virtual libMesh::UniquePtr<FEVariablesBase>
build_fe_var(
const std::vector<std::string>& var_names,
243 const std::vector<VariableIndex>& var_indices,
244 const std::set<libMesh::subdomain_id_type>& subdomain_ids )
245 {
return libMesh::UniquePtr<FEVariablesBase>(
new VariableType(var_names,var_indices,
_prefix,
_material,subdomain_ids) ); }
252 template<
typename VariableType>
255 const std::string& var_section )
257 std::vector<std::string> var_names;
259 std::string input_sec = var_section+
"/names";
262 if( !input.have_variable(input_sec) )
263 libmesh_error_msg(
"ERROR: Could not find input parameter "+input_sec);
265 unsigned int n_names = input.vector_variable_size(input_sec);
267 var_names.resize(n_names);
268 for(
unsigned int i = 0; i < n_names; i++ )
269 var_names[i] = input(input_sec,std::string(
"DIE!"),i);
274 template<
typename VariableType>
277 const std::string& var_section )
280 std::string prefix_sec = var_section+
"/names";
281 if( !input.have_variable(prefix_sec) )
282 libmesh_error_msg(
"ERROR: Could not find input parameter "+prefix_sec+
" for species prefix!");
285 std::string material_sec = var_section+
"/material";
286 if( !input.have_variable(material_sec) )
287 libmesh_error_msg(
"ERROR: Could not find input parameter "+material_sec+
" for species material!");
289 this->_prefix = input(prefix_sec,std::string(
"DIE!"));
290 this->_material = input(material_sec,std::string(
"DIE!"));
292 std::vector<std::string> var_names;
300 #endif // GRINS_VARIABLE_FACTORY_H
static std::string _var_section
Section of input to parse variable names in build_var_names.
static void parse_species_varnames(const GetPot &input, const std::string &material, const std::string &prefix, std::vector< std::string > &species_names)
Helper function for parsing the chemical species and setting variable name.
virtual libMesh::UniquePtr< FEVariablesBase > build_fe_var(const std::vector< std::string > &var_names, const std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)=0
Subclasses implement construction of the FEVariablesBase object using the var_names and var_indices...
virtual void check_create_state() const
Helper function to check required data is set when calling create()
virtual std::string parse_fe_family_impl(const GetPot &input, const std::string &var_section)
virtual std::string parse_fe_family_impl(const GetPot &input, const std::string &var_section)
static void check_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
virtual libMesh::UniquePtr< FEVariablesBase > build_fe_var(const std::vector< std::string > &var_names, const std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)
Subclasses implement construction of the FEVariablesBase object using the var_names and var_indices...
virtual std::vector< std::string > parse_var_names(const GetPot &input, const std::string &var_section)=0
~SpeciesVariableFactory()
virtual void reset_create_state()
Helper function to reset data before next call to create()
static void set_var_indices(const std::vector< VariableIndex > &var_indices)
Set the variable indices before calling create()
VariableFactoryAbstract(const std::string &name)
SpeciesVariableFactory(const std::string &name)
VariableFactoryAbstract()
virtual libMesh::UniquePtr< FEVariablesBase > create()
Subclasses implement the actual construction of the Base object in create().
static const std::vector< std::string > * _var_names
Variable component names needed for FEVariableBase construction.
static void reset_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
virtual std::vector< std::string > parse_var_names(const GetPot &input, const std::string &var_section)
The basic factory implementation looks in [Variables//names].
static void set_var_names(const std::vector< std::string > &var_names)
Set the variable names before calling create()
static std::vector< std::string > build_var_names(const std::string &name)
Build the variable names for the FEVariablesBase type (name), returned in the std::vector.
static void set_subdomain_ids(const std::set< libMesh::subdomain_id_type > &subdomain_ids)
Factory to build SCALAR variable.
ScalarVariableFactory(const std::string &name)
virtual std::string parse_fe_family_impl(const GetPot &input, const std::string &var_section)=0
virtual std::vector< std::string > parse_var_names(const GetPot &input, const std::string &var_section)
Implementation species variable name parsing.
std::string parse_var_option(const GetPot &input, const std::string &var_section, const std::string &option, const std::string &default_val) const
Factory to build "standard" FEVariablesBase classes.
static void set_var_section(const std::string &var_section)
Set the section for the input file before calling build_var_names()
~VariableFactoryAbstract()
Factory to build FEVariablesBase classes that use species names as variables.
virtual std::string parse_fe_order_impl(const GetPot &input, const std::string &var_section)
VariableFactoryBasic(const std::string &name)
static std::string parse_fe_family(const std::string &name)
VariableFactoryBase(const std::string &name)
virtual libMesh::UniquePtr< FEVariablesBase > build_fe_var(const std::vector< std::string > &var_names, const std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)
Subclasses implement construction of the FEVariablesBase object using the var_names and var_indices...
static const std::set< libMesh::subdomain_id_type > * _subdomain_ids
Subdomain ids for the variable.
virtual std::string parse_fe_order_impl(const GetPot &input, const std::string &var_section)=0
static const std::vector< VariableIndex > * _var_indices
Variable component indices needed for FEVariableBase construction.
static std::string parse_fe_order(const std::string &name)
Abstract factory that provides availability of GetPot.