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

Physics class for arbitrary scalar-valued ODEs. More...

#include <scalar_ode.h>

Inheritance diagram for GRINS::ScalarODE:
Inheritance graph
[legend]
Collaboration diagram for GRINS::ScalarODE:
Collaboration graph
[legend]

Public Member Functions

 ScalarODE (const std::string &physics_name, const GetPot &input)
 
 ~ScalarODE ()
 
virtual void set_time_evolving_vars (libMesh::FEMSystem *system)
 Sets scalar variable(s) to be time-evolving. More...
 
virtual void init_context (AssemblyContext &context)
 Prepare the context for evaluations. More...
 
virtual void nonlocal_time_derivative (bool compute_jacobian, AssemblyContext &context)
 Time dependent part(s) of physics for scalar variables. More...
 
virtual void nonlocal_constraint (bool compute_jacobian, AssemblyContext &context)
 Constraint part(s) of physics for scalar variables. More...
 
virtual void nonlocal_mass_residual (bool compute_jacobian, AssemblyContext &context)
 Mass matrix part(s) for scalar variables. More...
 
VariableIndex scalar_ode_var () const
 
- Public Member Functions inherited from GRINS::Physics
 Physics (const GRINS::PhysicsName &physics_name, const GetPot &input)
 
virtual ~Physics ()
 
virtual void init_variables (libMesh::FEMSystem *)
 Initialize variables for this physics. More...
 
virtual bool enabled_on_elem (const libMesh::Elem *elem)
 Find if current physics is active on supplied element. More...
 
void set_is_steady (bool is_steady)
 Sets whether this physics is to be solved with a steady solver or not. More...
 
bool is_steady () const
 Returns whether or not this physics is being solved with a steady solver. More...
 
virtual void auxiliary_init (MultiphysicsSystem &system)
 Any auxillary initialization a Physics class may need. More...
 
