GRINS-0.8.0
List of all members | Public Member Functions | Static Public Attributes | Private Attributes
GRINS::ParameterUser Class Reference

ParameterUser base class. Utility methods for subclasses. More...

#include <parameter_user.h>

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

Public Member Functions

 ParameterUser (const std::string &user_name)
 
virtual ~ParameterUser ()
 
virtual void set_parameter (libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
 Each subclass can simultaneously read a parameter value from. More...
 
virtual void set_parameter (libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void set_parameter (libMesh::ParsedFEMFunction< libMesh::Number > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void move_parameter (const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &old_func, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFEMFunction< libMesh::Number > &old_func, libMesh::ParsedFEMFunction< libMesh::Number > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void register_parameter (const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 

Static Public Attributes

static std::string zero_vector_function = std::string("{0}")
 A parseable function string with LIBMESH_DIM components, all 0. More...
 

Private Attributes

std::map< std::string, libMesh::Number * > _my_parameters
 
std::map< std::string, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > * > _my_parsed_functions
 
std::map< std::string, libMesh::ParsedFEMFunction< libMesh::Number > * > _my_parsed_fem_functions
 
std::string _my_name
 

Detailed Description

ParameterUser base class. Utility methods for subclasses.

This base class defines utility methods with which a subclass can simultaneously set a parameter from an input file and register that parameter (by input file variable name) for later parameter sensitivity studies.

Definition at line 68 of file parameter_user.h.

Constructor & Destructor Documentation

GRINS::ParameterUser::ParameterUser ( const std::string &  user_name)
inline

Definition at line 73 of file parameter_user.h.

73 : _my_name(user_name) {}
virtual GRINS::ParameterUser::~ParameterUser ( )
inlinevirtual

Definition at line 74 of file parameter_user.h.

74 {}

Member Function Documentation

void GRINS::ParameterUser::move_parameter ( const libMesh::Number &  old_parameter,
libMesh::Number &  new_parameter 
)
virtual

When cloning an object, we need to update parameter pointers.

Definition at line 113 of file parameter_user.C.

Referenced by GRINS::AverageNusseltNumber::clone(), GRINS::ParsedBoundaryQoI::ParsedBoundaryQoI(), and GRINS::ParsedInteriorQoI::ParsedInteriorQoI().

115  {
116  std::map<std::string, libMesh::Number*>::iterator it =
117  _my_parameters.begin();
118  const std::map<std::string, libMesh::Number*>::iterator end =
119  _my_parameters.end();
120  for (; it != end; ++it)
121  if (it->second == &old_parameter)
122  {
123  it->second = &new_parameter;
124  break;
125  }
126  }
std::map< std::string, libMesh::Number * > _my_parameters
void GRINS::ParameterUser::move_parameter ( const libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &  old_func,
libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &  new_func 
)
virtual

When cloning an object, we need to update parameter pointers.

Definition at line 129 of file parameter_user.C.

131  {
132  std::map
133  <std::string,
135  >::iterator it = _my_parsed_functions.begin();
136  const std::map
137  <std::string,
139  >::iterator end = _my_parsed_functions.end();
140  for (; it != end; ++it)
141  if (it->second == &old_func)
142  {
143  it->second = &new_func;
144  break;
145  }
146  }
std::map< std::string, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > * > _my_parsed_functions
void GRINS::ParameterUser::move_parameter ( const libMesh::ParsedFEMFunction< libMesh::Number > &  old_func,
libMesh::ParsedFEMFunction< libMesh::Number > &  new_func 
)
virtual

When cloning an object, we need to update parameter pointers.

Definition at line 149 of file parameter_user.C.

151  {
152  std::map
153  <std::string,
155  >::iterator it = _my_parsed_fem_functions.begin();
156  const std::map
157  <std::string,
159  >::iterator end = _my_parsed_fem_functions.end();
160  for (; it != end; ++it)
161  if (it->second == &old_func)
162  {
163  it->second = &new_func;
164  break;
165  }
166  }
std::map< std::string, libMesh::ParsedFEMFunction< libMesh::Number > * > _my_parsed_fem_functions
void GRINS::ParameterUser::register_parameter ( const std::string &  param_name,
libMesh::ParameterMultiAccessor< libMesh::Number > &  param_pointer 
) const
virtual

Each subclass will register its copy of an independent.

Reimplemented in GRINS::SpalartAllmarasStabilizationHelper, GRINS::SpalartAllmaras< Viscosity >, GRINS::CatalyticWallBase< Chemistry >, GRINS::AntiochMixture< KineticsThermoCurveFit >, GRINS::AntiochMixture< Antioch::CEACurveFit< libMesh::Real > >, GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >, GRINS::AxisymmetricHeatTransfer< Conductivity >, GRINS::SpalartAllmarasViscosity< Viscosity >, GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >, GRINS::IncompressibleNavierStokesBase< Viscosity >, GRINS::HeatConduction< Conductivity >, GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >, GRINS::HeatTransferBase< Conductivity >, GRINS::TurbulenceModelsBase< Viscosity >, GRINS::SpalartAllmarasSPGSMStabilization< Viscosity >, GRINS::ReactingLowMachNavierStokesBase< Mixture >, and GRINS::SpalartAllmarasStabilizationBase< Viscosity >.

Definition at line 170 of file parameter_user.C.

Referenced by GRINS::ReactingLowMachNavierStokesBase< Mixture >::register_parameter(), GRINS::TurbulenceModelsBase< Viscosity >::register_parameter(), GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >::register_parameter(), GRINS::HeatTransferBase< Conductivity >::register_parameter(), GRINS::HeatConduction< Conductivity >::register_parameter(), GRINS::IncompressibleNavierStokesBase< Viscosity >::register_parameter(), GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::register_parameter(), GRINS::SpalartAllmarasViscosity< Viscosity >::register_parameter(), GRINS::AxisymmetricHeatTransfer< Conductivity >::register_parameter(), GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >::register_parameter(), GRINS::AntiochMixture< KineticsThermoCurveFit >::register_parameter(), GRINS::SpalartAllmaras< Viscosity >::register_parameter(), and GRINS::SpalartAllmarasStabilizationHelper::register_parameter().

173  {
174  std::map<std::string, libMesh::Number*>::const_iterator it =
175  _my_parameters.find(param_name);
176 
177  // Make sure we don't find duplicate parameters - a Number
178  // parameter shouldn't have the same name as a ParsedFunction or
179  // ParsedFEMFunction parameter.
180 #ifndef NDEBUG
181  bool found_parameter = false;
182 #endif
183 
184  // First search for simple Number parameters
185  if (it != _my_parameters.end())
186  {
187  std::cout << _my_name << " has Number parameter " << param_name
188  << std::endl;
189  param_pointer.push_back
190  (libMesh::ParameterPointer<libMesh::Number>(it->second));
191 
192 #ifndef NDEBUG
193  found_parameter = true;
194 #else
195  return;
196 #endif
197  }
198 
199  // Next search for inline variable parameters in parsed functions
200  std::size_t last_slash_i = param_name.rfind('/');
201 
202  if (last_slash_i != std::string::npos)
203  {
204  std::string search_name = param_name.substr(0, last_slash_i);
205 
206  std::string var_name = param_name.substr(last_slash_i+1);
207 
208  std::map
209  <std::string, libMesh::ParsedFunction
210  <libMesh::Number,libMesh::Gradient>*>::const_iterator
211  pf_it = _my_parsed_functions.find(search_name);
212 
213  if (pf_it != _my_parsed_functions.end())
214  {
215  std::cout << _my_name << " has ParsedFunction for " <<
216  search_name << " / " << var_name << std::endl;
217  param_pointer.push_back
218  (libMesh::ParsedFunctionParameter<libMesh::Number>
219  (*pf_it->second, var_name));
220 
221 #ifndef NDEBUG
222  libmesh_assert(!found_parameter);
223  found_parameter = true;
224 #else
225  return;
226 #endif
227  }
228 
229  std::map
230  <std::string, libMesh::ParsedFEMFunction
231  <libMesh::Number>*>::const_iterator
232  pff_it = _my_parsed_fem_functions.find(search_name);
233 
234  if (pff_it != _my_parsed_fem_functions.end())
235  {
236  std::cout << _my_name << " has ParsedFEMFunction for " <<
237  search_name << " / " << var_name << std::endl;
238  param_pointer.push_back
239  (libMesh::ParsedFEMFunctionParameter<libMesh::Number>
240  (*pff_it->second, var_name));
241 
242 #ifndef NDEBUG
243  libmesh_assert(!found_parameter);
244 #endif
245  }
246  }
247  }
std::map< std::string, libMesh::ParsedFEMFunction< libMesh::Number > * > _my_parsed_fem_functions
std::map< std::string, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > * > _my_parsed_functions
std::map< std::string, libMesh::Number * > _my_parameters
void GRINS::ParameterUser::set_parameter ( libMesh::Number &  param_variable,
const GetPot &  input,
const std::string &  param_name,
libMesh::Number  param_default 
)
virtual

Each subclass can simultaneously read a parameter value from.

Definition at line 50 of file parameter_user.C.

References _my_name, and _my_parameters.

Referenced by GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::BoussinesqBuoyancySPGSMStabilization(), GRINS::ConstantConductivity::ConstantConductivity(), GRINS::ConstantPrandtlConductivity::ConstantPrandtlConductivity(), GRINS::ConstantSourceFunction::ConstantSourceFunction(), GRINS::ConstantSourceTerm::ConstantSourceTerm(), GRINS::ConstantSpecificHeat::ConstantSpecificHeat(), GRINS::ConstantViscosity::ConstantViscosity(), GRINS::ConvectionDiffusion::ConvectionDiffusion(), GRINS::ElasticMembraneConstantPressure::ElasticMembraneConstantPressure(), GRINS::HookesLaw::HookesLaw(), GRINS::HookesLaw1D::HookesLaw1D(), GRINS::ParsedBoundaryQoI::init(), GRINS::MooneyRivlin::MooneyRivlin(), GRINS::AverageNusseltNumber::parse_thermal_conductivity(), GRINS::ParsedConductivity::ParsedConductivity(), GRINS::ParsedSourceTerm::ParsedSourceTerm(), GRINS::ParsedViscosity::ParsedViscosity(), GRINS::ReactingLowMachNavierStokesAbstract::ReactingLowMachNavierStokesAbstract(), GRINS::MaterialsParsing::read_density(), GRINS::HookesLaw1D::read_input_options(), GRINS::HookesLaw::read_input_options(), GRINS::AxisymmetricBoussinesqBuoyancy::read_input_options(), GRINS::BoussinesqBuoyancyBase::read_property(), GRINS::MaterialsParsing::read_property(), GRINS::MaterialsParsing::read_specific_heat(), GRINS::PowerLawCatalycity::set_parameters(), GRINS::ArrheniusCatalycity::set_parameters(), GRINS::ConstantCatalycity::set_parameters(), GRINS::ScalarODE::set_time_evolving_vars(), GRINS::SpalartAllmarasParameters::SpalartAllmarasParameters(), GRINS::SpalartAllmarasStabilizationHelper::SpalartAllmarasStabilizationHelper(), and GRINS::TurbulenceModelsBase< Viscosity >::TurbulenceModelsBase().

54  {
55  param_variable = input(param_name, param_default);
56 
57  libmesh_assert_msg(!_my_parameters.count(param_name),
58  "ERROR: " << _my_name << " double-registered parameter " <<
59  param_name);
60 
61  _my_parameters[param_name] = &param_variable;
62  }
std::map< std::string, libMesh::Number * > _my_parameters
void GRINS::ParameterUser::set_parameter ( libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &  func,
const GetPot &  input,
const std::string &  func_param_name,
const std::string &  param_default 
)
virtual

Each subclass can simultaneously read a parsed function from.

Definition at line 65 of file parameter_user.C.

69  {
70  if((param_default == "DIE!") &&
71  (!input.have_variable(func_param_name)))
72  {
73  libMesh::err << "Error: Must specify parsed function for " <<
74  _my_name << std::endl
75  << " Please specify " << func_param_name << std::endl;
76  libmesh_error();
77  }
78 
79  func.reparse(input(func_param_name, param_default));
80 
81  libmesh_assert_msg(!_my_parsed_functions.count(func_param_name),
82  "ERROR: " << _my_name << " double-registered parameter " <<
83  func_param_name);
84 
85  _my_parsed_functions[func_param_name] = &func;
86  }
std::map< std::string, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > * > _my_parsed_functions
void GRINS::ParameterUser::set_parameter ( libMesh::ParsedFEMFunction< libMesh::Number > &  func,
const GetPot &  input,
const std::string &  func_param_name,
const std::string &  param_default 
)
virtual

Each subclass can simultaneously read a parsed function from.

Definition at line 89 of file parameter_user.C.

93  {
94  if((param_default == "DIE!") &&
95  (!input.have_variable(func_param_name)))
96  {
97  libMesh::err << "Error: Must specify parsed (fem) function for " <<
98  _my_name << std::endl
99  << " Please specify " << func_param_name << std::endl;
100  libmesh_error();
101  }
102 
103  func.reparse(input(func_param_name, param_default));
104 
105  libmesh_assert_msg(!_my_parsed_fem_functions.count(func_param_name),
106  "ERROR: " << _my_name << " double-registered parameter " <<
107  func_param_name);
108 
109  _my_parsed_fem_functions[func_param_name] = &func;
110  }
std::map< std::string, libMesh::ParsedFEMFunction< libMesh::Number > * > _my_parsed_fem_functions

Member Data Documentation

std::string GRINS::ParameterUser::_my_name
private

Definition at line 152 of file parameter_user.h.

Referenced by set_parameter().

std::map<std::string, libMesh::Number*> GRINS::ParameterUser::_my_parameters
private

Definition at line 140 of file parameter_user.h.

Referenced by set_parameter().

std::map<std::string, libMesh::ParsedFEMFunction<libMesh::Number>*> GRINS::ParameterUser::_my_parsed_fem_functions
private

Definition at line 148 of file parameter_user.h.

std::map<std::string, libMesh::ParsedFunction<libMesh::Number,libMesh::Gradient>*> GRINS::ParameterUser::_my_parsed_functions
private

Definition at line 144 of file parameter_user.h.

std::string GRINS::ParameterUser::zero_vector_function = std::string("{0}")
static

A parseable function string with LIBMESH_DIM components, all 0.

Definition at line 125 of file parameter_user.h.


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