37 #include "libmesh/composite_function.h"
38 #include "libmesh/fem_context.h"
39 #include "libmesh/fem_system.h"
40 #include "libmesh/dof_map.h"
41 #include "libmesh/dirichlet_boundaries.h"
42 #include "libmesh/periodic_boundary.h"
43 #include "libmesh/dof_map.h"
44 #include "libmesh/parsed_function.h"
45 #include "libmesh/const_function.h"
53 : _physics_name( physics_name )
64 (
const libMesh::FunctionBase<libMesh::Number>& initial_val)
66 _ic_func = initial_val.clone();
70 const std::string& ic_str,
71 const std::string& var_str,
72 const std::string& value_str)
74 int num_ids = input.vector_variable_size(id_str);
75 int num_ics = input.vector_variable_size(ic_str);
76 int num_vars = input.vector_variable_size(var_str);
77 int num_values = input.vector_variable_size(value_str);
79 if( num_ids != num_ics )
81 std::cerr <<
"Error: number of subdomain ids " << num_ids
82 <<
"must equal number of initial condition types " << num_ics
87 if( num_ids != num_vars )
89 std::cerr <<
"Error: number of subdomain ids " << num_ids
90 <<
"must equal number of variable name lists " << num_vars
95 if( num_ids != num_values )
97 std::cerr <<
"Error: number of subdomain ids " << num_ids
98 <<
"must equal number of initial condition values " << num_values
105 std::cerr <<
"Error: GRINS does not yet support per-subdomain initial conditions" << std::endl;
106 libmesh_not_implemented();
109 for(
int i = 0; i < num_ids; i++ )
111 int ic_id = input(id_str, -1, i );
112 std::string ic_type_in = input(ic_str,
"NULL", i );
113 std::string ic_value_in = input(value_str,
"NULL", i );
114 std::string ic_vars_in = input(var_str,
"NULL", i );
118 std::stringstream ss;
120 std::string ic_id_string = ss.str();
122 this->
init_ic_types( ic_id, ic_id_string, ic_type, ic_vars_in, ic_value_in, input );
133 std::vector<unsigned int> index_map;
142 all_ics.attach_subfunction(*this->
get_ic_func(), index_map);
149 if( ic_type_in ==
"parsed" )
153 else if( ic_type_in ==
"constant" )
159 std::cerr <<
"==========================================================" << std::endl
160 <<
"Error: Invalid ic_type " << ic_type_in << std::endl
162 <<
"==========================================================" << std::endl;
171 const std::string& ic_vars_string,
172 const std::string& ic_value_string,
183 _ic_func = libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> >
190 _ic_func = libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> >
191 (
new libMesh::ConstFunction<libMesh::Number>
192 (StringUtilities::string_to_T<libMesh::Number>(ic_value_string)));
198 std::cerr <<
"=========================================================="
199 <<
"Error: Invalid IC type for " <<
_physics_name << std::endl
200 <<
" Detected IC type was " << ic_type << std::endl
201 <<
"==========================================================" << std::endl;
void attach_initial_func(const libMesh::FunctionBase< libMesh::Number > &initial_val)
virtual ~ICHandlingBase()
libMesh::FunctionBase< libMesh::Number > * get_ic_func() const
virtual void init_ic_types(const libMesh::subdomain_id_type ic_id, const std::string &ic_id_string, const int ic_type, const std::string &ic_vars_string, const std::string &ic_value_string, const GetPot &input)
std::string _physics_name
ICHandlingBase(const std::string &physics_name)
virtual void read_ic_data(const GetPot &input, const std::string &id_str, const std::string &ic_str, const std::string &var_str, const std::string &value_str)
virtual int string_to_int(const std::string &bc_type_in) const
std::vector< std::string > _subfunction_variables
virtual void init_ic_data(const libMesh::FEMSystem &system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
Override this method to initialize any system-dependent data.
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > _ic_func