37 #include "libmesh/quadrature.h"
38 #include "libmesh/fem_system.h"
42 template<
typename Mixture,
typename Evaluator>
45 _p_pinning(input,physics_name),
67 template<
typename Mixture,
typename Evaluator>
73 template<
typename Mixture,
typename Evaluator>
84 template<
typename Mixture,
typename Evaluator>
90 if( input.have_variable(section) )
92 unsigned int n_vars = input.vector_variable_size(section);
94 for(
unsigned int v = 0; v < n_vars; v++ )
96 std::string name = input(section,
"DIE!",v);
98 if( name == std::string(
"rho") )
102 else if( name == std::string(
"mu") )
106 else if( name == std::string(
"k") )
110 else if( name == std::string(
"cp") )
114 else if( name == std::string(
"mole_fractions") )
116 this->_mole_fractions_index.resize(this->n_species());
118 for(
unsigned int s = 0; s < this->n_species(); s++ )
120 this->_mole_fractions_index[s] = postprocessing.
register_quantity(
"X_"+this->_gas_mixture.species_name(s) );
123 else if( name == std::string(
"h_s") )
125 this->_h_s_index.resize(this->n_species());
127 for(
unsigned int s = 0; s < this->n_species(); s++ )
129 this->_h_s_index[s] = postprocessing.
register_quantity(
"h_"+this->_gas_mixture.species_name(s) );
132 else if( name == std::string(
"omega_dot") )
134 this->_omega_dot_index.resize(this->n_species());
136 for(
unsigned int s = 0; s < this->n_species(); s++ )
138 this->_omega_dot_index[s] = postprocessing.
register_quantity(
"omega_dot_"+this->_gas_mixture.species_name(s) );
141 std::cout <<
"omega_dot size = " << _omega_dot_index.size() << std::endl;
146 <<
" Found " << name << std::endl
147 <<
" Acceptable values are: rho" << std::endl
148 <<
" mu" << std::endl
150 <<
" cp" << std::endl
151 <<
" mole_fractions" << std::endl
152 <<
" omega_dot" << std::endl;
161 template<
typename Mixture,
typename Evaluator>
168 context.get_side_fe(this->_u_var)->get_JxW();
169 context.get_side_fe(this->_u_var)->get_phi();
170 context.get_side_fe(this->_u_var)->get_dphi();
171 context.get_side_fe(this->_u_var)->get_xyz();
173 context.get_side_fe(this->_T_var)->get_JxW();
174 context.get_side_fe(this->_T_var)->get_phi();
175 context.get_side_fe(this->_T_var)->get_dphi();
176 context.get_side_fe(this->_T_var)->get_xyz();
181 template<
typename Mixture,
typename Evaluator>
186 if( compute_jacobian )
188 libmesh_not_implemented();
194 const unsigned int n_p_dofs = context.get_dof_indices(this->_p_var).size();
195 const unsigned int n_s_dofs = context.get_dof_indices(s0_var).size();
196 const unsigned int n_u_dofs = context.get_dof_indices(this->_u_var).size();
197 const unsigned int n_T_dofs = context.get_dof_indices(this->_T_var).size();
200 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_v_var).size());
202 libmesh_assert (n_u_dofs == context.get_dof_indices(this->_w_var).size());
205 const std::vector<libMesh::Real>& JxW =
206 context.get_element_fe(this->_u_var)->get_JxW();
209 const std::vector<std::vector<libMesh::Real> >& p_phi =
210 context.get_element_fe(this->_p_var)->get_phi();
213 const std::vector<std::vector<libMesh::Real> >& s_phi = context.get_element_fe(s0_var)->get_phi();
216 const std::vector<std::vector<libMesh::Gradient> >& s_grad_phi = context.get_element_fe(s0_var)->get_dphi();
219 const std::vector<std::vector<libMesh::Real> >& u_phi =
220 context.get_element_fe(this->_u_var)->get_phi();
223 const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
224 context.get_element_fe(this->_u_var)->get_dphi();
227 const std::vector<std::vector<libMesh::Real> >& T_phi =
228 context.get_element_fe(this->_T_var)->get_phi();
231 const std::vector<std::vector<libMesh::RealGradient> >& T_gradphi =
232 context.get_element_fe(this->_T_var)->get_dphi();
234 const std::vector<libMesh::Point>& u_qpoint =
235 context.get_element_fe(this->_u_var)->get_xyz();
237 libMesh::DenseSubVector<libMesh::Number>& Fp = context.get_elem_residual(this->_p_var);
239 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_u_var);
240 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_v_var);
241 libMesh::DenseSubVector<libMesh::Number> &Fw = context.get_elem_residual(this->_w_var);
243 libMesh::DenseSubVector<libMesh::Number> &FT = context.get_elem_residual(this->_T_var);
245 unsigned int n_qpoints = context.get_element_qrule().n_points();
246 for (
unsigned int qp=0; qp != n_qpoints; qp++)
250 libMesh::Number u, v, T;
256 const libMesh::Gradient& grad_T =
259 libMesh::NumberVectorValue U(u,v);
266 libMesh::Gradient grad_w;
270 libMesh::Number divU = grad_u(0) + grad_v(1);
274 libMesh::NumberVectorValue grad_uT( grad_u(0), grad_v(0) );
275 libMesh::NumberVectorValue grad_vT( grad_u(1), grad_v(1) );
276 libMesh::NumberVectorValue grad_wT;
277 if( this->_dim == 3 )
279 grad_uT(2) = grad_w(0);
280 grad_vT(2) = grad_w(1);
281 grad_wT = libMesh::NumberVectorValue( grad_u(2), grad_v(2), grad_w(2) );
287 const std::vector<libMesh::Real>& D =
296 const std::vector<libMesh::Real>& omega_dot =
299 const std::vector<libMesh::Real>& h =
302 const libMesh::Number r = u_qpoint[qp](0);
304 libMesh::Real jac = JxW[qp];
306 if( this->_is_axisymmetric )
315 libmesh_assert_equal_to( grad_ws.size(), this->_n_species );
318 libMesh::Gradient mass_term(0.0,0.0,0.0);
319 for(
unsigned int s=0; s < this->_n_species; s++ )
321 mass_term += grad_ws[s]/this->_gas_mixture.M(s);
325 for (
unsigned int i=0; i != n_p_dofs; i++)
327 Fp(i) += (-U*(mass_term + grad_T/T) + divU)*jac*p_phi[i][qp];
331 for(
unsigned int s=0; s < this->_n_species; s++ )
333 libMesh::DenseSubVector<libMesh::Number> &Fs =
334 context.get_elem_residual(this->_species_vars[s]);
336 const libMesh::Real term1 = -rho*(U*grad_ws[s]) + omega_dot[s];
337 const libMesh::Gradient term2 = -rho*D[s]*grad_ws[s];
339 for (
unsigned int i=0; i != n_s_dofs; i++)
342 Fs(i) += ( term1*s_phi[i][qp] + term2*s_grad_phi[i][qp] )*jac;
347 for (
unsigned int i=0; i != n_u_dofs; i++)
349 Fu(i) += ( -rho*U*grad_u*u_phi[i][qp]
350 + p*u_gradphi[i][qp](0)
351 - mu*(u_gradphi[i][qp]*grad_u + u_gradphi[i][qp]*grad_uT
352 - 2.0/3.0*divU*u_gradphi[i][qp](0) )
353 + rho*this->_g(0)*u_phi[i][qp]
358 if( this->_is_axisymmetric )
360 Fu(i) += u_phi[i][qp]*( p/r - 2*mu*U(0)/(r*r) - 2.0/3.0*mu*divU/r )*jac;
363 Fv(i) += ( -rho*U*grad_v*u_phi[i][qp]
364 + p*u_gradphi[i][qp](1)
365 - mu*(u_gradphi[i][qp]*grad_v + u_gradphi[i][qp]*grad_vT
366 - 2.0/3.0*divU*u_gradphi[i][qp](1) )
367 + rho*this->_g(1)*u_phi[i][qp]
372 Fw(i) += ( -rho*U*grad_w*u_phi[i][qp]
373 + p*u_gradphi[i][qp](2)
374 - mu*(u_gradphi[i][qp]*grad_w + u_gradphi[i][qp]*grad_wT
375 - 2.0/3.0*divU*u_gradphi[i][qp](2) )
376 + rho*this->_g(2)*u_phi[i][qp]
382 libMesh::Real chem_term = 0.0;
383 for(
unsigned int s=0; s < this->_n_species; s++ )
385 chem_term += h[s]*omega_dot[s];
388 for (
unsigned int i=0; i != n_T_dofs; i++)
390 FT(i) += ( ( -rho*cp*U*grad_T - chem_term )*T_phi[i][qp]
391 - k*grad_T*T_gradphi[i][qp] )*jac;
399 template<
typename Mixture,
typename Evaluator>
406 std::vector<BoundaryID> ids = context.side_boundary_ids();
408 for( std::vector<BoundaryID>::const_iterator it = ids.begin();
409 it != ids.end(); it++ )
411 libmesh_assert (*it != libMesh::BoundaryInfo::invalid_id);
413 this->_bc_handler->apply_neumann_bcs( context, cache, compute_jacobian, *it );
419 template<
typename Mixture,
typename Evaluator>
425 if( this->_pin_pressure )
427 _p_pinning.pin_value( context, compute_jacobian, this->_p_var );
433 template<
typename Mixture,
typename Evaluator>
438 libmesh_not_implemented();
443 template<
typename Mixture,
typename Evaluator>
447 Evaluator gas_evaluator( this->_gas_mixture );
449 const unsigned int n_qpoints = context.get_element_qrule().n_points();
451 std::vector<libMesh::Real> u, v, w, T, p, p0;
459 p0.resize(n_qpoints);
461 std::vector<libMesh::Gradient> grad_u, grad_v, grad_w, grad_T;
462 grad_u.resize(n_qpoints);
463 grad_v.resize(n_qpoints);
465 grad_w.resize(n_qpoints);
467 grad_T.resize(n_qpoints);
469 std::vector<std::vector<libMesh::Real> > mass_fractions;
470 std::vector<std::vector<libMesh::Gradient> > grad_mass_fractions;
471 mass_fractions.resize(n_qpoints);
472 grad_mass_fractions.resize(n_qpoints);
474 std::vector<libMesh::Real> M;
477 std::vector<libMesh::Real> R;
480 std::vector<libMesh::Real> rho;
481 rho.resize(n_qpoints);
483 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
485 u[qp] = context.interior_value(this->_u_var, qp);
486 v[qp] = context.interior_value(this->_v_var, qp);
488 grad_u[qp] = context.interior_gradient(this->_u_var, qp);
489 grad_v[qp] = context.interior_gradient(this->_v_var, qp);
492 w[qp] = context.interior_value(this->_w_var, qp);
493 grad_w[qp] = context.interior_gradient(this->_w_var, qp);
495 T[qp] = context.interior_value(this->_T_var, qp);
496 grad_T[qp] = context.interior_gradient(this->_T_var, qp);
498 p[qp] = context.interior_value(this->_p_var, qp);
499 p0[qp] = this->get_p0_steady(context, qp);
501 mass_fractions[qp].resize(this->_n_species);
502 grad_mass_fractions[qp].resize(this->_n_species);
504 for(
unsigned int s = 0; s < this->_n_species; s++ )
508 mass_fractions[qp][s] = std::max( context.interior_value(this->_species_vars[s],qp), 0.0 );
509 grad_mass_fractions[qp][s] = context.interior_gradient(this->_species_vars[s],qp);
512 M[qp] = gas_evaluator.M_mix( mass_fractions[qp] );
514 R[qp] = gas_evaluator.R_mix( mass_fractions[qp] );
516 rho[qp] = this->rho( T[qp], p0[qp], R[qp] );
548 std::vector<libMesh::Real> mu;
549 mu.resize(n_qpoints);
551 std::vector<libMesh::Real> cp;
552 cp.resize(n_qpoints);
554 std::vector<libMesh::Real> k;
557 std::vector<std::vector<libMesh::Real> > h_s;
558 h_s.resize(n_qpoints);
560 std::vector<std::vector<libMesh::Real> > D_s;
561 D_s.resize(n_qpoints);
563 std::vector<std::vector<libMesh::Real> > omega_dot_s;
564 omega_dot_s.resize(n_qpoints);
566 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
568 gas_evaluator.mu_and_k(cache,qp,mu[qp],k[qp]);
569 cp[qp] = gas_evaluator.cp(cache,qp);
571 h_s[qp].resize(this->_n_species);
572 gas_evaluator.h_s( cache, qp, h_s[qp] );
574 D_s[qp].resize(this->_n_species);
575 gas_evaluator.D( cache, qp, D_s[qp] );
577 omega_dot_s[qp].resize(this->_n_species);
578 gas_evaluator.omega_dot( cache, qp, omega_dot_s[qp] );
591 template<
typename Mixture,
typename Evaluator>
595 Evaluator gas_evaluator( this->_gas_mixture );
597 const unsigned int n_qpoints = context.get_side_qrule().n_points();
602 std::vector<libMesh::Real> T, rho;
604 rho.resize(n_qpoints);
606 std::vector<std::vector<libMesh::Real> > mass_fractions;
607 mass_fractions.resize(n_qpoints);
609 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
611 T[qp] = context.side_value(this->_T_var, qp);
613 mass_fractions[qp].resize(this->_n_species);
614 for(
unsigned int s = 0; s < this->_n_species; s++ )
618 mass_fractions[qp][s] = std::max( context.side_value(this->_species_vars[s],qp), 0.0 );
620 const libMesh::Real p0 = this->get_p0_steady_side(context, qp);
622 rho[qp] = this->rho( T[qp], p0, gas_evaluator.R_mix(mass_fractions[qp]) );
632 template<
typename Mixture,
typename Evaluator>
635 const libMesh::Point& point,
636 libMesh::Real& value )
638 Evaluator gas_evaluator( this->_gas_mixture );
640 if( quantity_index == this->_rho_index )
642 std::vector<libMesh::Real> Y( this->_n_species );
643 libMesh::Real T = this->T(point,context);
644 libMesh::Real p0 = this->get_p0_steady(context,point);
645 this->mass_fractions( point, context, Y );
647 value = this->rho( T, p0, gas_evaluator.R_mix(Y) );
649 else if( quantity_index == this->_mu_index )
651 std::vector<libMesh::Real> Y( this->_n_species );
652 libMesh::Real T = this->T(point,context);
653 this->mass_fractions( point, context, Y );
655 value = gas_evaluator.mu( T, Y );
657 else if( quantity_index == this->_k_index )
659 std::vector<libMesh::Real> Y( this->_n_species );
660 libMesh::Real T = this->T(point,context);
661 this->mass_fractions( point, context, Y );
663 value = gas_evaluator.k( T, Y );
665 else if( quantity_index == this->_cp_index )
667 std::vector<libMesh::Real> Y( this->_n_species );
668 libMesh::Real T = this->T(point,context);
669 this->mass_fractions( point, context, Y );
671 value = gas_evaluator.cp( T, Y );
676 if( !this->_h_s_index.empty() )
678 libmesh_assert_equal_to( _h_s_index.size(), this->n_species() );
680 for(
unsigned int s = 0; s < this->n_species(); s++ )
682 if( quantity_index == this->_h_s_index[s] )
684 libMesh::Real T = this->T(point,context);
686 value = gas_evaluator.h_s( T, s );
692 if( !this->_mole_fractions_index.empty() )
694 libmesh_assert_equal_to( _mole_fractions_index.size(), this->n_species() );
696 for(
unsigned int s = 0; s < this->n_species(); s++ )
698 if( quantity_index == this->_mole_fractions_index[s] )
700 std::vector<libMesh::Real> Y( this->_n_species );
701 this->mass_fractions( point, context, Y );
703 libMesh::Real M = gas_evaluator.M_mix(Y);
705 value = gas_evaluator.X( s, M, Y[s] );
711 if( !this->_omega_dot_index.empty() )
713 libmesh_assert_equal_to( _omega_dot_index.size(), this->n_species() );
715 for(
unsigned int s = 0; s < this->n_species(); s++ )
717 if( quantity_index == this->_omega_dot_index[s] )
719 std::vector<libMesh::Real> Y( this->n_species() );
720 this->mass_fractions( point, context, Y );
722 libMesh::Real T = this->T(point,context);
724 libMesh::Real p0 = this->get_p0_steady(context,point);
726 libMesh::Real rho = this->rho( T, p0, gas_evaluator.R_mix(Y) );
728 std::vector<libMesh::Real> omega_dot( this->n_species() );
729 gas_evaluator.omega_dot( T, rho, Y, omega_dot );
731 value = omega_dot[s];
unsigned int VariableIndex
More descriptive name of the type used for variable indices.
unsigned int register_quantity(std::string name)
Register quantity to be postprocessed.
GRINS::ICHandlingBase * _ic_handler
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
virtual void register_postprocessing_vars(const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
Register postprocessing variables for ReactingLowMachNavierStokes.
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
GRINS::BCHandlingBase * _bc_handler
~ReactingLowMachNavierStokes()
void set_vector_gradient_values(unsigned int quantity, std::vector< std::vector< libMesh::Gradient > > &values)
Base class for reading and handling initial conditions for physics classes.
virtual void side_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for boundaries of elements on the domain boundary.
virtual void compute_side_time_derivative_cache(const AssemblyContext &context, CachedValues &cache)
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors.
const std::vector< std::vector< libMesh::Number > > & get_cached_vector_values(unsigned int quantity) const
virtual void compute_element_time_derivative_cache(const AssemblyContext &context, CachedValues &cache)
const std::vector< std::vector< libMesh::Gradient > > & get_cached_vector_gradient_values(unsigned int quantity) const
const std::vector< libMesh::Gradient > & get_cached_gradient_values(unsigned int quantity) const
bool is_axisymmetric() const
const PhysicsName reacting_low_mach_navier_stokes
ReactingLowMachNavierStokes()
void set_vector_values(unsigned int quantity, std::vector< std::vector< libMesh::Number > > &values)
void set_gradient_values(unsigned int quantity, std::vector< libMesh::Gradient > &values)
virtual void mass_residual(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part...
virtual void side_constraint(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Constraint part(s) of physics for boundaries of elements on the domain boundary.
virtual void compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
const std::vector< libMesh::Number > & get_cached_values(unsigned int quantity) const
virtual void read_input_options(const GetPot &input)
Read options from GetPot input file.