38 #include "libmesh/getpot.h"
39 #include "libmesh/string_to_enum.h"
40 #include "libmesh/quadrature.h"
41 #include "libmesh/fem_system.h"
52 unsigned int n_v_comps = input.vector_variable_size(
"Physics/"+physics_name+
"/velocity_field");
54 for(
unsigned int v = 0; v < n_v_comps; v++ )
55 _v[v].reparse( input(
"Physics/"+physics_name+
"/velocity_field",
"0.0", v) );
60 "Materials/"+material_name+
"/Diffusivity/value",
70 system->time_evolving(
_var.
var(), 1);
75 context.get_element_fe(
_var.
var())->get_JxW();
76 context.get_element_fe(
_var.
var())->get_phi();
77 context.get_element_fe(
_var.
var())->get_dphi();
78 context.get_element_fe(
_var.
var())->get_xyz();
82 (
bool compute_jacobian,
85 const unsigned int n_dofs = context.get_dof_indices(_var.var()).size();
87 const std::vector<libMesh::Real> &JxW =
88 context.get_element_fe(_var.var())->get_JxW();
90 const std::vector<std::vector<libMesh::Real> >& phi =
91 context.get_element_fe(_var.var())->get_phi();
93 const std::vector<std::vector<libMesh::RealGradient> >& grad_phi =
94 context.get_element_fe(_var.var())->get_dphi();
96 const std::vector<libMesh::Point>& x =
97 context.get_element_fe(_var.var())->get_xyz();
99 libMesh::DenseSubVector<libMesh::Number> &F = context.get_elem_residual(_var.var());
101 libMesh::DenseSubMatrix<libMesh::Number> &K = context.get_elem_jacobian(_var.var(), _var.var());
103 unsigned int n_qpoints = context.get_element_qrule().n_points();
105 for (
unsigned int qp=0; qp != n_qpoints; qp++)
107 libMesh::Number c = context.interior_value(_var.var(), qp);
109 libMesh::Gradient grad_c;
110 context.interior_gradient(_var.var(), qp, grad_c);
112 libMesh::RealGradient v_qp;
113 v_qp(0) = this->_v[0](x[qp], context.get_time());
114 v_qp(1) = this->_v[1](x[qp], context.get_time());
115 v_qp(2) = this->_v[2](x[qp], context.get_time());
117 libMesh::Real kappa_qp = this->_kappa(x[qp], context.time);
119 for (
unsigned int i=0; i != n_dofs; i++)
121 F(i) += JxW[qp]*( c*(v_qp*grad_phi[i][qp])
122 - kappa_qp*(grad_c*grad_phi[i][qp]) );
124 if (compute_jacobian)
126 for (
unsigned int j=0; j != n_dofs; j++)
128 K(i,j) += context.get_elem_solution_derivative()*
129 JxW[qp]*( phi[j][qp]*(v_qp*grad_phi[i][qp])
130 - kappa_qp*(grad_phi[j][qp]*grad_phi[i][qp]) );
140 const unsigned int n_dofs = context.get_dof_indices(_var.var()).size();
142 const std::vector<libMesh::Real> &JxW =
143 context.get_element_fe(_var.var())->get_JxW();
145 const std::vector<std::vector<libMesh::Real> >& phi =
146 context.get_element_fe(_var.var())->get_phi();
148 libMesh::DenseSubVector<libMesh::Number> &F = context.get_elem_residual(_var.var());
150 libMesh::DenseSubMatrix<libMesh::Number> &M = context.get_elem_jacobian(_var.var(), _var.var());
152 unsigned int n_qpoints = context.get_element_qrule().n_points();
154 for (
unsigned int qp=0; qp != n_qpoints; qp++)
157 context.interior_rate(_var.var(), qp, c_dot);
159 for (
unsigned int i=0; i != n_dofs; i++)
161 F(i) -= JxW[qp]*( c_dot*phi[i][qp] );
163 if (compute_jacobian)
165 for (
unsigned int j=0; j != n_dofs; j++)
168 context.get_elem_solution_rate_derivative()*
169 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 element_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for element interiors.
GRINS::ICHandlingBase * _ic_handler
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
Variables with a single component.
void check_var_subdomain_consistency(const FEVariablesBase &var) const
Check that var is enabled on at least the subdomains this Physics is.
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Set which variables are time evolving.
Base class for reading and handling initial conditions for physics classes.
VariableIndex var() const
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
libMesh::ParsedFunction< libMesh::Number > _kappa
Diffusivity, .
virtual void mass_residual(bool compute_jacobian, AssemblyContext &context)
Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part...
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, ;.