30 #include "grins_config.h"
39 #include "libmesh/quadrature.h"
44 template<
class Mu,
class SH,
class TC>
47 _p_pinning(input,physics_name),
55 libmesh_error_msg(
"ERROR: LowMachNavierStokes only valid for two or three dimensions! Make sure you have at least two components in your Velocity type variable.");
58 template<
class Mu,
class SH,
class TC>
62 _p_pinning.check_pin_location(system.get_mesh());
65 template<
class Mu,
class SH,
class TC>
71 if( input.have_variable(section) )
73 unsigned int n_vars = input.vector_variable_size(section);
75 for(
unsigned int v = 0; v < n_vars; v++ )
77 std::string name = input(section,
"DIE!",v);
79 if( name == std::string(
"rho") )
86 <<
" Found " << name << std::endl
87 <<
" Acceptable values are: rho" << std::endl;
94 template<
class Mu,
class SH,
class TC>
101 context.get_side_fe(this->_flow_vars.u())->get_JxW();
102 context.get_side_fe(this->_flow_vars.u())->get_phi();
103 context.get_side_fe(this->_flow_vars.u())->get_dphi();
104 context.get_side_fe(this->_flow_vars.u())->get_xyz();
106 context.get_side_fe(this->_temp_vars.T())->get_JxW();
107 context.get_side_fe(this->_temp_vars.T())->get_phi();
108 context.get_side_fe(this->_temp_vars.T())->get_dphi();
109 context.get_side_fe(this->_temp_vars.T())->get_xyz();
113 template<
class Mu,
class SH,
class TC>
119 this->assemble_mass_time_deriv( compute_jacobian, context, cache );
120 this->assemble_momentum_time_deriv( compute_jacobian, context, cache );
121 this->assemble_energy_time_deriv( compute_jacobian, context, cache );
123 if( this->_enable_thermo_press_calc )
124 this->assemble_thermo_press_elem_time_deriv( compute_jacobian, context );
127 template<
class Mu,
class SH,
class TC>
129 (
bool compute_jacobian,
133 if( this->_pin_pressure )
134 this->_p_pinning.pin_value( context, compute_jacobian, this->_press_var.p());
137 template<
class Mu,
class SH,
class TC>
141 this->assemble_continuity_mass_residual( compute_jacobian, context );
143 this->assemble_momentum_mass_residual( compute_jacobian, context );
145 this->assemble_energy_mass_residual( compute_jacobian, context );
147 if( this->_enable_thermo_press_calc )
148 this->assemble_thermo_press_mass_residual( compute_jacobian, context );
151 template<
class Mu,
class SH,
class TC>
157 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
160 const std::vector<libMesh::Real> &JxW =
161 context.get_element_fe(this->_flow_vars.u())->get_JxW();
164 const std::vector<std::vector<libMesh::Real> >& p_phi =
165 context.get_element_fe(this->_press_var.p())->get_phi();
170 const std::vector<std::vector<libMesh::Real> >& u_phi =
171 context.get_element_fe(this->_flow_vars.u())->get_phi();
175 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
176 context.get_element_fe(this->_flow_vars.u())->get_dphi();
179 const std::vector<std::vector<libMesh::Real> >& T_phi =
180 context.get_element_fe(this->_temp_vars.T())->get_phi();
184 const std::vector<std::vector<libMesh::RealGradient> >& T_gradphi =
185 context.get_element_fe(this->_temp_vars.T())->get_dphi();
189 libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p());
191 unsigned int n_qpoints = context.get_element_qrule().n_points();
194 const unsigned int n_t_dofs = context.get_dof_indices(this->_temp_vars.T()).size();
197 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
200 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.v()).size());
202 if (this->_flow_vars.dim() == 3)
203 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.w()).size());
205 for (
unsigned int qp=0; qp != n_qpoints; qp++)
207 libMesh::Number u, v, T;
218 libMesh::NumberVectorValue U(u,v);
219 if (this->_flow_vars.dim() == 3)
222 libMesh::Number divU = grad_u(0) + grad_v(1);
223 if (this->_flow_vars.dim() == 3)
230 libMesh::DenseSubMatrix<libMesh::Number> &KPu = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.u());
231 libMesh::DenseSubMatrix<libMesh::Number> &KPv = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.v());
232 libMesh::DenseSubMatrix<libMesh::Number> &KPT = context.get_elem_jacobian(this->_press_var.p(), this->_temp_vars.T());
234 libMesh::DenseSubMatrix<libMesh::Number>* KPw = NULL;
236 if( this->_flow_vars.dim() == 3 )
238 KPw = &context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.w());
243 for (
unsigned int i=0; i != n_p_dofs; i++)
245 Fp(i) += (-U*grad_T/T + divU)*p_phi[i][qp]*JxW[qp];
248 if (compute_jacobian)
251 for (
unsigned int j=0; j!=n_u_dofs; j++)
253 KPu(i,j) += JxW[qp]*(
254 +u_gradphi[j][qp](0)*p_phi[i][qp]
255 -u_phi[j][qp]*p_phi[i][qp]*grad_T(0)/T
258 KPv(i,j) += JxW[qp]*(
259 +u_gradphi[j][qp](1)*p_phi[i][qp]
260 -u_phi[j][qp]*p_phi[i][qp]*grad_T(1)/T
263 if (this->_flow_vars.dim() == 3)
265 (*KPw)(i,j) += JxW[qp]*(
266 +u_gradphi[j][qp](2)*p_phi[i][qp]
267 -u_phi[j][qp]*p_phi[i][qp]*grad_T(2)/T
273 for (
unsigned int j=0; j!=n_t_dofs; j++)
275 KPT(i,j) += JxW[qp]*(
276 -T_gradphi[j][qp]*U*p_phi[i][qp]/T
277 +U*p_phi[i][qp]*grad_T*T_phi[j][qp])/(T*T);
286 template<
class Mu,
class SH,
class TC>
292 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
293 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
294 const unsigned int n_T_dofs = context.get_dof_indices(this->_temp_vars.T()).size();
297 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.v()).size());
299 if (this->_flow_vars.dim() == 3)
300 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.w()).size());
303 const std::vector<libMesh::Real> &JxW =
304 context.get_element_fe(this->_flow_vars.u())->get_JxW();
307 const std::vector<std::vector<libMesh::Real> >& u_phi =
308 context.get_element_fe(this->_flow_vars.u())->get_phi();
309 const std::vector<std::vector<libMesh::Real> >& p_phi =
310 context.get_element_fe(this->_press_var.p())->get_phi();
311 const std::vector<std::vector<libMesh::Real> >& T_phi =
312 context.get_element_fe(this->_temp_vars.T())->get_phi();
315 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
316 context.get_element_fe(this->_flow_vars.u())->get_dphi();
318 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
319 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
320 libMesh::DenseSubVector<libMesh::Real>* Fw = NULL;
322 if( this->_flow_vars.dim() == 3 )
324 Fw = &context.get_elem_residual(this->_flow_vars.w());
327 unsigned int n_qpoints = context.get_element_qrule().n_points();
328 for (
unsigned int qp=0; qp != n_qpoints; qp++)
330 libMesh::Number u, v, p, p0, T;
341 libMesh::Gradient grad_w;
342 if (this->_flow_vars.dim() == 3)
345 libMesh::NumberVectorValue grad_uT( grad_u(0), grad_v(0) );
346 libMesh::NumberVectorValue grad_vT( grad_u(1), grad_v(1) );
347 libMesh::NumberVectorValue grad_wT;
348 if( this->_flow_vars.dim() == 3 )
350 grad_uT(2) = grad_w(0);
351 grad_vT(2) = grad_w(1);
352 grad_wT = libMesh::NumberVectorValue( grad_u(2), grad_v(2), grad_w(2) );
355 libMesh::NumberVectorValue U(u,v);
356 if (this->_flow_vars.dim() == 3)
359 libMesh::Number divU = grad_u(0) + grad_v(1);
360 if (this->_flow_vars.dim() == 3)
363 libMesh::Number rho = this->rho( T, p0 );
364 libMesh::Number d_rho = this->d_rho_dT( T, p0 );
365 libMesh::Number d_mu = this->_mu.deriv(T);
367 libMesh::DenseSubMatrix<libMesh::Number> &Kuu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
368 libMesh::DenseSubMatrix<libMesh::Number> &Kuv = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.v());
369 libMesh::DenseSubMatrix<libMesh::Number>* Kuw = NULL;
371 libMesh::DenseSubMatrix<libMesh::Number> &Kvu = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.u());
372 libMesh::DenseSubMatrix<libMesh::Number> &Kvv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
373 libMesh::DenseSubMatrix<libMesh::Number>* Kvw = NULL;
375 libMesh::DenseSubMatrix<libMesh::Number>* Kwu = NULL;
376 libMesh::DenseSubMatrix<libMesh::Number>* Kwv = NULL;
377 libMesh::DenseSubMatrix<libMesh::Number>* Kww = NULL;
379 libMesh::DenseSubMatrix<libMesh::Number> &Kup = context.get_elem_jacobian(this->_flow_vars.u(), this->_press_var.p());
380 libMesh::DenseSubMatrix<libMesh::Number> &Kvp = context.get_elem_jacobian(this->_flow_vars.v(), this->_press_var.p());
381 libMesh::DenseSubMatrix<libMesh::Number>* Kwp = NULL;
383 libMesh::DenseSubMatrix<libMesh::Number> &KuT = context.get_elem_jacobian(this->_flow_vars.u(), this->_temp_vars.T());
384 libMesh::DenseSubMatrix<libMesh::Number> &KvT = context.get_elem_jacobian(this->_flow_vars.v(), this->_temp_vars.T());
385 libMesh::DenseSubMatrix<libMesh::Number>* KwT = NULL;
387 if( this->_flow_vars.dim() == 3 )
389 Kuw = &context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.w());
390 Kvw = &context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.w());
391 Kwu = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.u());
392 Kwv = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.v());
393 Kww = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.w());
394 Kwp = &context.get_elem_jacobian(this->_flow_vars.w(), this->_press_var.p());
395 KwT = &context.get_elem_jacobian(this->_flow_vars.w(), this->_temp_vars.T());
400 for (
unsigned int i=0; i != n_u_dofs; i++)
402 Fu(i) += ( -rho*U*grad_u*u_phi[i][qp]
403 + p*u_gradphi[i][qp](0)
404 - this->_mu(T)*(u_gradphi[i][qp]*grad_u + u_gradphi[i][qp]*grad_uT
405 - 2.0/3.0*divU*u_gradphi[i][qp](0) )
406 + rho*this->_g(0)*u_phi[i][qp]
409 Fv(i) += ( -rho*U*grad_v*u_phi[i][qp]
410 + p*u_gradphi[i][qp](1)
411 - this->_mu(T)*(u_gradphi[i][qp]*grad_v + u_gradphi[i][qp]*grad_vT
412 - 2.0/3.0*divU*u_gradphi[i][qp](1) )
413 + rho*this->_g(1)*u_phi[i][qp]
415 if (this->_flow_vars.dim() == 3)
417 (*Fw)(i) += ( -rho*U*grad_w*u_phi[i][qp]
418 + p*u_gradphi[i][qp](2)
419 - this->_mu(T)*(u_gradphi[i][qp]*grad_w + u_gradphi[i][qp]*grad_wT
420 - 2.0/3.0*divU*u_gradphi[i][qp](2) )
421 + rho*this->_g(2)*u_phi[i][qp]
425 if (compute_jacobian && context.get_elem_solution_derivative())
427 libmesh_assert (context.get_elem_solution_derivative() == 1.0);
429 for (
unsigned int j=0; j != n_u_dofs; j++)
432 libMesh::Number r0 = rho*U*u_phi[i][qp]*u_gradphi[j][qp];
433 libMesh::Number r1 = u_gradphi[i][qp]*u_gradphi[j][qp];
434 libMesh::Number r2 = rho*u_phi[i][qp]*u_phi[j][qp];
437 Kuu(i,j) += JxW[qp]*(
445 + u_gradphi[i][qp](0)*u_gradphi[j][qp](0)
446 - 2.0/3.0*u_gradphi[i][qp](0)*u_gradphi[j][qp](0)
448 Kvv(i,j) += JxW[qp]*(
456 + u_gradphi[i][qp](1)*u_gradphi[j][qp](1)
457 - 2.0/3.0*u_gradphi[i][qp](1)*u_gradphi[j][qp](1)
460 Kuv(i,j) += JxW[qp]*(
461 +2.0/3.0*this->_mu(T)*u_gradphi[i][qp](0)*u_gradphi[j][qp](1)
462 -this->_mu(T)*u_gradphi[i][qp](1)*u_gradphi[j][qp](0)
467 Kvu(i,j) += JxW[qp]*(
468 +2.0/3.0*this->_mu(T)*u_gradphi[i][qp](1)*u_gradphi[j][qp](0)
469 -this->_mu(T)*u_gradphi[i][qp](0)*u_gradphi[j][qp](1)
476 if (this->_flow_vars.dim() == 3)
478 (*Kuw)(i,j) += JxW[qp]*(
479 +2.0/3.0*this->_mu(T)*u_gradphi[i][qp](0)*u_gradphi[j][qp](2)
480 -this->_mu(T)*u_gradphi[i][qp](2)*u_gradphi[j][qp](0)
485 (*Kvw)(i,j) += JxW[qp]*(
486 +2.0/3.0*this->_mu(T)*u_gradphi[i][qp](1)*u_gradphi[j][qp](2)
487 -this->_mu(T)*u_gradphi[i][qp](2)*u_gradphi[j][qp](1)
492 (*Kwu)(i,j) += JxW[qp]*(
493 +2.0/3.0*this->_mu(T)*u_gradphi[i][qp](2)*u_gradphi[j][qp](0)
494 -this->_mu(T)*u_gradphi[i][qp](0)*u_gradphi[j][qp](2)
499 (*Kwv)(i,j) += JxW[qp]*(
500 +2.0/3.0*this->_mu(T)*u_gradphi[i][qp](2)*u_gradphi[j][qp](1)
501 -this->_mu(T)*u_gradphi[i][qp](1)*u_gradphi[j][qp](2)
506 (*Kww)(i,j) += JxW[qp]*(
514 + u_gradphi[i][qp](2)*u_gradphi[j][qp](2)
515 - 2.0/3.0*u_gradphi[i][qp](2)*u_gradphi[j][qp](2)
521 for (
unsigned int j=0; j!=n_T_dofs; j++)
525 libMesh:: Number r3 = d_rho*u_phi[i][qp]*T_phi[j][qp];
528 KuT(i,j) += JxW[qp]*(
531 -d_mu*T_phi[j][qp]*grad_u*u_gradphi[i][qp]
532 -d_mu*T_phi[j][qp]*grad_u(0)*u_gradphi[i][qp](0)
533 +2.0/3.0*d_mu*T_phi[j][qp]*divU*u_gradphi[i][qp](0)
538 KvT(i,j) += JxW[qp]*(
541 -d_mu*T_phi[j][qp]*grad_v*u_gradphi[i][qp]
542 -d_mu*T_phi[j][qp]*grad_v(1)*u_gradphi[i][qp](1)
543 +2.0/3.0*d_mu*T_phi[j][qp]*divU*u_gradphi[i][qp](1)
548 if (this->_flow_vars.dim() == 3)
550 (*KwT)(i,j) += JxW[qp]*(
553 -d_mu*T_phi[j][qp]*grad_w*u_gradphi[i][qp]
554 -d_mu*T_phi[j][qp]*grad_w(2)*u_gradphi[i][qp](2)
555 +2.0/3.0*d_mu*T_phi[j][qp]*divU*u_gradphi[i][qp](2)
564 for (
unsigned int j=0; j != n_p_dofs; j++)
566 Kup(i,j) += JxW[qp]*p_phi[j][qp]*u_gradphi[i][qp](0);
567 Kvp(i,j) += JxW[qp]*p_phi[j][qp]*u_gradphi[i][qp](1);
568 if (this->_flow_vars.dim() == 3)
569 (*Kwp)(i,j) += JxW[qp]*p_phi[j][qp]*u_gradphi[i][qp](2);
580 template<
class Mu,
class SH,
class TC>
586 const unsigned int n_T_dofs = context.get_dof_indices(this->_temp_vars.T()).size();
587 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
590 const std::vector<libMesh::Real> &JxW =
591 context.get_element_fe(this->_temp_vars.T())->get_JxW();
594 const std::vector<std::vector<libMesh::Real> >& T_phi =
595 context.get_element_fe(this->_temp_vars.T())->get_phi();
596 const std::vector<std::vector<libMesh::Real> >& u_phi =
597 context.get_element_fe(this->_flow_vars.u())->get_phi();
600 const std::vector<std::vector<libMesh::RealGradient> >& T_gradphi =
601 context.get_element_fe(this->_temp_vars.T())->get_dphi();
603 libMesh::DenseSubVector<libMesh::Number> &FT = context.get_elem_residual(this->_temp_vars.T());
605 unsigned int n_qpoints = context.get_element_qrule().n_points();
606 for (
unsigned int qp=0; qp != n_qpoints; qp++)
608 libMesh::Number u, v, T, p0;
616 libMesh::NumberVectorValue U(u,v);
617 if (this->_flow_vars.dim() == 3)
620 libMesh::DenseSubMatrix<libMesh::Number> &KTu = context.get_elem_jacobian(this->_temp_vars.T(), this->_flow_vars.u());
621 libMesh::DenseSubMatrix<libMesh::Number> &KTv = context.get_elem_jacobian(this->_temp_vars.T(), this->_flow_vars.v());
622 libMesh::DenseSubMatrix<libMesh::Number>* KTw = NULL;
624 libMesh::DenseSubMatrix<libMesh::Number> &KTT = context.get_elem_jacobian(this->_temp_vars.T(), this->_temp_vars.T());
626 if( this->_flow_vars.dim() == 3 )
628 KTw = &context.get_elem_jacobian(this->_temp_vars.T(), this->_flow_vars.w());
631 libMesh::Number k = this->_k(T);
632 libMesh::Number dk_dT = this->_k.deriv(T);
633 libMesh::Number cp = this->_cp(T);
634 libMesh::Number d_cp = this->_cp.deriv(T);
635 libMesh::Number rho = this->rho( T, p0 );
636 libMesh::Number d_rho = this->d_rho_dT( T, p0 );
640 for (
unsigned int i=0; i != n_T_dofs; i++)
642 FT(i) += ( -rho*cp*U*grad_T*T_phi[i][qp]
643 - k*grad_T*T_gradphi[i][qp]
649 for (
unsigned int j=0; j!=n_u_dofs; j++)
652 libMesh::Number r0 = rho*cp*T_phi[i][qp]*u_phi[j][qp];
662 if (this->_flow_vars.dim() == 3)
664 (*KTw)(i,j) += JxW[qp]*
672 for (
unsigned int j=0; j!=n_T_dofs; j++)
674 KTT(i,j) += JxW[qp]* (
676 cp*U*T_phi[i][qp]*T_gradphi[j][qp]
677 + U*grad_T*T_phi[i][qp]*d_cp*T_phi[j][qp]
679 -cp*U*grad_T*T_phi[i][qp]*d_rho*T_phi[j][qp]
680 -k*T_gradphi[i][qp]*T_gradphi[j][qp]
681 -grad_T*T_gradphi[i][qp]*dk_dT*T_phi[j][qp]
692 template<
class Mu,
class SH,
class TC>
697 const std::vector<libMesh::Real> &JxW =
698 context.get_element_fe(this->_flow_vars.u())->get_JxW();
701 const std::vector<std::vector<libMesh::Real> >& p_phi =
702 context.get_element_fe(this->_press_var.p())->get_phi();
705 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
708 libMesh::DenseSubVector<libMesh::Real> &F_p = context.get_elem_residual(this->_press_var.p());
710 unsigned int n_qpoints = context.get_element_qrule().n_points();
712 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
720 context.interior_rate(this->_temp_vars.T(), qp, T_dot);
722 libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
724 for (
unsigned int i = 0; i != n_p_dofs; ++i)
726 F_p(i) -= T_dot/T*p_phi[i][qp]*JxW[qp];
734 template<
class Mu,
class SH,
class TC>
739 const std::vector<libMesh::Real> &JxW =
740 context.get_element_fe(this->_flow_vars.u())->get_JxW();
743 const std::vector<std::vector<libMesh::Real> >& u_phi =
744 context.get_element_fe(this->_flow_vars.u())->get_phi();
747 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
750 libMesh::DenseSubVector<libMesh::Real> &F_u = context.get_elem_residual(this->_flow_vars.u());
751 libMesh::DenseSubVector<libMesh::Real> &F_v = context.get_elem_residual(this->_flow_vars.v());
752 libMesh::DenseSubVector<libMesh::Real>* F_w = NULL;
755 if( this->_flow_vars.dim() == 3 )
756 F_w = &context.get_elem_residual(this->_flow_vars.w());
758 unsigned int n_qpoints = context.get_element_qrule().n_points();
760 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
767 libMesh::Real u_dot, v_dot, w_dot = 0.0;
768 context.interior_rate(this->_flow_vars.u(), qp, u_dot);
769 context.interior_rate(this->_flow_vars.v(), qp, v_dot);
771 if( this->_flow_vars.dim() == 3 )
772 context.interior_rate(this->_flow_vars.w(), qp, w_dot);
774 libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
776 libMesh::Number rho = this->rho(T, this->get_p0_transient(context, qp));
778 for (
unsigned int i = 0; i != n_u_dofs; ++i)
780 F_u(i) -= rho*u_dot*u_phi[i][qp]*JxW[qp];
781 F_v(i) -= rho*v_dot*u_phi[i][qp]*JxW[qp];
783 if( this->_flow_vars.dim() == 3 )
784 (*F_w)(i) -= rho*w_dot*u_phi[i][qp]*JxW[qp];
813 template<
class Mu,
class SH,
class TC>
818 const std::vector<libMesh::Real> &JxW =
819 context.get_element_fe(this->_temp_vars.T())->get_JxW();
822 const std::vector<std::vector<libMesh::Real> >& T_phi =
823 context.get_element_fe(this->_temp_vars.T())->get_phi();
826 const unsigned int n_T_dofs = context.get_dof_indices(this->_temp_vars.T()).size();
829 libMesh::DenseSubVector<libMesh::Real> &F_T = context.get_elem_residual(this->_temp_vars.T());
831 unsigned int n_qpoints = context.get_element_qrule().n_points();
833 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
841 context.interior_rate(this->_temp_vars.T(), qp, T_dot);
843 libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
845 libMesh::Real cp = this->_cp(T);
847 libMesh::Number rho = this->rho(T, this->get_p0_transient(context, qp));
849 for (
unsigned int i = 0; i != n_T_dofs; ++i)
851 F_T(i) -= rho*cp*T_dot*T_phi[i][qp]*JxW[qp];
859 template<
class Mu,
class SH,
class TC>
864 const std::vector<libMesh::Real> &JxW =
865 context.get_element_fe(this->_temp_vars.T())->get_JxW();
868 const unsigned int n_p0_dofs = context.get_dof_indices(this->_p0_var->p0()).size();
871 libMesh::DenseSubVector<libMesh::Real> &F_p0 = context.get_elem_residual(this->_p0_var->p0());
873 unsigned int n_qpoints = context.get_element_qrule().n_points();
875 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
878 T = context.interior_value(this->_temp_vars.T(), qp);
880 libMesh::Gradient grad_u, grad_v, grad_w;
881 grad_u = context.interior_gradient(this->_flow_vars.u(), qp);
882 grad_v = context.interior_gradient(this->_flow_vars.v(), qp);
883 if (this->_flow_vars.dim() == 3)
884 grad_w = context.interior_gradient(this->_flow_vars.w(), qp);
886 libMesh::Number divU = grad_u(0) + grad_v(1);
887 if(this->_flow_vars.dim()==3)
895 libMesh::Number p0 = context.interior_value( this->_p0_var->p0(), qp );
897 for (
unsigned int i = 0; i != n_p0_dofs; ++i)
899 F_p0(i) += (p0/T - this->_p0/this->_T0)*JxW[qp];
907 template<
class Mu,
class SH,
class TC>
912 const unsigned int n_p0_dofs = context.get_dof_indices(this->_p0_var->p0()).size();
924 unsigned int n_qpoints = context.get_side_qrule().n_points();
925 for (
unsigned int qp=0; qp != n_qpoints; qp++)
948 for (
unsigned int i=0; i != n_p0_dofs; i++)
957 template<
class Mu,
class SH,
class TC>
962 const unsigned int n_p0_dofs = context.get_dof_indices(this->_p0_var->p0()).size();
963 const unsigned int n_T_dofs = context.get_dof_indices(this->_temp_vars.T()).size();
964 const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
967 const std::vector<libMesh::Real> &JxW =
968 context.get_element_fe(this->_temp_vars.T())->get_JxW();
971 const std::vector<std::vector<libMesh::Real> >& T_phi =
972 context.get_element_fe(this->_temp_vars.T())->get_phi();
975 const std::vector<std::vector<libMesh::Real> >& p_phi =
976 context.get_element_fe(this->_press_var.p())->get_phi();
979 libMesh::DenseSubVector<libMesh::Real> &F_p0 = context.get_elem_residual(this->_p0_var->p0());
980 libMesh::DenseSubVector<libMesh::Real> &F_T = context.get_elem_residual(this->_temp_vars.T());
981 libMesh::DenseSubVector<libMesh::Real> &F_p = context.get_elem_residual(this->_press_var.p());
983 unsigned int n_qpoints = context.get_element_qrule().n_points();
985 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
988 T = context.fixed_interior_value(this->_temp_vars.T(), qp);
990 libMesh::Number cp = this->_cp(T);
991 libMesh::Number cv = cp + this->_R;
992 libMesh::Number gamma = cp/cv;
993 libMesh::Number one_over_gamma = 1.0/(gamma-1.0);
995 libMesh::Number p0_dot;
996 context.interior_rate(this->_p0_var->p0(), qp, p0_dot);
998 libMesh::Number p0 = context.fixed_interior_value(this->_p0_var->p0(), qp );
1000 for (
unsigned int i=0; i != n_p0_dofs; i++)
1002 F_p0(i) -= p0_dot*one_over_gamma*JxW[qp];
1005 for (
unsigned int i=0; i != n_T_dofs; i++)
1007 F_T(i) += p0_dot*T_phi[i][qp]*JxW[qp];
1010 for (
unsigned int i=0; i != n_p_dofs; i++)
1012 F_p(i) += p0_dot/p0*p_phi[i][qp]*JxW[qp];
1019 template<
class Mu,
class SH,
class TC>
1024 const unsigned int n_qpoints = context.get_element_qrule().n_points();
1026 std::vector<libMesh::Real> u, v, w, T, p, p0;
1027 u.resize(n_qpoints);
1028 v.resize(n_qpoints);
1029 if( this->_flow_vars.dim() > 2 )
1030 w.resize(n_qpoints);
1032 T.resize(n_qpoints);
1033 p.resize(n_qpoints);
1034 p0.resize(n_qpoints);
1036 std::vector<libMesh::Gradient> grad_u, grad_v, grad_w, grad_T;
1037 grad_u.resize(n_qpoints);
1038 grad_v.resize(n_qpoints);
1039 if( this->_flow_vars.dim() > 2 )
1040 grad_w.resize(n_qpoints);
1042 grad_T.resize(n_qpoints);
1044 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
1046 u[qp] = context.interior_value(this->_flow_vars.u(), qp);
1047 v[qp] = context.interior_value(this->_flow_vars.v(), qp);
1049 grad_u[qp] = context.interior_gradient(this->_flow_vars.u(), qp);
1050 grad_v[qp] = context.interior_gradient(this->_flow_vars.v(), qp);
1051 if( this->_flow_vars.dim() > 2 )
1053 w[qp] = context.interior_value(this->_flow_vars.w(), qp);
1054 grad_w[qp] = context.interior_gradient(this->_flow_vars.w(), qp);
1056 T[qp] = context.interior_value(this->_temp_vars.T(), qp);
1057 grad_T[qp] = context.interior_gradient(this->_temp_vars.T(), qp);
1059 p[qp] = context.interior_value(this->_press_var.p(), qp);
1060 p0[qp] = this->get_p0_steady(context, qp);
1069 if(this->_flow_vars.dim() > 2)
1082 template<
class Mu,
class SH,
class TC>
1085 const libMesh::Point& point,
1086 libMesh::Real& value )
1088 if( quantity_index == this->_rho_index )
1090 libMesh::Real T = this->T(point,context);
1091 libMesh::Real p0 = this->get_p0_steady(context,point);
1093 value = this->rho( T, p0 );
void assemble_mass_time_deriv(bool compute_jacobian, AssemblyContext &context, const CachedValues &cache)
Helper function.
CachedValues & get_cached_values()
void assemble_momentum_mass_residual(bool compute_jacobian, AssemblyContext &context)
Helper function.
unsigned int register_quantity(std::string name)
Register quantity to be postprocessed.
GRINS::ICHandlingBase * _ic_handler
virtual void element_constraint(bool compute_jacobian, AssemblyContext &context)
Constraint part(s) of physics for element interiors.
virtual void auxiliary_init(MultiphysicsSystem &system)
Any auxillary initialization a Physics class may need.
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for element interiors.
void assemble_energy_time_deriv(bool compute_jacobian, AssemblyContext &context, const CachedValues &cache)
Helper function.
static PhysicsName low_mach_navier_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 compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
void assemble_momentum_time_deriv(bool compute_jacobian, AssemblyContext &context, const CachedValues &cache)
Helper function.
Physics class for Incompressible Navier-Stokes.
VelocityVariable & _flow_vars
virtual void compute_element_time_derivative_cache(AssemblyContext &context)
Interface with libMesh for solving Multiphysics problems.
const std::vector< libMesh::Gradient > & get_cached_gradient_values(unsigned int quantity) const
virtual void register_postprocessing_vars(const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
Register postprocessing variables for LowMachNavierStokes.
bool _pin_pressure
Enable pressure pinning.
Physics class for Incompressible Navier-Stokes.
void assemble_thermo_press_side_time_deriv(bool compute_jacobian, AssemblyContext &context)
void assemble_continuity_mass_residual(bool compute_jacobian, AssemblyContext &context)
Helper function.
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
unsigned int dim() const
Number of components.
void set_gradient_values(unsigned int quantity, std::vector< libMesh::Gradient > &values)
void assemble_thermo_press_mass_residual(bool compute_jacobian, AssemblyContext &context)
void assemble_energy_mass_residual(bool compute_jacobian, AssemblyContext &context)
Helper function.
const std::vector< libMesh::Number > & get_cached_values(unsigned int quantity) const
void assemble_thermo_press_elem_time_deriv(bool compute_jacobian, AssemblyContext &context)