GRINS-0.8.0
List of all members | Public Member Functions | Protected Types | Protected Attributes
GRINS::ICHandlingBase Class Reference

Base class for reading and handling initial conditions for physics classes. More...

#include <ic_handling_base.h>

Inheritance diagram for GRINS::ICHandlingBase:
Inheritance graph
[legend]

Public Member Functions

 ICHandlingBase (const std::string &physics_name)
 
virtual ~ICHandlingBase ()
 
void attach_initial_func (const libMesh::FunctionBase< libMesh::Number > &initial_val)
 
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 void init_ic_data (const libMesh::FEMSystem &system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
 Override this method to initialize any system-dependent data. More...
 
virtual int string_to_int (const std::string &bc_type_in) 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)
 
libMesh::FunctionBase< libMesh::Number > * get_ic_func () const
 

Protected Types

enum  IC_BASE { PARSED = -2, CONSTANT }
 

Protected Attributes

libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > _ic_func
 
std::string _physics_name
 
std::vector< std::string > _subfunction_variables
 

Detailed Description

Base class for reading and handling initial conditions for physics classes.

Definition at line 51 of file ic_handling_base.h.

Member Enumeration Documentation

Enumerator
PARSED 
CONSTANT 

Definition at line 90 of file ic_handling_base.h.

Constructor & Destructor Documentation

GRINS::ICHandlingBase::ICHandlingBase ( const std::string &  physics_name)

Definition at line 52 of file ic_handling_base.C.

53  : _physics_name( physics_name )
54  {
55  return;
56  }
GRINS::ICHandlingBase::~ICHandlingBase ( )
virtual

Definition at line 58 of file ic_handling_base.C.

59  {
60  return;
61  }

Member Function Documentation

void GRINS::ICHandlingBase::attach_initial_func ( const libMesh::FunctionBase< libMesh::Number > &  initial_val)

Definition at line 64 of file ic_handling_base.C.

65  {
66  _ic_func = initial_val.clone();
67  }
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > _ic_func
libMesh::FunctionBase< libMesh::Number > * GRINS::ICHandlingBase::get_ic_func ( ) const
inline

Definition at line 99 of file ic_handling_base.h.

References _ic_func.

Referenced by init_ic_data().

100  {
101  return _ic_func.get();
102  }
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > _ic_func
void GRINS::ICHandlingBase::init_ic_data ( const libMesh::FEMSystem &  system,
libMesh::CompositeFunction< libMesh::Number > &  all_ics 
)
virtual

Override this method to initialize any system-dependent data.

Override this method to, for example, cache a System variable number.

Definition at line 128 of file ic_handling_base.C.

References _subfunction_variables, and get_ic_func().

Referenced by GRINS::Physics::init_ics().

130  {
131  if (this->get_ic_func())
132  {
133  std::vector<unsigned int> index_map;
134 
135  libmesh_assert(_subfunction_variables.size());
136 
137  for (unsigned int i=0; i != _subfunction_variables.size();
138  ++i)
139  index_map.push_back
140  (system.variable_number(_subfunction_variables[i]));
141 
142  all_ics.attach_subfunction(*this->get_ic_func(), index_map);
143  }
144  }
libMesh::FunctionBase< libMesh::Number > * get_ic_func() const
std::vector< std::string > _subfunction_variables
void GRINS::ICHandlingBase::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 
)
virtual

Definition at line 168 of file ic_handling_base.C.

References _ic_func, _physics_name, _subfunction_variables, CONSTANT, PARSED, and GRINS::StringUtilities::split_string().

Referenced by read_ic_data().

174  {
176 
177  libmesh_assert(_subfunction_variables.size());
178 
179  switch(ic_type)
180  {
181  case(PARSED):
182  {
183  _ic_func = libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> >
184  (new libMesh::ParsedFunction<libMesh::Number>(ic_value_string));
185  }
186  break;
187 
188  case(CONSTANT):
189  {
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)));
193  }
194  break;
195 
196  default:
197  {
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;
202  libmesh_error();
203  }
204  }
205  return;
206  }
std::vector< std::string > _subfunction_variables
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
Definition: string_utils.C:31
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > _ic_func
void GRINS::ICHandlingBase::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

Definition at line 69 of file ic_handling_base.C.

References init_ic_types(), and string_to_int().

Referenced by GRINS::GenericICHandler::GenericICHandler().

73  {
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);
78 
79  if( num_ids != num_ics )
80  {
81  std::cerr << "Error: number of subdomain ids " << num_ids
82  << "must equal number of initial condition types " << num_ics
83  << std::endl;
84  libmesh_error();
85  }
86 
87  if( num_ids != num_vars )
88  {
89  std::cerr << "Error: number of subdomain ids " << num_ids
90  << "must equal number of variable name lists " << num_vars
91  << std::endl;
92  libmesh_error();
93  }
94 
95  if( num_ids != num_values )
96  {
97  std::cerr << "Error: number of subdomain ids " << num_ids
98  << "must equal number of initial condition values " << num_values
99  << std::endl;
100  libmesh_error();
101  }
102 
103  if( num_ids > 1 )
104  {
105  std::cerr << "Error: GRINS does not yet support per-subdomain initial conditions" << std::endl;
106  libmesh_not_implemented();
107  }
108 
109  for( int i = 0; i < num_ids; i++ )
110  {
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 );
115 
116  int ic_type = this->string_to_int( ic_type_in );
117 
118  std::stringstream ss;
119  ss << ic_id;
120  std::string ic_id_string = ss.str();
121 
122  this->init_ic_types( ic_id, ic_id_string, ic_type, ic_vars_in, ic_value_in, input );
123  }
124 
125  return;
126  }
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)
virtual int string_to_int(const std::string &bc_type_in) const
int GRINS::ICHandlingBase::string_to_int ( const std::string &  bc_type_in) const
virtual

Definition at line 146 of file ic_handling_base.C.

References _physics_name, CONSTANT, and PARSED.

Referenced by read_ic_data().

147  {
148  int ic_type_out;
149  if( ic_type_in == "parsed" )
150  {
151  ic_type_out = PARSED;
152  }
153  else if( ic_type_in == "constant" )
154  {
155  ic_type_out = CONSTANT;
156  }
157  else
158  {
159  std::cerr << "==========================================================" << std::endl
160  << "Error: Invalid ic_type " << ic_type_in << std::endl
161  << " Physics class is " << _physics_name << std::endl
162  << "==========================================================" << std::endl;
163  libmesh_error();
164  }
165  return ic_type_out;
166  }

Member Data Documentation

libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> > GRINS::ICHandlingBase::_ic_func
protected

Definition at line 86 of file ic_handling_base.h.

Referenced by get_ic_func(), and init_ic_types().

std::string GRINS::ICHandlingBase::_physics_name
protected
std::vector<std::string> GRINS::ICHandlingBase::_subfunction_variables
protected

Definition at line 93 of file ic_handling_base.h.

Referenced by init_ic_data(), and init_ic_types().


The documentation for this class was generated from the following files:

Generated on Tue Dec 19 2017 12:47:31 for GRINS-0.8.0 by  doxygen 1.8.9.1