34 #include "libmesh/quadrature.h"
47 (
bool compute_jacobian,
51 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
52 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
55 const std::vector<libMesh::Real> &JxW =
56 context.get_element_fe(this->_flow_vars.u())->get_JxW();
58 const std::vector<std::vector<libMesh::RealGradient> >& p_gradphi =
59 context.get_element_fe(this->_press_var.p())->get_dphi();
61 const std::vector<std::vector<libMesh::Real> >& u_phi =
62 context.get_element_fe(this->_flow_vars.u())->get_phi();
64 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
65 context.get_element_fe(this->_flow_vars.u())->get_dphi();
67 const std::vector<std::vector<libMesh::RealTensor> >& u_hessphi =
68 context.get_element_fe(this->_flow_vars.u())->get_d2phi();
70 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
71 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
72 libMesh::DenseSubMatrix<libMesh::Number> &Kup =
73 context.get_elem_jacobian(this->_flow_vars.u(), this->_press_var.p());
74 libMesh::DenseSubMatrix<libMesh::Number> &Kuu =
75 context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
76 libMesh::DenseSubMatrix<libMesh::Number> &Kuv =
77 context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.v());
78 libMesh::DenseSubMatrix<libMesh::Number> &Kvp =
79 context.get_elem_jacobian(this->_flow_vars.v(), this->_press_var.p());
80 libMesh::DenseSubMatrix<libMesh::Number> &Kvu =
81 context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.u());
82 libMesh::DenseSubMatrix<libMesh::Number> &Kvv =
83 context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
85 libMesh::DenseSubVector<libMesh::Number> *Fw = NULL;
86 libMesh::DenseSubMatrix<libMesh::Number> *Kuw = NULL;
87 libMesh::DenseSubMatrix<libMesh::Number> *Kvw = NULL;
88 libMesh::DenseSubMatrix<libMesh::Number> *Kwp = NULL;
89 libMesh::DenseSubMatrix<libMesh::Number> *Kwu = NULL;
90 libMesh::DenseSubMatrix<libMesh::Number> *Kwv = NULL;
91 libMesh::DenseSubMatrix<libMesh::Number> *Kww = NULL;
94 if(this->_flow_vars.dim() == 3)
96 Fw = &context.get_elem_residual(this->_flow_vars.w());
97 Kuw = &context.get_elem_jacobian
98 (this->_flow_vars.u(), this->_flow_vars.w());
99 Kvw = &context.get_elem_jacobian
100 (this->_flow_vars.v(), this->_flow_vars.w());
101 Kwp = &context.get_elem_jacobian
102 (this->_flow_vars.w(), this->_press_var.p());
103 Kwu = &context.get_elem_jacobian
104 (this->_flow_vars.w(), this->_flow_vars.u());
105 Kwv = &context.get_elem_jacobian
106 (this->_flow_vars.w(), this->_flow_vars.v());
107 Kww = &context.get_elem_jacobian
108 (this->_flow_vars.w(), this->_flow_vars.w());
111 unsigned int n_qpoints = context.get_element_qrule().n_points();
113 libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
115 for (
unsigned int qp=0; qp != n_qpoints; qp++)
117 libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
118 libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
120 libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ),
121 context.interior_value( this->_flow_vars.v(), qp ) );
122 if( this->_flow_vars.dim() == 3 )
124 U(2) = context.interior_value( this->_flow_vars.w(), qp );
135 libMesh::Real tau_M, tau_C;
136 libMesh::Real d_tau_M_d_rho, d_tau_C_d_rho;
137 libMesh::Gradient d_tau_M_dU, d_tau_C_dU;
138 libMesh::Gradient RM_s, d_RM_s_uvw_dgraduvw;
140 libMesh::Tensor d_RC_dgradU,
141 d_RM_s_dgradp, d_RM_s_dU, d_RM_s_uvw_dhessuvw;
144 libMesh::Real _mu_qp = this->_mu(context, qp);
146 if (compute_jacobian)
148 this->_stab_helper.compute_tau_momentum_and_derivs
149 ( context, qp, g, G, this->_rho, U, _mu_qp,
150 tau_M, d_tau_M_d_rho, d_tau_M_dU,
152 this->_stab_helper.compute_tau_continuity_and_derivs
153 ( tau_M, d_tau_M_d_rho, d_tau_M_dU,
155 tau_C, d_tau_C_d_rho, d_tau_C_dU );
156 this->_stab_helper.compute_res_momentum_steady_and_derivs
157 ( context, qp, this->_rho, _mu_qp,
158 RM_s, d_RM_s_dgradp, d_RM_s_dU, d_RM_s_uvw_dgraduvw,
159 d_RM_s_uvw_dhessuvw);
160 this->_stab_helper.compute_res_continuity_and_derivs
161 ( context, qp, RC, d_RC_dgradU );
165 tau_M = this->_stab_helper.compute_tau_momentum( context, qp, g, G, this->_rho, U, _mu_qp, this->_is_steady );
166 tau_C = this->_stab_helper.compute_tau_continuity( tau_M, g );
167 RM_s = this->_stab_helper.compute_res_momentum_steady( context, qp, this->_rho, _mu_qp );
168 RC = this->_stab_helper.compute_res_continuity( context, qp );
171 for (
unsigned int i=0; i != n_u_dofs; i++)
173 libMesh::Real test_func = this->_rho*U*u_gradphi[i][qp] +
174 _mu_qp*( u_hessphi[i][qp](0,0) + u_hessphi[i][qp](1,1) + u_hessphi[i][qp](2,2) );
175 libMesh::Gradient d_test_func_dU = this->_rho*u_gradphi[i][qp];
179 Fu(i) += ( -tau_M*RM_s(0)*test_func - tau_C*RC*u_gradphi[i][qp](0) )*JxW[qp];
181 Fv(i) += ( -tau_M*RM_s(1)*test_func - tau_C*RC*u_gradphi[i][qp](1) )*JxW[qp];
183 if(this->_flow_vars.dim() == 3)
185 (*Fw)(i) += ( -tau_M*RM_s(2)*test_func - tau_C*RC*u_gradphi[i][qp](2) )*JxW[qp];
188 if (compute_jacobian)
190 const libMesh::Real fixed_deriv =
191 context.get_fixed_solution_derivative();
192 for (
unsigned int j=0; j != n_p_dofs; j++)
194 Kup(i,j) += ( -tau_M*
195 ( d_RM_s_dgradp(0,0) *
196 p_gradphi[j][qp](0) +
198 p_gradphi[j][qp](1) +
201 )*test_func)*fixed_deriv*JxW[qp];
202 Kvp(i,j) += ( -tau_M*
203 ( d_RM_s_dgradp(1,0) *
204 p_gradphi[j][qp](0) +
206 p_gradphi[j][qp](1) +
209 )*test_func)*fixed_deriv*JxW[qp];
211 for (
unsigned int j=0; j != n_u_dofs; j++)
213 Kuu(i,j) += ( -d_tau_M_dU(0)*RM_s(0)*test_func
214 -tau_M*d_RM_s_dU(0,0)*test_func
215 - d_tau_C_dU(0)*RC*u_gradphi[i][qp](0)
216 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
217 Kuu(i,j) += ( -tau_M*RM_s(0)*d_test_func_dU(0)
218 )*u_phi[j][qp]*JxW[qp];
219 Kuu(i,j) += ( - tau_C*
221 d_RC_dgradU(0,0)*u_gradphi[j][qp](0) +
222 d_RC_dgradU(0,1)*u_gradphi[j][qp](1) +
223 d_RC_dgradU(0,2)*u_gradphi[j][qp](2)
225 *fixed_deriv*u_gradphi[i][qp](0)
227 Kuu(i,j) += ( -tau_M*test_func*(d_RM_s_uvw_dgraduvw*u_gradphi[j][qp])
228 )*fixed_deriv*JxW[qp];
229 Kuu(i,j) += ( -tau_M*test_func*(d_RM_s_uvw_dhessuvw.contract(u_hessphi[j][qp]))
230 )*fixed_deriv*JxW[qp];
231 Kuv(i,j) += ( -d_tau_M_dU(1)*RM_s(0)*test_func
232 -tau_M*d_RM_s_dU(0,1)*test_func
233 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
234 Kuv(i,j) += ( -tau_M*RM_s(0)*d_test_func_dU(1)
235 )*u_phi[j][qp]*JxW[qp];
236 Kuv(i,j) += ( - tau_C*
238 d_RC_dgradU(1,0)*u_gradphi[j][qp](0) +
239 d_RC_dgradU(1,1)*u_gradphi[j][qp](1) +
240 d_RC_dgradU(1,2)*u_gradphi[j][qp](2)
242 *fixed_deriv*u_gradphi[i][qp](0)
244 Kvu(i,j) += ( -d_tau_M_dU(0)*RM_s(1)*test_func
245 -tau_M*d_RM_s_dU(1,0)*test_func
246 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
247 Kvu(i,j) += ( -tau_M*RM_s(1)*d_test_func_dU(0)
248 )*u_phi[j][qp]*JxW[qp];
249 Kvu(i,j) += ( - tau_C*
251 d_RC_dgradU(0,0)*u_gradphi[j][qp](0) +
252 d_RC_dgradU(0,1)*u_gradphi[j][qp](1) +
253 d_RC_dgradU(0,2)*u_gradphi[j][qp](2)
255 *fixed_deriv*u_gradphi[i][qp](1)
257 Kvv(i,j) += ( -d_tau_M_dU(1)*RM_s(1)*test_func
258 -tau_M*d_RM_s_dU(1,1)*test_func
259 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
260 Kvv(i,j) += ( -tau_M*RM_s(1)*d_test_func_dU(1)
261 )*u_phi[j][qp]*JxW[qp];
262 Kvv(i,j) += ( - tau_C*
264 d_RC_dgradU(1,0)*u_gradphi[j][qp](0) +
265 d_RC_dgradU(1,1)*u_gradphi[j][qp](1) +
266 d_RC_dgradU(1,2)*u_gradphi[j][qp](2)
268 *fixed_deriv*u_gradphi[i][qp](1)
270 Kvv(i,j) += ( -tau_M*test_func*(d_RM_s_uvw_dgraduvw*u_gradphi[j][qp])
271 )*fixed_deriv*JxW[qp];
272 Kvv(i,j) += ( -tau_M*test_func*(d_RM_s_uvw_dhessuvw.contract(u_hessphi[j][qp]))
273 )*fixed_deriv*JxW[qp];
275 if(this->_flow_vars.dim() == 3)
277 for (
unsigned int j=0; j != n_p_dofs; j++)
279 (*Kwp)(i,j) += ( -tau_M*
280 ( d_RM_s_dgradp(2,0) *
281 p_gradphi[j][qp](0) +
283 p_gradphi[j][qp](1) +
286 )*test_func)*fixed_deriv*JxW[qp];
288 for (
unsigned int j=0; j != n_u_dofs; j++)
290 (*Kuw)(i,j) += ( -d_tau_M_dU(2)*RM_s(0)*test_func
291 -tau_M*d_RM_s_dU(0,2)*test_func
292 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
293 (*Kuw)(i,j) += ( -tau_M*RM_s(0)*d_test_func_dU(2)
294 )*u_phi[j][qp]*JxW[qp];
295 (*Kuw)(i,j) += ( - tau_C*
297 d_RC_dgradU(2,0)*u_gradphi[j][qp](0) +
298 d_RC_dgradU(2,1)*u_gradphi[j][qp](1) +
299 d_RC_dgradU(2,2)*u_gradphi[j][qp](2)
301 *fixed_deriv* u_gradphi[i][qp](0)
303 (*Kvw)(i,j) += ( -d_tau_M_dU(2)*RM_s(1)*test_func
304 -tau_M*d_RM_s_dU(1,2)*test_func
305 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
306 (*Kvw)(i,j) += ( -tau_M*RM_s(1)*d_test_func_dU(2)
307 )*u_phi[j][qp]*JxW[qp];
308 (*Kvw)(i,j) += ( - tau_C*
310 d_RC_dgradU(2,0)*u_gradphi[j][qp](0) +
311 d_RC_dgradU(2,1)*u_gradphi[j][qp](1) +
312 d_RC_dgradU(2,2)*u_gradphi[j][qp](2)
314 *fixed_deriv* u_gradphi[i][qp](1)
316 (*Kwu)(i,j) += ( -d_tau_M_dU(0)*RM_s(2)*test_func
317 -tau_M*d_RM_s_dU(2,0)*test_func
318 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
319 (*Kwu)(i,j) += ( -tau_M*RM_s(2)*d_test_func_dU(0)
320 )*u_phi[j][qp]*JxW[qp];
321 (*Kwu)(i,j) += ( - tau_C*
323 d_RC_dgradU(0,0)*u_gradphi[j][qp](0) +
324 d_RC_dgradU(0,1)*u_gradphi[j][qp](1) +
325 d_RC_dgradU(0,2)*u_gradphi[j][qp](2)
327 *fixed_deriv* u_gradphi[i][qp](2)
329 (*Kwv)(i,j) += ( -d_tau_M_dU(1)*RM_s(2)*test_func
330 -tau_M*d_RM_s_dU(2,1)*test_func
331 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
332 (*Kwv)(i,j) += ( -tau_M*RM_s(2)*d_test_func_dU(1)
333 )*u_phi[j][qp]*JxW[qp];
334 (*Kwv)(i,j) += ( - tau_C*
336 d_RC_dgradU(1,0)*u_gradphi[j][qp](0) +
337 d_RC_dgradU(1,1)*u_gradphi[j][qp](1) +
338 d_RC_dgradU(1,2)*u_gradphi[j][qp](2)
340 *fixed_deriv* u_gradphi[i][qp](2)
342 (*Kww)(i,j) += ( -d_tau_M_dU(2)*RM_s(2)*test_func
343 -tau_M*d_RM_s_dU(2,2)*test_func
344 )*fixed_deriv*u_phi[j][qp]*JxW[qp];
345 (*Kww)(i,j) += ( -tau_M*RM_s(2)*d_test_func_dU(2)
346 )*u_phi[j][qp]*JxW[qp];
347 (*Kww)(i,j) += ( - tau_C*
349 d_RC_dgradU(2,0)*u_gradphi[j][qp](0) +
350 d_RC_dgradU(2,1)*u_gradphi[j][qp](1) +
351 d_RC_dgradU(2,2)*u_gradphi[j][qp](2)
353 *fixed_deriv* u_gradphi[i][qp](2)
355 (*Kww)(i,j) += ( -tau_M*test_func*(d_RM_s_uvw_dgraduvw*u_gradphi[j][qp])
356 )*fixed_deriv*JxW[qp];
357 (*Kww)(i,j) += ( -tau_M*test_func*(d_RM_s_uvw_dhessuvw.contract(u_hessphi[j][qp]))
358 )*fixed_deriv*JxW[qp];
372 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
373 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
376 const std::vector<libMesh::Real> &JxW =
377 context.get_element_fe(this->_flow_vars.u())->get_JxW();
380 const std::vector<std::vector<libMesh::RealGradient> >& p_dphi =
381 context.get_element_fe(this->_press_var.p())->get_dphi();
384 const std::vector<std::vector<libMesh::Real> >& u_phi =
385 context.get_element_fe(this->_flow_vars.u())->get_phi();
387 const std::vector<std::vector<libMesh::RealGradient> >& u_dphi =
388 context.get_element_fe(this->_flow_vars.u())->get_dphi();
390 const std::vector<std::vector<libMesh::RealTensor> >& u_d2phi =
391 context.get_element_fe(this->_flow_vars.u())->get_d2phi();
393 libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p());
395 libMesh::DenseSubMatrix<libMesh::Number> &Kpp =
396 context.get_elem_jacobian(this->_press_var.p(), this->_press_var.p());
397 libMesh::DenseSubMatrix<libMesh::Number> &Kpu =
398 context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.u());
399 libMesh::DenseSubMatrix<libMesh::Number> &Kpv =
400 context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.v());
401 libMesh::DenseSubMatrix<libMesh::Number> *Kpw = NULL;
404 if(this->_flow_vars.dim() == 3)
406 Kpw = &context.get_elem_jacobian
407 (this->_press_var.p(), this->_flow_vars.w());
410 unsigned int n_qpoints = context.get_element_qrule().n_points();
412 libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
414 for (
unsigned int qp=0; qp != n_qpoints; qp++)
416 libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
417 libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
419 libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ),
420 context.interior_value( this->_flow_vars.v(), qp ) );
421 if( this->_flow_vars.dim() == 3 )
423 U(2) = context.interior_value( this->_flow_vars.w(), qp );
427 libMesh::Real d_tau_M_d_rho;
428 libMesh::Gradient d_tau_M_dU;
429 libMesh::Gradient RM_s, d_RM_s_uvw_dgraduvw;
430 libMesh::Tensor d_RM_s_dgradp, d_RM_s_dU, d_RM_s_uvw_dhessuvw;
433 libMesh::Real _mu_qp = this->_mu(context, qp);
435 if (compute_jacobian)
437 this->_stab_helper.compute_tau_momentum_and_derivs
438 ( context, qp, g, G, this->_rho, U, _mu_qp,
439 tau_M, d_tau_M_d_rho, d_tau_M_dU,
441 this->_stab_helper.compute_res_momentum_steady_and_derivs
442 ( context, qp, this->_rho, _mu_qp,
443 RM_s, d_RM_s_dgradp, d_RM_s_dU, d_RM_s_uvw_dgraduvw,
444 d_RM_s_uvw_dhessuvw);
448 tau_M = this->_stab_helper.compute_tau_momentum( context, qp, g, G, this->_rho, U, _mu_qp, this->_is_steady );
449 RM_s = this->_stab_helper.compute_res_momentum_steady( context, qp, this->_rho, _mu_qp );
454 for (
unsigned int i=0; i != n_p_dofs; i++)
456 Fp(i) += tau_M*(RM_s*p_dphi[i][qp])*JxW[qp];
458 if (compute_jacobian)
460 const libMesh::Real fixed_deriv =
461 context.get_fixed_solution_derivative();
463 const libMesh::TypeVector<libMesh::Number>
464 p_dphiiT_d_RM_s_dgradp =
465 d_RM_s_dgradp.transpose() * p_dphi[i][qp];
467 for (
unsigned int j=0; j != n_p_dofs; j++)
469 Kpp(i,j) += tau_M*(p_dphiiT_d_RM_s_dgradp*p_dphi[j][qp])*JxW[qp];
472 for (
unsigned int j=0; j != n_u_dofs; j++)
475 d_tau_M_dU(0)*u_phi[j][qp]*(RM_s*p_dphi[i][qp])
478 d_RM_s_dU(0,0)*u_phi[j][qp]*p_dphi[i][qp](0) +
479 d_RM_s_dU(1,0)*u_phi[j][qp]*p_dphi[i][qp](1) +
480 d_RM_s_dU(2,0)*u_phi[j][qp]*p_dphi[i][qp](2) +
481 d_RM_s_uvw_dgraduvw*u_dphi[j][qp]*p_dphi[i][qp](0) +
482 d_RM_s_uvw_dhessuvw.contract(u_d2phi[j][qp])*p_dphi[i][qp](0)
486 d_tau_M_dU(1)*u_phi[j][qp]*(RM_s*p_dphi[i][qp])
489 d_RM_s_dU(0,1)*u_phi[j][qp]*p_dphi[i][qp](0) +
490 d_RM_s_dU(1,1)*u_phi[j][qp]*p_dphi[i][qp](1) +
491 d_RM_s_dU(2,1)*u_phi[j][qp]*p_dphi[i][qp](2) +
492 d_RM_s_uvw_dgraduvw*u_dphi[j][qp]*p_dphi[i][qp](1) +
493 d_RM_s_uvw_dhessuvw.contract(u_d2phi[j][qp])*p_dphi[i][qp](0)
498 if(this->_flow_vars.dim() == 3)
500 for (
unsigned int j=0; j != n_u_dofs; j++)
503 d_tau_M_dU(2)*u_phi[j][qp]*(RM_s*p_dphi[i][qp])
506 d_RM_s_dU(0,2)*u_phi[j][qp]*p_dphi[i][qp](0) +
507 d_RM_s_dU(1,2)*u_phi[j][qp]*p_dphi[i][qp](1) +
508 d_RM_s_dU(2,2)*u_phi[j][qp]*p_dphi[i][qp](2) +
509 d_RM_s_uvw_dgraduvw*u_dphi[j][qp]*p_dphi[i][qp](2) +
510 d_RM_s_uvw_dhessuvw.contract(u_d2phi[j][qp])*p_dphi[i][qp](0)
525 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
526 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
529 const std::vector<libMesh::Real> &JxW =
530 context.get_element_fe(this->_flow_vars.u())->get_JxW();
533 const std::vector<std::vector<libMesh::RealGradient> >& p_dphi =
534 context.get_element_fe(this->_press_var.p())->get_dphi();
536 const std::vector<std::vector<libMesh::Real> >& u_phi =
537 context.get_element_fe(this->_flow_vars.u())->get_phi();
539 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
540 context.get_element_fe(this->_flow_vars.u())->get_dphi();
542 const std::vector<std::vector<libMesh::RealTensor> >& u_hessphi =
543 context.get_element_fe(this->_flow_vars.u())->get_d2phi();
545 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
546 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
547 libMesh::DenseSubVector<libMesh::Number> *Fw = NULL;
549 libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p());
551 libMesh::DenseSubMatrix<libMesh::Number> &Kuu =
552 context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
553 libMesh::DenseSubMatrix<libMesh::Number> &Kuv =
554 context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.v());
555 libMesh::DenseSubMatrix<libMesh::Number> &Kvu =
556 context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.u());
557 libMesh::DenseSubMatrix<libMesh::Number> &Kvv =
558 context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
560 libMesh::DenseSubMatrix<libMesh::Number> *Kuw = NULL;
561 libMesh::DenseSubMatrix<libMesh::Number> *Kvw = NULL;
562 libMesh::DenseSubMatrix<libMesh::Number> *Kwu = NULL;
563 libMesh::DenseSubMatrix<libMesh::Number> *Kwv = NULL;
564 libMesh::DenseSubMatrix<libMesh::Number> *Kww = NULL;
566 libMesh::DenseSubMatrix<libMesh::Number> &Kpu =
567 context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.u());
568 libMesh::DenseSubMatrix<libMesh::Number> &Kpv =
569 context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.v());
570 libMesh::DenseSubMatrix<libMesh::Number> *Kpw = NULL;
573 if(this->_flow_vars.dim() == 3)
575 Fw = &context.get_elem_residual(this->_flow_vars.w());
577 Kuw = &context.get_elem_jacobian
578 (this->_flow_vars.u(), this->_flow_vars.w());
579 Kvw = &context.get_elem_jacobian
580 (this->_flow_vars.v(), this->_flow_vars.w());
581 Kwu = &context.get_elem_jacobian
582 (this->_flow_vars.w(), this->_flow_vars.u());
583 Kwv = &context.get_elem_jacobian
584 (this->_flow_vars.w(), this->_flow_vars.v());
585 Kww = &context.get_elem_jacobian
586 (this->_flow_vars.w(), this->_flow_vars.w());
588 Kpw = &context.get_elem_jacobian
589 (this->_press_var.p(), this->_flow_vars.w());
592 unsigned int n_qpoints = context.get_element_qrule().n_points();
594 for (
unsigned int qp=0; qp != n_qpoints; qp++)
596 libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
598 libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
599 libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
601 libMesh::RealGradient U( context.fixed_interior_value( this->_flow_vars.u(), qp ),
602 context.fixed_interior_value( this->_flow_vars.v(), qp ) );
603 if( this->_flow_vars.dim() == 3 )
605 U(2) = context.fixed_interior_value( this->_flow_vars.w(), qp );
618 libMesh::Real d_tau_M_d_rho;
620 libMesh::Gradient d_tau_M_dU;
622 libMesh::RealGradient RM_t;
624 libMesh::Real d_RM_t_uvw_duvw;
627 libMesh::Real _mu_qp = this->_mu(context, qp);
629 if (compute_jacobian)
631 this->_stab_helper.compute_tau_momentum_and_derivs
632 ( context, qp, g, G, this->_rho, U, _mu_qp,
633 tau_M, d_tau_M_d_rho, d_tau_M_dU,
635 this->_stab_helper.compute_res_momentum_transient_and_derivs
636 ( context, qp, this->_rho,
637 RM_t, d_RM_t_uvw_duvw );
641 tau_M = this->_stab_helper.compute_tau_momentum( context, qp, g, G, this->_rho, U, _mu_qp,
false );
642 RM_t = this->_stab_helper.compute_res_momentum_transient( context, qp, this->_rho );
648 for (
unsigned int i=0; i != n_p_dofs; i++)
650 Fp(i) -= tau_M*RM_t*p_dphi[i][qp]*JxW[qp];
652 if (compute_jacobian)
654 const libMesh::Real fixed_deriv =
655 context.get_fixed_solution_derivative();
657 for (
unsigned int j=0; j != n_u_dofs; j++)
659 Kpu(i,j) -= d_tau_M_dU(0)*u_phi[j][qp]*RM_t*p_dphi[i][qp]*fixed_deriv*JxW[qp];
660 Kpu(i,j) -= tau_M*d_RM_t_uvw_duvw*u_phi[j][qp]*p_dphi[i][qp](0)*fixed_deriv*JxW[qp];
662 Kpv(i,j) -= d_tau_M_dU(1)*u_phi[j][qp]*RM_t*p_dphi[i][qp]*fixed_deriv*JxW[qp];
663 Kpv(i,j) -= tau_M*d_RM_t_uvw_duvw*u_phi[j][qp]*p_dphi[i][qp](1)*fixed_deriv*JxW[qp];
666 if(this->_flow_vars.dim() == 3)
668 for (
unsigned int j=0; j != n_u_dofs; j++)
670 (*Kpw)(i,j) -= d_tau_M_dU(2)*u_phi[j][qp]*RM_t*p_dphi[i][qp]*fixed_deriv*JxW[qp];
671 (*Kpw)(i,j) -= tau_M*d_RM_t_uvw_duvw*u_phi[j][qp]*p_dphi[i][qp](2)*fixed_deriv*JxW[qp];
677 for (
unsigned int i=0; i != n_u_dofs; i++)
679 libMesh::Real test_func = this->_rho*U*u_gradphi[i][qp] +
680 _mu_qp*( u_hessphi[i][qp](0,0) + u_hessphi[i][qp](1,1) + u_hessphi[i][qp](2,2) );
681 libMesh::Gradient d_test_func_dU = this->_rho*u_gradphi[i][qp];
685 Fu(i) -= tau_M*RM_t(0)*test_func*JxW[qp];
687 Fv(i) -= tau_M*RM_t(1)*test_func*JxW[qp];
689 if(this->_flow_vars.dim() == 3)
691 (*Fw)(i) -= tau_M*RM_t(2)*test_func*JxW[qp];
694 if (compute_jacobian)
696 const libMesh::Real fixed_deriv =
697 context.get_fixed_solution_derivative();
699 for (
unsigned int j=0; j != n_u_dofs; j++)
701 Kuu(i,j) -= d_tau_M_dU(0)*u_phi[j][qp]*RM_t(0)*test_func*fixed_deriv*JxW[qp];
702 Kuu(i,j) -= tau_M*d_RM_t_uvw_duvw*u_phi[j][qp]*test_func*fixed_deriv*JxW[qp];
703 Kuu(i,j) -= tau_M*RM_t(0)*d_test_func_dU(0)*u_phi[j][qp]*fixed_deriv*JxW[qp];
705 Kuv(i,j) -= d_tau_M_dU(1)*u_phi[j][qp]*RM_t(0)*test_func*fixed_deriv*JxW[qp];
706 Kuv(i,j) -= tau_M*RM_t(0)*d_test_func_dU(1)*u_phi[j][qp]*fixed_deriv*JxW[qp];
708 Kvu(i,j) -= d_tau_M_dU(0)*u_phi[j][qp]*RM_t(1)*test_func*fixed_deriv*JxW[qp];
709 Kvu(i,j) -= tau_M*RM_t(1)*d_test_func_dU(0)*u_phi[j][qp]*fixed_deriv*JxW[qp];
711 Kvv(i,j) -= d_tau_M_dU(1)*u_phi[j][qp]*RM_t(1)*test_func*fixed_deriv*JxW[qp];
712 Kvv(i,j) -= tau_M*d_RM_t_uvw_duvw*u_phi[j][qp]*test_func*fixed_deriv*JxW[qp];
713 Kvv(i,j) -= tau_M*RM_t(1)*d_test_func_dU(1)*u_phi[j][qp]*fixed_deriv*JxW[qp];
715 if(this->_flow_vars.dim() == 3)
717 for (
unsigned int j=0; j != n_u_dofs; j++)
719 (*Kuw)(i,j) -= d_tau_M_dU(2)*u_phi[j][qp]*RM_t(0)*test_func*fixed_deriv*JxW[qp];
720 (*Kuw)(i,j) -= tau_M*RM_t(0)*d_test_func_dU(2)*u_phi[j][qp]*fixed_deriv*JxW[qp];
722 (*Kvw)(i,j) -= d_tau_M_dU(2)*u_phi[j][qp]*RM_t(1)*test_func*fixed_deriv*JxW[qp];
723 (*Kvw)(i,j) -= tau_M*RM_t(1)*d_test_func_dU(2)*u_phi[j][qp]*fixed_deriv*JxW[qp];
725 (*Kwu)(i,j) -= d_tau_M_dU(0)*u_phi[j][qp]*RM_t(2)*test_func*fixed_deriv*JxW[qp];
726 (*Kwu)(i,j) -= tau_M*RM_t(2)*d_test_func_dU(0)*u_phi[j][qp]*fixed_deriv*JxW[qp];
728 (*Kwv)(i,j) -= d_tau_M_dU(1)*u_phi[j][qp]*RM_t(2)*test_func*fixed_deriv*JxW[qp];
729 (*Kwv)(i,j) -= tau_M*RM_t(2)*d_test_func_dU(1)*u_phi[j][qp]*fixed_deriv*JxW[qp];
731 (*Kww)(i,j) -= d_tau_M_dU(2)*u_phi[j][qp]*RM_t(2)*test_func*fixed_deriv*JxW[qp];
732 (*Kww)(i,j) -= tau_M*d_RM_t_uvw_duvw*u_phi[j][qp]*test_func*fixed_deriv*JxW[qp];
733 (*Kww)(i,j) -= tau_M*RM_t(2)*d_test_func_dU(2)*u_phi[j][qp]*fixed_deriv*JxW[qp];
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for element interiors.
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_constraint(bool compute_jacobian, AssemblyContext &context)
Constraint part(s) of physics for element interiors.
INSTANTIATE_INC_NS_SUBCLASS(IncompressibleNavierStokesAdjointStabilization)
IncompressibleNavierStokesAdjointStabilization()