33 #include "libmesh/getpot.h"
34 #include "libmesh/mesh_base.h"
41 std::set<libMesh::subdomain_id_type> mesh_subdomain_ids;
42 const libMesh::MeshBase& mesh = system.get_mesh();
46 mesh.subdomain_ids(mesh_subdomain_ids);
48 std::vector<std::string> var_sections;
51 for( std::vector<std::string>::const_iterator var_sect = var_sections.begin();
52 var_sect != var_sections.end(); ++var_sect )
55 std::string var_section( *var_sect );
63 std::vector<std::string> var_names;
67 std::string fe_family = this->
parse_fe_family( input, var_section, var_type );
70 std::string order = this->
parse_fe_order( input, var_section, var_type );
73 std::set<libMesh::subdomain_id_type> subdomain_ids;
77 std::vector<VariableIndex> var_indices;
78 this->
add_vars_to_system( system, var_names, fe_family, order, var_indices, subdomain_ids );
82 SharedPtr<FEVariablesBase> fe_var = this->
build_fe_var( var_type, var_names, var_indices, subdomain_ids );
90 const std::string& var_type,
91 const std::string& var_section,
92 std::vector<std::string>& var_names )
const
104 const std::string& var_section,
105 const std::string& var_type )
const
114 const std::string& var_section,
115 const std::string& var_type )
const
125 const std::string& var_section,
126 std::set<libMesh::subdomain_id_type>& subdomain_ids )
129 if( input.have_variable(input_sec) )
131 unsigned int invalid_id = std::numeric_limits<unsigned int>::max();
133 unsigned int n_ids = input.vector_variable_size(input_sec);
134 for(
unsigned int i = 0; i < n_ids; i++ )
136 unsigned int id = input(input_sec,invalid_id,i);
137 subdomain_ids.insert(
id);
140 for( std::set<libMesh::subdomain_id_type>::const_iterator it = subdomain_ids.begin(); it != subdomain_ids.end(); ++it )
141 if( mesh_subdomain_ids.find(*it) == mesh_subdomain_ids.end() )
142 libmesh_error_msg(
"ERROR: Could not find subdomain " << *it <<
" in the mesh!");
std::string parse_fe_order(const GetPot &input, const std::string &var_section, const std::string &var_type) const
Helper function to extract [Varaiable//order] from input.
static std::string variables_section()
Helper function to encapsualte the overall [Variables] section name.
static void set_getpot(const GetPot &input)
std::string parse_var_type(const GetPot &input, const std::string &var_section) const
Parses the [Variable//var_type] option.
void parse_subdomain_ids(const std::set< libMesh::subdomain_id_type > &mesh_subdomain_ids, const GetPot &input, const std::string &var_section, std::set< libMesh::subdomain_id_type > &subdomain_ids)
static void parse_var_sections_vector(const GetPot &input, std::vector< std::string > §ions)
The same as parse_var_sections, except the result is returned in an std::vector.
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.
void add_variable_to_warehouse(SharedPtr< FEVariablesBase > &fe_var, const std::string &var_name)
Adds/registers the fe_var to VariableWarehouse.
void add_vars_to_system(MultiphysicsSystem &system, const std::vector< std::string > &var_names, const std::string &fe_family, const std::string &order, std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)
Given the names, family, and order, this adds the variables to the system and populates var_indices...
void parse_var_names(const GetPot &input, const std::string &var_type, const std::string &var_section, std::vector< std::string > &var_names) const
Parse [Variable//names].
static void set_var_section(const std::string &var_section)
Set the section for the input file before calling build_var_names()
virtual void build_variables_impl(const GetPot &input, MultiphysicsSystem &system)
Implementation of Variable construction done in subclasses.
static std::string parse_fe_family(const std::string &name)
Interface with libMesh for solving Multiphysics problems.
SharedPtr< FEVariablesBase > build_fe_var(const std::string &var_type, const std::vector< std::string > &var_names, const std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)
Sets appropriate data in the VariableFactoryAbstract and calls VariableFactoryAbstract::build() ...
std::string parse_fe_family(const GetPot &input, const std::string &var_section, const std::string &var_type) const
Helper function to extract from input.
static std::string parse_fe_order(const std::string &name)