33 #include "libmesh/quadrature.h"
46 (
bool compute_jacobian,
50 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
53 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.v()).size());
56 if (this->_flow_vars.dim() == 3)
57 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.w()).size());
60 const std::vector<libMesh::Real> &JxW =
61 context.get_element_fe(this->_flow_vars.u())->get_JxW();
64 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
65 context.get_element_fe(this->_flow_vars.u())->get_dphi();
67 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
68 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
69 libMesh::DenseSubVector<libMesh::Number> *Fw = NULL;
70 if(this->_flow_vars.dim() == 3)
71 Fw = &context.get_elem_residual(this->_flow_vars.w());
73 libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
75 unsigned int n_qpoints = context.get_element_qrule().n_points();
77 for (
unsigned int qp=0; qp != n_qpoints; qp++)
79 libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
80 libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
82 libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ),
83 context.interior_value( this->_flow_vars.v(), qp ) );
84 if( this->_flow_vars.dim() == 3 )
86 U(2) = context.interior_value( this->_flow_vars.w(), qp );
90 libMesh::Real _mu_qp = this->_mu(context, qp);
92 libMesh::Real tau_M = this->_stab_helper.compute_tau_momentum( context, qp, g, G, this->_rho, U, _mu_qp, this->_is_steady );
93 libMesh::Real tau_C = this->_stab_helper.compute_tau_continuity( tau_M, g );
95 libMesh::RealGradient RM_s = this->_stab_helper.compute_res_momentum_steady( context, qp, this->_rho, _mu_qp );
96 libMesh::Real RC = this->_stab_helper.compute_res_continuity( context, qp );
98 for (
unsigned int i=0; i != n_u_dofs; i++)
100 Fu(i) += ( - tau_C*RC*u_gradphi[i][qp](0)
101 - tau_M*RM_s(0)*this->_rho*U*u_gradphi[i][qp] )*JxW[qp];
103 Fv(i) += ( - tau_C*RC*u_gradphi[i][qp](1)
104 - tau_M*RM_s(1)*this->_rho*U*u_gradphi[i][qp] )*JxW[qp];
106 if( this->_flow_vars.dim() == 3 )
108 (*Fw)(i) += ( - tau_C*RC*u_gradphi[i][qp](2)
109 - tau_M*RM_s(2)*this->_rho*U*u_gradphi[i][qp] )*JxW[qp];
113 if( compute_jacobian )
114 libmesh_not_implemented();
123 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
126 const std::vector<libMesh::Real> &JxW =
127 context.get_element_fe(this->_flow_vars.u())->get_JxW();
130 const std::vector<std::vector<libMesh::RealGradient> >& p_dphi =
131 context.get_element_fe(this->_press_var.p())->get_dphi();
133 libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p());
135 libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
137 unsigned int n_qpoints = context.get_element_qrule().n_points();
139 for (
unsigned int qp=0; qp != n_qpoints; qp++)
141 libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
142 libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
144 libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ),
145 context.interior_value( this->_flow_vars.v(), qp ) );
146 if( this->_flow_vars.dim() == 3 )
147 U(2) = context.interior_value( this->_flow_vars.w(), qp );
150 libMesh::Real _mu_qp = this->_mu(context, qp);
152 libMesh::Real tau_M = this->_stab_helper.compute_tau_momentum( context, qp, g, G, this->_rho, U, _mu_qp, this->_is_steady );
154 libMesh::RealGradient RM_s = this->_stab_helper.compute_res_momentum_steady( context, qp, this->_rho, _mu_qp );
156 for (
unsigned int i=0; i != n_p_dofs; i++)
157 Fp(i) += tau_M*RM_s*p_dphi[i][qp]*JxW[qp];
159 if( compute_jacobian )
160 libmesh_not_implemented();
169 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
170 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
173 const std::vector<libMesh::Real> &JxW =
174 context.get_element_fe(this->_flow_vars.u())->get_JxW();
177 const std::vector<std::vector<libMesh::RealGradient> >& p_dphi =
178 context.get_element_fe(this->_press_var.p())->get_dphi();
180 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
181 context.get_element_fe(this->_flow_vars.u())->get_dphi();
183 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
184 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
185 libMesh::DenseSubVector<libMesh::Number> *Fw = NULL;
188 if(this->_flow_vars.dim() == 3)
189 Fw = &context.get_elem_residual(this->_flow_vars.w());
191 libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p());
193 libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
195 unsigned int n_qpoints = context.get_element_qrule().n_points();
197 for (
unsigned int qp=0; qp != n_qpoints; qp++)
199 libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
200 libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
202 libMesh::RealGradient U( context.fixed_interior_value( this->_flow_vars.u(), qp ),
203 context.fixed_interior_value( this->_flow_vars.v(), qp ) );
205 libMesh::Real _mu_qp = this->_mu(context, qp);
207 if( this->_flow_vars.dim() == 3 )
209 U(2) = context.fixed_interior_value( this->_flow_vars.w(), qp );
212 libMesh::Real tau_M = this->_stab_helper.compute_tau_momentum( context, qp, g, G, this->_rho, U, _mu_qp,
false );
214 libMesh::RealGradient RM_t = this->_stab_helper.compute_res_momentum_transient( context, qp, this->_rho );
216 for (
unsigned int i=0; i != n_p_dofs; i++)
218 Fp(i) -= tau_M*RM_t*p_dphi[i][qp]*JxW[qp];
221 for (
unsigned int i=0; i != n_u_dofs; i++)
223 Fu(i) -= tau_M*RM_t(0)*this->_rho*U*u_gradphi[i][qp]*JxW[qp];
225 Fv(i) -= tau_M*RM_t(1)*this->_rho*U*u_gradphi[i][qp]*JxW[qp];
227 if( this->_flow_vars.dim() == 3 )
229 (*Fw)(i) -= tau_M*RM_t(2)*this->_rho*U*u_gradphi[i][qp]*JxW[qp];
233 if( compute_jacobian )
235 libmesh_not_implemented();
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...
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for element interiors.
IncompressibleNavierStokesSPGSMStabilization()
INSTANTIATE_INC_NS_SUBCLASS(IncompressibleNavierStokesSPGSMStabilization)
virtual void element_constraint(bool compute_jacobian, AssemblyContext &context)
Constraint part(s) of physics for element interiors.