virtual void register_postprocessing_vars (const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
 Register name of postprocessed quantity with PostProcessedQuantities. More...
 
virtual void preassembly (MultiphysicsSystem &)
 Perform any necessary setup before element assembly begins. More...
 
virtual void reinit (MultiphysicsSystem &)
 Any reinitialization that needs to be done. More...
 
virtual void element_time_derivative (bool, AssemblyContext &)
 Time dependent part(s) of physics for element interiors. More...
 
virtual void side_time_derivative (bool, AssemblyContext &)
 Time dependent part(s) of physics for boundaries of elements on the domain boundary. More...
 
virtual void element_constraint (bool, AssemblyContext &)
 Constraint part(s) of physics for element interiors. More...
 
virtual void side_constraint (bool, AssemblyContext &)
 Constraint part(s) of physics for boundaries of elements on the domain boundary. More...
 
virtual void damping_residual (bool, AssemblyContext &)
 Damping matrix part(s) for element interiors. All boundary terms lie within the time_derivative part. More...
 
virtual void mass_residual (bool, AssemblyContext &)
 Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part. More...
 
void init_ics (libMesh::FEMSystem *system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
 
virtual void compute_element_time_derivative_cache (AssemblyContext &)
 
virtual void compute_side_time_derivative_cache (AssemblyContext &)
 
virtual void compute_nonlocal_time_derivative_cache (AssemblyContext &)
 
virtual void compute_element_constraint_cache (AssemblyContext &)
 
virtual void compute_side_constraint_cache (AssemblyContext &)
 
virtual void compute_nonlocal_constraint_cache (AssemblyContext &)
 
virtual void compute_damping_residual_cache (AssemblyContext &)
 
virtual void compute_mass_residual_cache (AssemblyContext &)
 
virtual void compute_nonlocal_mass_residual_cache (AssemblyContext &)
 
virtual void compute_postprocessed_quantity (unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
 
ICHandlingBaseget_ic_handler ()
 
- Public Member Functions inherited from GRINS::ParameterUser
 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...
 

Private Member Functions

 ScalarODE ()
 
void read_input_options (const GetPot &input)
 Read options from GetPot input file. More...
 

Private Attributes

libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > time_deriv_function
 
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > constraint_function
 
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > mass_residual_function
 
libMesh::Number _epsilon
 
const GetPot & _input
 
ScalarVariable_var
 

Additional Inherited Members

- Static Public Member Functions inherited from GRINS::Physics
static void set_is_axisymmetric (bool is_axisymmetric)
 Set whether we should treat the problem as axisymmetric. More...
 
static bool is_axisymmetric ()
 
- Static Public Attributes inherited from GRINS::ParameterUser
static std::string zero_vector_function = std::string("{0}")
 A parseable function string with LIBMESH_DIM components, all 0. More...
 
- Protected Member Functions inherited from GRINS::Physics
libMesh::UniquePtr< libMesh::FEGenericBase< libMesh::Real > > build_new_fe (const libMesh::Elem *elem, const libMesh::FEGenericBase< libMesh::Real > *fe, const libMesh::Point p)
 
void parse_enabled_subdomains (const GetPot &input, const std::string &physics_name)
 
void check_var_subdomain_consistency (const FEVariablesBase &var) const
 Check that var is enabled on at least the subdomains this Physics is. More...
 
- Protected Attributes inherited from GRINS::Physics
const PhysicsName _physics_name
 Name of the physics object. Used for reading physics specific inputs. More...
 
GRINS::ICHandlingBase_ic_handler
 
std::set< libMesh::subdomain_id_type > _enabled_subdomains
 Subdomains on which the current Physics class is enabled. More...
 
- Static Protected Attributes inherited from GRINS::Physics
static bool _is_steady = false
 Caches whether or not the solver that's being used is steady or not. More...
 
static bool _is_axisymmetric = false
 Caches whether we are solving an axisymmetric problem or not. More...
 

Detailed Description

Physics class for arbitrary scalar-valued ODEs.

Definition at line 51 of file scalar_ode.h.

Constructor & Destructor Documentation

GRINS::ScalarODE::ScalarODE ( const std::string &  physics_name,
const GetPot &  input 
)

Definition at line 40 of file scalar_ode.C.

References GRINS::Physics::_ic_handler, and read_input_options().

41  : Physics(physics_name, input),
42  _epsilon(1e-6),
43  _input(input),
44  _var(GRINSPrivate::VariableWarehouse::get_variable_subclass<ScalarVariable>(VariablesParsing::scalar_variable_name(input,physics_name,VariablesParsing::PHYSICS)))
45  {
46  this->read_input_options(input);
47 
48  this->_ic_handler = new GenericICHandler( physics_name, input );
49  }
GRINS::ICHandlingBase * _ic_handler
Definition: physics.h:258
const GetPot & _input
Definition: scalar_ode.h:94
void read_input_options(const GetPot &input)
Read options from GetPot input file.
Definition: scalar_ode.C:91
libMesh::Number _epsilon
Definition: scalar_ode.h:92
ScalarVariable & _var
Definition: scalar_ode.h:96
static std::string scalar_variable_name(const GetPot &input, const std::string &subsection_name, const SECTION_TYPE section_type)
GRINS::ScalarODE::~ScalarODE ( )
inline

Definition at line 57 of file scalar_ode.h.

57 {};
GRINS::ScalarODE::ScalarODE ( )
private

Member Function Documentation

void GRINS::ScalarODE::init_context ( AssemblyContext context)
virtual

Prepare the context for evaluations.

Reimplemented from GRINS::Physics.

Definition at line 97 of file scalar_ode.C.

References constraint_function, mass_residual_function, and time_deriv_function.

98  {
99  mass_residual_function->init_context(context);
100  time_deriv_function->init_context(context);
101  constraint_function->init_context(context);
102  }
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > mass_residual_function
Definition: scalar_ode.h:87
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > time_deriv_function
Definition: scalar_ode.h:87
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > constraint_function
Definition: scalar_ode.h:87
void GRINS::ScalarODE::nonlocal_constraint ( bool  ,
AssemblyContext  
)
virtual

Constraint part(s) of physics for scalar variables.

Reimplemented from GRINS::Physics.

Definition at line 196 of file scalar_ode.C.

197  {
198  libMesh::DenseSubMatrix<libMesh::Number> &Kss =
199  context.get_elem_jacobian(this->scalar_ode_var(), this->scalar_ode_var()); // R_{s},{s}
200 
201  libMesh::DenseSubVector<libMesh::Number> &Fs =
202  context.get_elem_residual(this->scalar_ode_var()); // R_{s}
203 
204  const libMesh::Number constraint =
205  (*constraint_function)(context, libMesh::Point(0),
206  context.get_time());
207 
208  Fs(0) += constraint;
209 
210  if (compute_jacobian)
211  {
212  // FIXME: we should replace this hacky FDM with a hook to the
213  // AD fparser stuff
214  libMesh::DenseSubVector<libMesh::Number> &Us =
215  const_cast<libMesh::DenseSubVector<libMesh::Number>&>
216  (context.get_elem_solution(this->scalar_ode_var())); // U_{s}
217 
218  const libMesh::Number s = Us(0);
219  Us(0) = s + this->_epsilon;
220  libMesh::Number constraint_jacobian =
221  (*constraint_function)(context, libMesh::Point(0),
222  context.get_time());
223 
224  Us(0) = s - this->_epsilon;
225  constraint_jacobian -=
226  (*constraint_function)(context, libMesh::Point(0),
227  context.get_time());
228 
229  Us(0) = s;
230  constraint_jacobian /= (2*this->_epsilon);
231 
232  Kss(0,0) += constraint_jacobian *
233  context.get_elem_solution_derivative();
234  }
235 
236  return;
237  }
libMesh::Number _epsilon
Definition: scalar_ode.h:92
VariableIndex scalar_ode_var() const
Definition: scalar_ode.h:79
void GRINS::ScalarODE::nonlocal_mass_residual ( bool  ,
AssemblyContext  
)
virtual

Mass matrix part(s) for scalar variables.

Reimplemented from GRINS::Physics.

Definition at line 151 of file scalar_ode.C.

152  {
153  libMesh::DenseSubMatrix<libMesh::Number> &Kss =
154  context.get_elem_jacobian(this->scalar_ode_var(), this->scalar_ode_var()); // R_{s},{s}
155 
156  libMesh::DenseSubVector<libMesh::Number> &Fs =
157  context.get_elem_residual(this->scalar_ode_var()); // R_{s}
158 
159  const libMesh::Number mass_res =
160  (*mass_residual_function)(context, libMesh::Point(0),
161  context.get_time());
162 
163  Fs(0) -= mass_res;
164 
165  if (compute_jacobian)
166  {
167  // FIXME: we should replace this hacky FDM with a hook to the
168  // AD fparser stuff
169  libMesh::DenseSubVector<libMesh::Number> &Us =
170  const_cast<libMesh::DenseSubVector<libMesh::Number>&>
171  (context.get_elem_solution_rate(this->scalar_ode_var())); // U_{s}
172 
173  const libMesh::Number s = Us(0);
174  Us(0) = s + this->_epsilon;
175  libMesh::Number mass_residual_jacobian =
176  (*mass_residual_function)(context, libMesh::Point(0),
177  context.get_time());
178 
179  Us(0) = s - this->_epsilon;
180  mass_residual_jacobian -=
181  (*mass_residual_function)(context, libMesh::Point(0),
182  context.get_time());
183 
184  Us(0) = s;
185  mass_residual_jacobian /= (2*this->_epsilon);
186 
187  Kss(0,0) -= mass_residual_jacobian *
188  context.get_elem_solution_rate_derivative();
189  }
190 
191  return;
192  }
libMesh::Number _epsilon
Definition: scalar_ode.h:92
VariableIndex scalar_ode_var() const
Definition: scalar_ode.h:79
void GRINS::ScalarODE::nonlocal_time_derivative ( bool  ,
AssemblyContext  
)
virtual

Time dependent part(s) of physics for scalar variables.

Reimplemented from GRINS::Physics.

Definition at line 106 of file scalar_ode.C.

107  {
108  libMesh::DenseSubMatrix<libMesh::Number> &Kss =
109  context.get_elem_jacobian(this->scalar_ode_var(), this->scalar_ode_var()); // R_{s},{s}
110 
111  libMesh::DenseSubVector<libMesh::Number> &Fs =
112  context.get_elem_residual(this->scalar_ode_var()); // R_{s}
113 
114  const libMesh::Number time_deriv =
115  (*time_deriv_function)(context, libMesh::Point(0),
116  context.get_time());
117 
118  Fs(0) += time_deriv;
119 
120  if (compute_jacobian)
121  {
122  // FIXME: we should replace this hacky FDM with a hook to the
123  // AD fparser stuff
124  libMesh::DenseSubVector<libMesh::Number> &Us =
125  const_cast<libMesh::DenseSubVector<libMesh::Number>&>
126  (context.get_elem_solution(this->scalar_ode_var())); // U_{s}
127 
128  const libMesh::Number s = Us(0);
129  Us(0) = s + this->_epsilon;
130  libMesh::Number time_deriv_jacobian =
131  (*time_deriv_function)(context, libMesh::Point(0),
132  context.get_time());
133 
134  Us(0) = s - this->_epsilon;
135  time_deriv_jacobian -=
136  (*time_deriv_function)(context, libMesh::Point(0),
137  context.get_time());
138 
139  Us(0) = s;
140  time_deriv_jacobian /= (2*this->_epsilon);
141 
142  Kss(0,0) += time_deriv_jacobian *
143  context.get_elem_solution_derivative();
144  }
145 
146  return;
147  }
libMesh::Number _epsilon
Definition: scalar_ode.h:92
VariableIndex scalar_ode_var() const
Definition: scalar_ode.h:79
void GRINS::ScalarODE::read_input_options ( const GetPot &  input)
private

Read options from GetPot input file.

Definition at line 91 of file scalar_ode.C.

References _epsilon, and GRINS::PhysicsNaming::scalar_ode().

Referenced by ScalarODE().

92  {
93  this->_epsilon = input("Physics/"+PhysicsNaming::scalar_ode()+"/epsilon", 1e-6);
94  }
static PhysicsName scalar_ode()
libMesh::Number _epsilon
Definition: scalar_ode.h:92
VariableIndex GRINS::ScalarODE::scalar_ode_var ( ) const
inline

Definition at line 79 of file scalar_ode.h.

References _var, and GRINS::SingleVariable::var().

Referenced by set_time_evolving_vars().

80  { return _var.var(); }
VariableIndex var() const
ScalarVariable & _var
Definition: scalar_ode.h:96
void GRINS::ScalarODE::set_time_evolving_vars ( libMesh::FEMSystem *  system)
virtual

Sets scalar variable(s) to be time-evolving.

Reimplemented from GRINS::Physics.

Definition at line 51 of file scalar_ode.C.

References _input, constraint_function, mass_residual_function, GRINS::PhysicsNaming::scalar_ode(), scalar_ode_var(), GRINS::ParameterUser::set_parameter(), and time_deriv_function.

52  {
53  system->time_evolving(this->scalar_ode_var(), 1);
54 
55  // FIXME: this doesn't fit here at all, but it's the only time
56  // we've clearly got a System to grab hold of with all it's
57  // variables initialized.
58 
61  this->time_deriv_function.reset(tdf);
62 
63  if (tdf->expression() == "0")
64  std::cout << "Warning! Zero time_deriv function specified!" << std::endl;
65 
66  this->set_parameter(*tdf, _input,
67  "Physics/"+PhysicsNaming::scalar_ode()+"/time_deriv",
68  std::string("0"));
69 
72  this->mass_residual_function.reset(mrf);
73 
74  if (mrf->expression() == "0")
75  std::cout << "Warning! Zero mass_residual function specified!" << std::endl;
76 
77  this->set_parameter(*mrf, _input,
78  "Physics/"+PhysicsNaming::scalar_ode()+"/mass_residual",
79  std::string("0"));
80 
83  this->constraint_function.reset(cf);
84 
85  this->set_parameter(*cf, _input,
86  "Physics/"+PhysicsNaming::scalar_ode()+"/constraint",
87  std::string("0"));
88  }
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.
const GetPot & _input
Definition: scalar_ode.h:94
static PhysicsName scalar_ode()
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > mass_residual_function
Definition: scalar_ode.h:87
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > time_deriv_function
Definition: scalar_ode.h:87
VariableIndex scalar_ode_var() const
Definition: scalar_ode.h:79
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > constraint_function
Definition: scalar_ode.h:87

Member Data Documentation

libMesh::Number GRINS::ScalarODE::_epsilon
private

Definition at line 92 of file scalar_ode.h.

Referenced by read_input_options().

const GetPot& GRINS::ScalarODE::_input
private

Definition at line 94 of file scalar_ode.h.

Referenced by set_time_evolving_vars().

ScalarVariable& GRINS::ScalarODE::_var
private

Definition at line 96 of file scalar_ode.h.

Referenced by scalar_ode_var().

libMesh::UniquePtr<libMesh::FEMFunctionBase<libMesh::Number> > GRINS::ScalarODE::constraint_function
private

Definition at line 87 of file scalar_ode.h.

Referenced by init_context(), and set_time_evolving_vars().

libMesh::UniquePtr<libMesh::FEMFunctionBase<libMesh::Number> > GRINS::ScalarODE::mass_residual_function
private

Definition at line 87 of file scalar_ode.h.

Referenced by init_context(), and set_time_evolving_vars().

libMesh::UniquePtr<libMesh::FEMFunctionBase<libMesh::Number> > GRINS::ScalarODE::time_deriv_function
private

Definition at line 87 of file scalar_ode.h.

Referenced by init_context(), and set_time_evolving_vars().


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

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