34 #include "libmesh/boundary_info.h"
35 #include "libmesh/parsed_fem_function.h"
63 if (tdf->expression() ==
"0")
64 std::cout <<
"Warning! Zero time_deriv function specified!" << std::endl;
74 if (mrf->expression() ==
"0")
75 std::cout <<
"Warning! Zero mass_residual function specified!" << std::endl;
108 libMesh::DenseSubMatrix<libMesh::Number> &Kss =
109 context.get_elem_jacobian(this->scalar_ode_var(), this->scalar_ode_var());
111 libMesh::DenseSubVector<libMesh::Number> &Fs =
112 context.get_elem_residual(this->scalar_ode_var());
114 const libMesh::Number time_deriv =
115 (*time_deriv_function)(context, libMesh::Point(0),
120 if (compute_jacobian)
124 libMesh::DenseSubVector<libMesh::Number> &Us =
125 const_cast<libMesh::DenseSubVector<libMesh::Number>&
>
126 (context.get_elem_solution(this->scalar_ode_var()));
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),
134 Us(0) = s - this->_epsilon;
135 time_deriv_jacobian -=
136 (*time_deriv_function)(context, libMesh::Point(0),
140 time_deriv_jacobian /= (2*this->_epsilon);
142 Kss(0,0) += time_deriv_jacobian *
143 context.get_elem_solution_derivative();
153 libMesh::DenseSubMatrix<libMesh::Number> &Kss =
154 context.get_elem_jacobian(this->scalar_ode_var(), this->scalar_ode_var());
156 libMesh::DenseSubVector<libMesh::Number> &Fs =
157 context.get_elem_residual(this->scalar_ode_var());
159 const libMesh::Number mass_res =
160 (*mass_residual_function)(context, libMesh::Point(0),
165 if (compute_jacobian)
169 libMesh::DenseSubVector<libMesh::Number> &Us =
170 const_cast<libMesh::DenseSubVector<libMesh::Number>&
>
171 (context.get_elem_solution_rate(this->scalar_ode_var()));
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),
179 Us(0) = s - this->_epsilon;
180 mass_residual_jacobian -=
181 (*mass_residual_function)(context, libMesh::Point(0),
185 mass_residual_jacobian /= (2*this->_epsilon);
187 Kss(0,0) -= mass_residual_jacobian *
188 context.get_elem_solution_rate_derivative();
198 libMesh::DenseSubMatrix<libMesh::Number> &Kss =
199 context.get_elem_jacobian(this->scalar_ode_var(), this->scalar_ode_var());
201 libMesh::DenseSubVector<libMesh::Number> &Fs =
202 context.get_elem_residual(this->scalar_ode_var());
204 const libMesh::Number constraint =
205 (*constraint_function)(context, libMesh::Point(0),
210 if (compute_jacobian)
214 libMesh::DenseSubVector<libMesh::Number> &Us =
215 const_cast<libMesh::DenseSubVector<libMesh::Number>&
>
216 (context.get_elem_solution(this->scalar_ode_var()));
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),
224 Us(0) = s - this->_epsilon;
225 constraint_jacobian -=
226 (*constraint_function)(context, libMesh::Point(0),
230 constraint_jacobian /= (2*this->_epsilon);
232 Kss(0,0) += constraint_jacobian *
233 context.get_elem_solution_derivative();
virtual void set_parameter(libMesh::Number ¶m_variable, const GetPot &input, const std::string ¶m_name, libMesh::Number param_default)
Each subclass can simultaneously read a parameter value from.
GRINS::ICHandlingBase * _ic_handler
static PhysicsName scalar_ode()
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > mass_residual_function
virtual void nonlocal_mass_residual(bool compute_jacobian, AssemblyContext &context)
Mass matrix part(s) for scalar variables.
Base class for reading and handling initial conditions for physics classes.
void read_input_options(const GetPot &input)
Read options from GetPot input file.
virtual void init_context(AssemblyContext &context)
Prepare the context for evaluations.
virtual void nonlocal_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for scalar variables.
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Sets scalar variable(s) to be time-evolving.
virtual void nonlocal_constraint(bool compute_jacobian, AssemblyContext &context)
Constraint part(s) of physics for scalar variables.
Variables with a single SCALAR component.
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > time_deriv_function
VariableIndex scalar_ode_var() const
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > constraint_function