37 #include "libmesh/getpot.h"
38 #include "libmesh/string_to_enum.h"
39 #include "libmesh/quadrature.h"
40 #include "libmesh/fem_system.h"
49 _var(input,physics_name)
51 unsigned int n_v_comps = input.vector_variable_size(
"Physics/"+physics_name+
"/velocity_field");
53 for(
unsigned int v = 0; v < n_v_comps; v++ )
54 _v[v].reparse( input(
"Physics/"+physics_name+
"/velocity_field",
"0.0", v) );
59 "Materials/"+material_name+
"/Diffusivity/value",
74 system->time_evolving(
_var.
var());
79 context.get_element_fe(
_var.
var())->get_JxW();
80 context.get_element_fe(
_var.
var())->get_phi();
81 context.get_element_fe(
_var.
var())->get_dphi();
82 context.get_element_fe(
_var.
var())->get_xyz();
89 const unsigned int n_dofs = context.get_dof_indices(
_var.
var()).size();
91 const std::vector<libMesh::Real> &JxW =
92 context.get_element_fe(
_var.
var())->get_JxW();
94 const std::vector<std::vector<libMesh::Real> >& phi =
95 context.get_element_fe(
_var.
var())->get_phi();
97 const std::vector<std::vector<libMesh::RealGradient> >& grad_phi =
98 context.get_element_fe(
_var.
var())->get_dphi();
100 const std::vector<libMesh::Point>& x =
101 context.get_element_fe(
_var.
var())->get_xyz();
103 libMesh::DenseSubVector<libMesh::Number> &F = context.get_elem_residual(
_var.
var());
105 libMesh::DenseSubMatrix<libMesh::Number> &K = context.get_elem_jacobian(
_var.
var(),
_var.
var());
107 unsigned int n_qpoints = context.get_element_qrule().n_points();
109 for (
unsigned int qp=0; qp != n_qpoints; qp++)
111 libMesh::Number c = context.interior_value(
_var.
var(), qp);
113 libMesh::Gradient grad_c;
114 context.interior_gradient(
_var.
var(), qp, grad_c);
116 libMesh::RealGradient v_qp;
117 v_qp(0) = this->
_v[0](x[qp], context.get_time());
118 v_qp(1) = this->
_v[1](x[qp], context.get_time());
119 v_qp(2) = this->
_v[2](x[qp], context.get_time());
121 libMesh::Real kappa_qp = this->
_kappa(x[qp], context.time);
123 for (
unsigned int i=0; i != n_dofs; i++)
125 F(i) += JxW[qp]*( c*(v_qp*grad_phi[i][qp])
126 - kappa_qp*(grad_c*grad_phi[i][qp]) );
128 if (compute_jacobian)
130 for (
unsigned int j=0; j != n_dofs; j++)
132 K(i,j) += context.get_elem_solution_derivative()*
133 JxW[qp]*( phi[j][qp]*(v_qp*grad_phi[i][qp])
134 - kappa_qp*(grad_phi[j][qp]*grad_phi[i][qp]) );
145 const unsigned int n_dofs = context.get_dof_indices(
_var.
var()).size();
147 const std::vector<libMesh::Real> &JxW =
148 context.get_element_fe(
_var.
var())->get_JxW();
150 const std::vector<std::vector<libMesh::Real> >& phi =
151 context.get_element_fe(
_var.
var())->get_phi();
153 libMesh::DenseSubVector<libMesh::Number> &F = context.get_elem_residual(
_var.
var());
155 libMesh::DenseSubMatrix<libMesh::Number> &M = context.get_elem_jacobian(
_var.
var(),
_var.
var());
157 unsigned int n_qpoints = context.get_element_qrule().n_points();
159 for (
unsigned int qp=0; qp != n_qpoints; qp++)
162 context.interior_rate(
_var.
var(), qp, c_dot);
164 for (
unsigned int i=0; i != n_dofs; i++)
166 F(i) -= JxW[qp]*( c_dot*phi[i][qp] );
168 if (compute_jacobian)
170 for (
unsigned int j=0; j != n_dofs; j++)
173 context.get_elem_solution_rate_derivative()*
174 JxW[qp]*( phi[j][qp]*phi[i][qp] );
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.
virtual void init_variables(libMesh::FEMSystem *system)
Initialize variables for this physics.
GRINS::ICHandlingBase * _ic_handler
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Set which variables are time evolving.
virtual void init(libMesh::FEMSystem *system)
Add variables to the system.
static void check_and_register_variable(const std::string &var_name, const FEVariablesBase &variable)
First check if var_name is registered and then register.
Base class for reading and handling initial conditions for physics classes.
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
libMesh::ParsedFunction< libMesh::Number > _kappa
Diffusivity, .
VariableIndex var() const
virtual void mass_residual(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part...
GenericFETypeVariable _var
static std::string material_name(const GetPot &input, const std::string &physics)
Get the name of the material in the Physics/physics section.
std::vector< libMesh::ParsedFunction< libMesh::Number > > _v
Velocity field, ;.
std::string section_name(const std::string &physics_name) const
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors.