36 template<
typename Mixture,
typename Evaluator>
38 (
const std::string& physics_name,
const GetPot& input,libMesh::UniquePtr<Mixture> & gas_mix )
40 _stab_helper( physics_name+
"StabHelper", input )
43 template<
typename Mixture,
typename Evaluator>
50 context.get_element_fe(this->_press_var.p())->get_dphi();
53 context.get_element_fe(this->_flow_vars.u())->get_d2phi();
54 context.get_element_fe(this->_temp_vars.T())->get_d2phi();
57 template<
typename Mixture,
typename Evaluator>
61 libMesh::RealGradient& RM_s,
63 std::vector<libMesh::Real>& Rs_s )
65 Rs_s.resize(this->n_species(),0.0);
69 libMesh::Real r = (context.get_element_fe(this->_flow_vars.u())->get_xyz())[qp](0);
71 libMesh::RealGradient grad_p = context.interior_gradient(this->_press_var.p(), qp);
73 libMesh::RealGradient grad_u = context.interior_gradient(this->_flow_vars.u(), qp);
75 libMesh::RealGradient U( context.interior_value(this->_flow_vars.u(), qp) );
76 libMesh::Real divU = grad_u(0);
78 if( this->_is_axisymmetric )
81 if(this->_flow_vars.dim() > 1)
83 U(1) = context.interior_value(this->_flow_vars.v(), qp);
84 divU += (context.interior_gradient(this->_flow_vars.v(), qp))(1);
86 if(this->_flow_vars.dim() == 3)
88 U(2) = context.interior_value(this->_flow_vars.w(), qp);
89 divU += (context.interior_gradient(this->_flow_vars.w(), qp))(2);
94 libMesh::RealTensor hess_u = context.interior_hessian(this->_flow_vars.u(), qp);
95 libMesh::RealTensor hess_v = context.interior_hessian(this->_flow_vars.v(), qp);
97 libMesh::Real T = context.interior_value(this->_temp_vars.T(), qp);
99 libMesh::Gradient grad_T = context.interior_gradient(this->_temp_vars.T(), qp);
100 libMesh::Tensor hess_T = context.interior_hessian(this->_temp_vars.T(), qp);
102 libMesh::Real hess_T_term = hess_T(0,0) + hess_T(1,1);
104 hess_T_term += hess_T(2,2);
107 if( this->_is_axisymmetric )
108 hess_T_term += grad_T(0)/r;
110 std::vector<libMesh::Real> ws(this->n_species());
111 std::vector<libMesh::RealGradient> grad_ws(this->n_species());
112 std::vector<libMesh::RealTensor> hess_ws(this->n_species());
113 for(
unsigned int s=0; s < this->_n_species; s++ )
115 ws[s] = context.interior_value(this->_species_vars.species(s), qp);
116 grad_ws[s] = context.interior_gradient(this->_species_vars.species(s), qp);
117 hess_ws[s] = context.interior_hessian(this->_species_vars.species(s), qp);
120 Evaluator gas_evaluator( *(this->_gas_mixture) );
121 const libMesh::Real R_mix = gas_evaluator.R_mix(ws);
122 const libMesh::Real p0 = this->get_p0_steady(context,qp);
123 libMesh::Real rho = this->rho(T, p0, R_mix );
124 libMesh::Real cp = gas_evaluator.cp(T,p0,ws);
125 libMesh::Real M = gas_evaluator.M_mix( ws );
127 std::vector<libMesh::Real> D( this->n_species() );
130 gas_evaluator.mu_and_k_and_D( T, rho, cp, ws, mu, k, D );
134 const libMesh::Real drho_dT = -p0/(R_mix*T*T);
135 libMesh::RealGradient grad_rho = drho_dT*grad_T;
136 for(
unsigned int s=0; s < this->_n_species; s++ )
138 libMesh::Real Ms = gas_evaluator.M(s);
144 const libMesh::Real drho_dws = -p0/(R_mix*R_mix*T)*R_uni/Ms;
145 grad_rho += drho_dws*grad_ws[s];
148 libMesh::RealGradient rhoUdotGradU;
149 libMesh::RealGradient divGradU;
150 libMesh::RealGradient divGradUT;
151 libMesh::RealGradient divdivU;
153 if( this->_flow_vars.dim() == 1 )
155 rhoUdotGradU = rho*_stab_helper.UdotGradU( U, grad_u );
157 divGradU = _stab_helper.div_GradU( hess_u );
158 divGradUT = _stab_helper.div_GradU_T( hess_u );
159 divdivU = _stab_helper.div_divU_I( hess_u );
161 else if( this->_flow_vars.dim() == 2 )
163 libMesh::RealGradient grad_v = context.interior_gradient(this->_flow_vars.v(), qp);
165 rhoUdotGradU = rho*_stab_helper.UdotGradU( U, grad_u, grad_v );
168 if( this->_is_axisymmetric )
170 divGradU = _stab_helper.div_GradU_axi( r, U, grad_u, grad_v, hess_u, hess_v );
171 divGradUT = _stab_helper.div_GradU_T_axi( r, U, grad_u, hess_u, hess_v );
172 divdivU = _stab_helper.div_divU_I_axi( r, U, grad_u, hess_u, hess_v );
176 divGradU = _stab_helper.div_GradU( hess_u, hess_v );
177 divGradUT = _stab_helper.div_GradU_T( hess_u, hess_v );
178 divdivU = _stab_helper.div_divU_I( hess_u, hess_v );
183 libMesh::RealGradient grad_v = context.interior_gradient(this->_flow_vars.v(), qp);
184 libMesh::RealTensor hess_v = context.interior_hessian(this->_flow_vars.v(), qp);
186 libMesh::RealGradient grad_w = context.interior_gradient(this->_flow_vars.w(), qp);
187 libMesh::RealTensor hess_w = context.interior_hessian(this->_flow_vars.w(), qp);
189 rhoUdotGradU = rho*_stab_helper.UdotGradU( U, grad_u, grad_v, grad_w );
191 divGradU = _stab_helper.div_GradU( hess_u, hess_v, hess_w );
192 divGradUT = _stab_helper.div_GradU_T( hess_u, hess_v, hess_w );
193 divdivU = _stab_helper.div_divU_I( hess_u, hess_v, hess_w );
232 libMesh::RealGradient div_stress = mu*(divGradU + divGradUT - 2.0/3.0*divdivU);
234 std::vector<libMesh::Real> omega_dot(this->n_species());
235 gas_evaluator.omega_dot(T,rho,ws,omega_dot);
237 libMesh::Real chem_term = 0.0;
238 libMesh::Gradient mass_term(0.0,0.0,0.0);
239 for(
unsigned int s=0; s < this->_n_species; s++ )
242 libMesh::Real h_s=gas_evaluator.h_s(T,s);
243 chem_term += h_s*omega_dot[s];
247 mass_term += grad_ws[s]/this->_gas_mixture->M(s);
249 libMesh::Real hess_s_term = hess_ws[s](0,0) + hess_ws[s](1,1);
251 hess_s_term += hess_ws[s](2,2);
254 if( this->_is_axisymmetric )
255 hess_s_term += grad_ws[s](0)/r;
260 Rs_s[s] = rho*U*grad_ws[s] - rho*D[s]*hess_s_term - grad_rho*D[s]*grad_ws[s]
266 RP_s = divU - (U*grad_T)/T - U*mass_term;
269 RM_s = rhoUdotGradU + grad_p - div_stress - rho*(this->_g);
273 RE_s = rho*U*cp*grad_T - k*(hess_T_term) + chem_term;
278 template<
typename Mixture,
typename Evaluator>
282 libMesh::RealGradient& RM_t,
284 std::vector<libMesh::Real>& Rs_t )
286 libMesh::Real T = context.interior_value( this->_temp_vars.T(), qp );
288 std::vector<libMesh::Real> ws(this->n_species());
289 for(
unsigned int s=0; s < this->_n_species; s++ )
291 ws[s] = context.interior_value(this->_species_vars.species(s), qp);
294 Evaluator gas_evaluator( *(this->_gas_mixture) );
295 const libMesh::Real R_mix = gas_evaluator.R_mix(ws);
296 const libMesh::Real p0 = this->get_p0_transient(context,qp);
297 const libMesh::Real rho = this->rho(T, p0, R_mix);
298 const libMesh::Real cp = gas_evaluator.cp(T,p0,ws);
299 const libMesh::Real M = gas_evaluator.M_mix( ws );
302 libMesh::Real M_dot = 0.0;
303 std::vector<libMesh::Real> ws_dot(this->n_species());
304 for(
unsigned int s=0; s < this->n_species(); s++)
306 context.interior_rate(this->_species_vars.species(s), qp, ws_dot[s]);
309 M_dot += ws_dot[s]/this->_gas_mixture->M(s);
311 libMesh::Real M_dot_over_M = M_dot*(-M);
313 libMesh::RealGradient u_dot;
314 context.interior_rate(this->_flow_vars.u(), qp, u_dot(0));
315 if(this->_flow_vars.dim() > 1)
316 context.interior_rate(this->_flow_vars.v(), qp, u_dot(1));
317 if(this->_flow_vars.dim() == 3)
318 context.interior_rate(this->_flow_vars.w(), qp, u_dot(2));
321 context.interior_rate(this->_temp_vars.T(), qp, T_dot);
323 RP_t = -T_dot/T + M_dot_over_M;
326 for(
unsigned int s=0; s < this->n_species(); s++)
328 Rs_t[s] = rho*ws_dot[s];
const libMesh::Real R_universal
Universal Gas Constant, R, [J/(kmol-K)].
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
void compute_res_steady(AssemblyContext &context, unsigned int qp, libMesh::Real &RP_s, libMesh::RealGradient &RM_s, libMesh::Real &RE_s, std::vector< libMesh::Real > &Rs_s)
void compute_res_transient(AssemblyContext &context, unsigned int qp, libMesh::Real &RP_t, libMesh::RealGradient &RM_t, libMesh::Real &RE_t, std::vector< libMesh::Real > &Rs_t)
ReactingLowMachNavierStokesStabilizationBase()
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.