30 #include "grins_config.h"
37 #include "libmesh/fem_context.h"
38 #include "libmesh/quadrature.h"
48 _p_pinning(input,physics_name),
49 _pin_pressure( input(
"Physics/"+
PhysicsNaming::stokes()+
"/pin_pressure", false ) )
64 _p_pinning.check_pin_location(system.get_mesh());
72 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
73 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
76 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.v()).size());
78 if (this->_flow_vars.dim() == 3)
79 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.w()).size());
85 const std::vector<libMesh::Real> &JxW =
86 context.get_element_fe(this->_flow_vars.u())->get_JxW();
90 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
91 context.get_element_fe(this->_flow_vars.u())->get_dphi();
94 const std::vector<std::vector<libMesh::Real> >& p_phi =
95 context.get_element_fe(this->_press_var.p())->get_phi();
103 libMesh::DenseSubMatrix<libMesh::Number> &Kuu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
104 libMesh::DenseSubMatrix<libMesh::Number> &Kvv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
105 libMesh::DenseSubMatrix<libMesh::Number>* Kww = NULL;
107 libMesh::DenseSubMatrix<libMesh::Number> &Kup = context.get_elem_jacobian(this->_flow_vars.u(), this->_press_var.p());
108 libMesh::DenseSubMatrix<libMesh::Number> &Kvp = context.get_elem_jacobian(this->_flow_vars.v(), this->_press_var.p());
109 libMesh::DenseSubMatrix<libMesh::Number>* Kwp = NULL;
111 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
112 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
113 libMesh::DenseSubVector<libMesh::Number>* Fw = NULL;
115 if( this->_flow_vars.dim() == 3 )
117 Kww = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.w());
118 Kwp = &context.get_elem_jacobian(this->_flow_vars.w(), this->_press_var.p());
119 Fw = &context.get_elem_residual(this->_flow_vars.w());
128 unsigned int n_qpoints = context.get_element_qrule().n_points();
130 for (
unsigned int qp=0; qp != n_qpoints; qp++)
133 libMesh::Number p, u, v, w;
134 p = context.interior_value(this->_press_var.p(), qp);
135 u = context.interior_value(this->_flow_vars.u(), qp);
136 v = context.interior_value(this->_flow_vars.v(), qp);
137 if (this->_flow_vars.dim() == 3)
138 w = context.interior_value(this->_flow_vars.w(), qp);
140 libMesh::Gradient grad_u, grad_v, grad_w;
141 grad_u = context.interior_gradient(this->_flow_vars.u(), qp);
142 grad_v = context.interior_gradient(this->_flow_vars.v(), qp);
143 if (this->_flow_vars.dim() == 3)
144 grad_w = context.interior_gradient(this->_flow_vars.w(), qp);
146 libMesh::NumberVectorValue Uvec (u,v);
147 if (this->_flow_vars.dim() == 3)
151 libMesh::Real _mu_qp = this->_mu(context, qp);
156 for (
unsigned int i=0; i != n_u_dofs; i++)
159 ( p*u_gradphi[i][qp](0)
160 -_mu_qp*(u_gradphi[i][qp]*grad_u) );
163 ( p*u_gradphi[i][qp](1)
164 -_mu_qp*(u_gradphi[i][qp]*grad_v) );
165 if (this->_flow_vars.dim() == 3)
167 (*Fw)(i) += JxW[qp] *
168 ( p*u_gradphi[i][qp](2)
169 -_mu_qp*(u_gradphi[i][qp]*grad_w) );
172 if (compute_jacobian)
174 for (
unsigned int j=0; j != n_u_dofs; j++)
181 Kuu(i,j) += JxW[qp] * context.get_elem_solution_derivative() *
182 (-_mu_qp*(u_gradphi[i][qp]*u_gradphi[j][qp]));
184 Kvv(i,j) += JxW[qp] * context.get_elem_solution_derivative() *
185 (-_mu_qp*(u_gradphi[i][qp]*u_gradphi[j][qp]));
187 if (this->_flow_vars.dim() == 3)
189 (*Kww)(i,j) += JxW[qp] * context.get_elem_solution_derivative() *
190 (-_mu_qp*(u_gradphi[i][qp]*u_gradphi[j][qp]));
195 for (
unsigned int j=0; j != n_p_dofs; j++)
197 Kup(i,j) += context.get_elem_solution_derivative() * JxW[qp]*u_gradphi[i][qp](0)*p_phi[j][qp];
198 Kvp(i,j) += context.get_elem_solution_derivative() * JxW[qp]*u_gradphi[i][qp](1)*p_phi[j][qp];
199 if (this->_flow_vars.dim() == 3)
200 (*Kwp)(i,j) += context.get_elem_solution_derivative() * JxW[qp]*u_gradphi[i][qp](2)*p_phi[j][qp];
214 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
215 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
221 const std::vector<libMesh::Real> &JxW =
222 context.get_element_fe(this->_flow_vars.u())->get_JxW();
226 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
227 context.get_element_fe(this->_flow_vars.u())->get_dphi();
230 const std::vector<std::vector<libMesh::Real> >& p_phi =
231 context.get_element_fe(this->_press_var.p())->get_phi();
237 libMesh::DenseSubMatrix<libMesh::Number> &Kpu = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.u());
238 libMesh::DenseSubMatrix<libMesh::Number> &Kpv = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.v());
239 libMesh::DenseSubMatrix<libMesh::Number>* Kpw = NULL;
241 libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p());
244 if( this->_flow_vars.dim() == 3 )
246 Kpw = &context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.w());
250 unsigned int n_qpoints = context.get_element_qrule().n_points();
251 for (
unsigned int qp=0; qp != n_qpoints; qp++)
254 libMesh::Gradient grad_u, grad_v, grad_w;
255 grad_u = context.interior_gradient(this->_flow_vars.u(), qp);
256 grad_v = context.interior_gradient(this->_flow_vars.v(), qp);
257 if (this->_flow_vars.dim() == 3)
258 grad_w = context.interior_gradient(this->_flow_vars.w(), qp);
262 for (
unsigned int i=0; i != n_p_dofs; i++)
264 Fp(i) += JxW[qp] * p_phi[i][qp] *
265 (grad_u(0) + grad_v(1));
266 if (this->_flow_vars.dim() == 3)
267 Fp(i) += JxW[qp] * p_phi[i][qp] *
270 if (compute_jacobian)
272 for (
unsigned int j=0; j != n_u_dofs; j++)
274 Kpu(i,j) += context.get_elem_solution_derivative() * JxW[qp]*p_phi[i][qp]*u_gradphi[j][qp](0);
275 Kpv(i,j) += context.get_elem_solution_derivative() * JxW[qp]*p_phi[i][qp]*u_gradphi[j][qp](1);
276 if (this->_flow_vars.dim() == 3)
277 (*Kpw)(i,j) += context.get_elem_solution_derivative() * JxW[qp]*p_phi[i][qp]*u_gradphi[j][qp](2);
289 _p_pinning.pin_value( context, compute_jacobian, this->_press_var.p() );
299 const std::vector<libMesh::Real> &JxW =
300 context.get_element_fe(this->_flow_vars.u())->get_JxW();
304 const std::vector<std::vector<libMesh::Real> >& u_phi =
305 context.get_element_fe(this->_flow_vars.u())->get_phi();
308 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
311 libMesh::DenseSubVector<libMesh::Real> &F_u = context.get_elem_residual(this->_flow_vars.u());
312 libMesh::DenseSubVector<libMesh::Real> &F_v = context.get_elem_residual(this->_flow_vars.v());
313 libMesh::DenseSubVector<libMesh::Real>* F_w = NULL;
315 libMesh::DenseSubMatrix<libMesh::Real> &M_uu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
316 libMesh::DenseSubMatrix<libMesh::Real> &M_vv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
317 libMesh::DenseSubMatrix<libMesh::Real>* M_ww = NULL;
319 if( this->_flow_vars.dim() == 3 )
321 F_w = &context.get_elem_residual(this->_flow_vars.w());
322 M_ww = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.w());
325 unsigned int n_qpoints = context.get_element_qrule().n_points();
327 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
334 libMesh::Real u_dot, v_dot, w_dot = 0.0;
335 context.interior_rate(this->_flow_vars.u(), qp, u_dot);
336 context.interior_rate(this->_flow_vars.v(), qp, v_dot);
338 if( this->_flow_vars.dim() == 3 )
339 context.interior_rate(this->_flow_vars.w(), qp, w_dot);
341 for (
unsigned int i = 0; i != n_u_dofs; ++i)
343 F_u(i) -= JxW[qp]*this->_rho*u_dot*u_phi[i][qp];
344 F_v(i) -= JxW[qp]*this->_rho*v_dot*u_phi[i][qp];
346 if( this->_flow_vars.dim() == 3 )
347 (*F_w)(i) -= JxW[qp]*this->_rho*w_dot*u_phi[i][qp];
349 if( compute_jacobian )
351 for (
unsigned int j=0; j != n_u_dofs; j++)
355 libMesh::Real value = context.get_elem_solution_derivative() * JxW[qp]*this->_rho*u_phi[i][qp]*u_phi[j][qp];
360 if( this->_flow_vars.dim() == 3)
362 (*M_ww)(i,j) -= value;
GRINS::ICHandlingBase * _ic_handler
Physics class for Incompressible Navier-Stokes.
INSTANTIATE_INC_NS_SUBCLASS(Stokes)
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...
Base class for reading and handling initial conditions for physics classes.
virtual void auxiliary_init(MultiphysicsSystem &system)
Any auxillary initialization a Physics class may need.
Interface with libMesh for solving Multiphysics problems.
virtual void element_constraint(bool compute_jacobian, AssemblyContext &context)
Constraint part(s) of physics for element interiors.
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for element interiors.