GRINS-0.6.0
Public Member Functions | Protected Attributes | List of all members
GRINS::SpalartAllmarasStabilizationHelper Class Reference

#include <spalart_allmaras_stab_helper.h>

Inheritance diagram for GRINS::SpalartAllmarasStabilizationHelper:
Inheritance graph
[legend]
Collaboration diagram for GRINS::SpalartAllmarasStabilizationHelper:
Collaboration graph
[legend]

Public Member Functions

 SpalartAllmarasStabilizationHelper (const std::string &helper_name, const GetPot &input)
 
 ~SpalartAllmarasStabilizationHelper ()
 
void init (libMesh::FEMSystem &system)
 
libMesh::Real compute_tau_spalart (AssemblyContext &c, unsigned int qp, libMesh::RealGradient &g, libMesh::RealTensor &G, libMesh::Real rho, libMesh::Gradient U, libMesh::Real mu, bool is_steady) const
 
void compute_tau_spalart_and_derivs (AssemblyContext &c, unsigned int qp, libMesh::RealGradient &g, libMesh::RealTensor &G, libMesh::Real rho, libMesh::Gradient U, libMesh::Real T, libMesh::Real &tau_M, libMesh::Real &d_tau_M_d_rho, libMesh::Gradient &d_tau_M_d_U, bool is_steady) const
 
libMesh::Real compute_tau (AssemblyContext &c, unsigned int qp, libMesh::Real mat_prop_sq, libMesh::RealGradient &g, libMesh::RealTensor &G, libMesh::Real rho, libMesh::Gradient U, bool is_steady) const
 
void compute_tau_and_derivs (AssemblyContext &c, unsigned int qp, libMesh::Real mat_prop_sq, libMesh::RealGradient &g, libMesh::RealTensor &G, libMesh::Real rho, libMesh::Gradient U, libMesh::Real &tau, libMesh::Real &d_tau_d_rho, libMesh::Gradient &d_tau_d_U, bool is_steady) const
 
libMesh::Real compute_res_spalart_steady (AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, const libMesh::Real distance_qp) const
 
void compute_res_spalart_steady_and_derivs (AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, libMesh::Gradient &res_M, libMesh::Tensor &d_res_M_dgradp, libMesh::Tensor &d_res_M_dU, libMesh::Gradient &d_res_Muvw_dgraduvw, libMesh::Tensor &d_res_Muvw_dhessuvw) const
 
libMesh::Real compute_res_spalart_transient (AssemblyContext &context, unsigned int qp, const libMesh::Real rho) const
 
void compute_res_spalart_transient_and_derivs (AssemblyContext &context, unsigned int qp, const libMesh::Real rho, libMesh::RealGradient &res_M, libMesh::Real &d_res_Muvw_duvw) const
 
libMesh::RealGradient compute_g (libMesh::FEBase *fe, AssemblyContext &c, unsigned int qp) const
 
libMesh::RealTensor compute_G (libMesh::FEBase *fe, AssemblyContext &c, unsigned int qp) const
 
virtual void set_parameter (libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
 Each subclass can simultaneously read a parameter value from. More...
 
virtual void register_parameter (const std::string &param_name, libMesh::ParameterMultiPointer< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 

Protected Attributes

unsigned int _dim
 Physical dimension of problem. More...
 
libMesh::Real _C
 
libMesh::Real _tau_factor
 
PrimitiveFlowVariables _flow_vars
 
TurbulenceVariables _turbulence_vars
 
SpalartAllmarasHelper _spalart_allmaras_helper
 
SpalartAllmarasParameters _sa_params
 

Detailed Description

Definition at line 44 of file spalart_allmaras_stab_helper.h.

Constructor & Destructor Documentation

GRINS::SpalartAllmarasStabilizationHelper::SpalartAllmarasStabilizationHelper ( const std::string &  helper_name,
const GetPot &  input 
)

Definition at line 37 of file spalart_allmaras_stab_helper.C.

39  : StabilizationHelper(helper_name),
40  _C( input("Stabilization/tau_constant_vel", input("Stabilization/tau_constant", 1 ) ) ),
41  _tau_factor( input("Stabilization/tau_factor_vel", input("Stabilization/tau_factor", 0.5 ) ) ),
42  _flow_vars(input),
43  _turbulence_vars(input),
45  _sa_params(input)
46  {
47  return;
48  }
StabilizationHelper(const std::string &helper_name)
Definition: stab_helper.C:36
GRINS::SpalartAllmarasStabilizationHelper::~SpalartAllmarasStabilizationHelper ( )

Definition at line 50 of file spalart_allmaras_stab_helper.C.

51  {
52  return;
53  }

Member Function Documentation

libMesh::RealGradient GRINS::StabilizationHelper::compute_g ( libMesh::FEBase *  fe,
AssemblyContext c,
unsigned int  qp 
) const
inherited
Todo:
Should we inline this?

Definition at line 47 of file stab_helper.C.

50  {
51  libMesh::RealGradient g( fe->get_dxidx()[qp] + fe->get_detadx()[qp],
52  fe->get_dxidy()[qp] + fe->get_detady()[qp] );
53 
54  if( c.get_dim() == 3 )
55  {
56  g(0) += fe->get_dzetadx()[qp];
57  g(1) += fe->get_dzetady()[qp];
58  g(2) = fe->get_dxidz()[qp] + fe->get_detadz()[qp] + fe->get_dzetadz()[qp];
59  }
60 
61  return g;
62  }
libMesh::RealTensor GRINS::StabilizationHelper::compute_G ( libMesh::FEBase *  fe,
AssemblyContext c,
unsigned int  qp 
) const
inherited
Todo:
Should we inline this?

Definition at line 64 of file stab_helper.C.

67  {
68  libMesh::Real dxidx = fe->get_dxidx()[qp];
69  libMesh::Real dxidy = fe->get_dxidy()[qp];
70 
71  libMesh::Real detadx = fe->get_detadx()[qp];
72  libMesh::Real detady = fe->get_detady()[qp];
73 
74  libMesh::RealTensor G( dxidx*dxidx + detadx*detadx,
75  dxidx*dxidy + detadx*detady,
76  0.0,
77  dxidy*dxidx + detady*detadx,
78  dxidy*dxidy + detady*detady,
79  0.0 );
80 
81  if( c.get_dim() == 3 )
82  {
83  libMesh::Real dxidz = fe->get_dxidz()[qp];
84 
85  libMesh::Real detadz = fe->get_detadz()[qp];
86 
87  libMesh::Real dzetadx = fe->get_dzetadx()[qp];
88  libMesh::Real dzetady = fe->get_dzetady()[qp];
89  libMesh::Real dzetadz = fe->get_dzetadz()[qp];
90 
91  G(0,0) += dzetadx*dzetadx;
92  G(0,1) += dzetadx*dzetady;
93  G(0,2) = dxidx*dxidz + detadx*detadz + dzetadx*dzetadz;
94  G(1,0) += dzetady*dzetadx;
95  G(1,1) += dzetady*dzetady;
96  G(1,2) = dxidy*dxidz + detady*detadz + dzetady*dzetadz;
97  G(2,0) = dxidz*dxidx + detadz*detadx + dzetadz*dzetadx;
98  G(2,1) = dxidz*dxidy + detadz*detady + dzetadz*dzetady;
99  G(2,2) = dxidz*dxidz + detadz*detadz + dzetadz*dzetadz;
100  }
101 
102  return G;
103  }
libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::compute_res_spalart_steady ( AssemblyContext context,
unsigned int  qp,
const libMesh::Real  rho,
const libMesh::Real  mu,
const libMesh::Real  distance_qp 
) const

Definition at line 68 of file spalart_allmaras_stab_helper.C.

References _dim, _flow_vars, _sa_params, _spalart_allmaras_helper, _turbulence_vars, GRINS::SpalartAllmarasParameters::destruction_fn(), GRINS::SpalartAllmarasParameters::get_cb1(), GRINS::SpalartAllmarasParameters::get_cb2(), GRINS::SpalartAllmarasParameters::get_cw1(), GRINS::SpalartAllmarasParameters::get_sigma(), GRINS::TurbulenceVariables::nu_var(), GRINS::SpalartAllmarasParameters::source_fn(), GRINS::PrimitiveFlowVariables::u_var(), GRINS::PrimitiveFlowVariables::v_var(), GRINS::SpalartAllmarasHelper::vorticity(), and GRINS::PrimitiveFlowVariables::w_var().

70  {
71  // The flow velocity
72  libMesh::Number u,v;
73  u = context.interior_value(this->_flow_vars.u_var(), qp);
74  v = context.interior_value(this->_flow_vars.v_var(), qp);
75 
76  libMesh::NumberVectorValue U(u,v);
77  if ( context.get_system().get_mesh().mesh_dimension() == 3 )
78  U(2) = context.interior_value(this->_flow_vars.w_var(), qp);
79 
80  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u_var(), qp);
81  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v_var(), qp);
82 
83  libMesh::Number nu_value = context.interior_value(this->_turbulence_vars.nu_var(), qp);
84 
85  libMesh::RealGradient grad_nu = context.fixed_interior_gradient(this->_turbulence_vars.nu_var(), qp);
86 
87  libMesh::RealTensor hess_nu = context.fixed_interior_hessian(this->_turbulence_vars.nu_var(), qp);
88 
89  // The convection term
90  libMesh::Number rhoUdotGradnu = rho*(U*grad_nu);
91 
92  // The diffusion term
93  libMesh::Number inv_sigmadivnuplusnuphysicalGradnu = (1./this->_sa_params.get_sigma())*(grad_nu*grad_nu + ((nu_value + mu)*(hess_nu(0,0) + hess_nu(1,1) + (this->_dim == 3)?hess_nu(2,2):0)) + this->_sa_params.get_cb2()*grad_nu*grad_nu);
94 
95  // The source term
96  libMesh::Real vorticity_value_qp = this->_spalart_allmaras_helper.vorticity(context, qp);
97  libMesh::Real S_tilde = this->_sa_params.source_fn(nu_value, mu, distance_qp, vorticity_value_qp);
98  libMesh::Real source_term = this->_sa_params.get_cb1()*S_tilde*nu_value;
99 
100  // The destruction term
101  libMesh::Real fw = this->_sa_params.destruction_fn(nu_value, distance_qp, S_tilde);
102  libMesh::Real destruction_term = this->_sa_params.get_cw1()*fw*pow(nu_value/distance_qp, 2.);
103 
104  return rhoUdotGradnu + source_term + inv_sigmadivnuplusnuphysicalGradnu - destruction_term;
105  }
VariableIndex nu_var() const
libMesh::Real source_fn(libMesh::Number nu, libMesh::Real mu, libMesh::Real wall_distance, libMesh::Real vorticity_value) const
libMesh::Real destruction_fn(libMesh::Number nu, libMesh::Real wall_distance, libMesh::Real S_tilde) const
libMesh::Real vorticity(AssemblyContext &context, unsigned int qp) const
unsigned int _dim
Physical dimension of problem.
void GRINS::SpalartAllmarasStabilizationHelper::compute_res_spalart_steady_and_derivs ( AssemblyContext context,
unsigned int  qp,
const libMesh::Real  rho,
const libMesh::Real  mu,
libMesh::Gradient &  res_M,
libMesh::Tensor &  d_res_M_dgradp,
libMesh::Tensor &  d_res_M_dU,
libMesh::Gradient &  d_res_Muvw_dgraduvw,
libMesh::Tensor &  d_res_Muvw_dhessuvw 
) const

Definition at line 108 of file spalart_allmaras_stab_helper.C.

116  {
117  // To be filled when we start using analytic jacobians with SA
118  libmesh_not_implemented();
119  }
libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::compute_res_spalart_transient ( AssemblyContext context,
unsigned int  qp,
const libMesh::Real  rho 
) const

Definition at line 122 of file spalart_allmaras_stab_helper.C.

References _turbulence_vars, and GRINS::TurbulenceVariables::nu_var().

123  {
124  libMesh::Number nu_dot = context.interior_value(this->_turbulence_vars.nu_var(), qp);
125 
126  return rho*nu_dot;
127  }
VariableIndex nu_var() const
void GRINS::SpalartAllmarasStabilizationHelper::compute_res_spalart_transient_and_derivs ( AssemblyContext context,
unsigned int  qp,
const libMesh::Real  rho,
libMesh::RealGradient &  res_M,
libMesh::Real &  d_res_Muvw_duvw 
) const

Definition at line 131 of file spalart_allmaras_stab_helper.C.

137  {
138  libmesh_not_implemented();
139  }
libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::compute_tau ( AssemblyContext c,
unsigned int  qp,
libMesh::Real  mat_prop_sq,
libMesh::RealGradient &  g,
libMesh::RealTensor &  G,
libMesh::Real  rho,
libMesh::Gradient  U,
bool  is_steady 
) const
inline

Definition at line 180 of file spalart_allmaras_stab_helper.h.

References _C, and _tau_factor.

Referenced by compute_tau_spalart().

188  {
189  libMesh::Real tau = (rho*U)*(G*(rho*U)) + this->_C*mat_prop_sq*G.contract(G);
190 
191  if(!is_steady)
192  tau += (2.0*rho/c.get_deltat_value())*(2.0*rho/c.get_deltat_value());
193 
194  return this->_tau_factor/std::sqrt(tau);
195  }
void GRINS::SpalartAllmarasStabilizationHelper::compute_tau_and_derivs ( AssemblyContext c,
unsigned int  qp,
libMesh::Real  mat_prop_sq,
libMesh::RealGradient &  g,
libMesh::RealTensor &  G,
libMesh::Real  rho,
libMesh::Gradient  U,
libMesh::Real &  tau,
libMesh::Real &  d_tau_d_rho,
libMesh::Gradient &  d_tau_d_U,
bool  is_steady 
) const
inline

Definition at line 200 of file spalart_allmaras_stab_helper.h.

211  {
212  libMesh::Gradient rhoU = rho*U;
213  libMesh::Gradient GrhoU = G*rhoU;
214  libMesh::Real rhoUGrhoU = rhoU * GrhoU;
215  libMesh::Real GG = G.contract(G);
216  tau = rhoUGrhoU + this->_C*mat_prop_sq*GG;
217  d_tau_d_rho = rhoUGrhoU*2/rho;
218  d_tau_d_U = 2*rho*GrhoU;
219 
220  if(!is_steady)
221  {
222  libMesh::Real two_rho_over_dt = 2*rho/c.get_deltat_value();
223  tau += two_rho_over_dt * two_rho_over_dt;
224  d_tau_d_rho += 4*two_rho_over_dt/c.get_deltat_value();
225  }
226 
227  // But what we've computed so far isn't tau; we need
228  // tau = _tau_factor/ sqrt(our_tau)
229 
230  libMesh::Real root_oldtau = std::sqrt(tau);
231  libMesh::Real d_tau_d_oldtau = -this->_tau_factor / (tau*root_oldtau) / 2;
232 
233  d_tau_d_rho = d_tau_d_oldtau * d_tau_d_rho;
234  d_tau_d_U = d_tau_d_oldtau * d_tau_d_U;
235 
236  tau = this->_tau_factor / root_oldtau;
237  }
libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::compute_tau_spalart ( AssemblyContext c,
unsigned int  qp,
libMesh::RealGradient &  g,
libMesh::RealTensor &  G,
libMesh::Real  rho,
libMesh::Gradient  U,
libMesh::Real  mu,
bool  is_steady 
) const
inline

Definition at line 147 of file spalart_allmaras_stab_helper.h.

References compute_tau().

155  {
156  return this->compute_tau( c, qp, mu*mu, g, G, rho, U, is_steady );
157  }
libMesh::Real compute_tau(AssemblyContext &c, unsigned int qp, libMesh::Real mat_prop_sq, libMesh::RealGradient &g, libMesh::RealTensor &G, libMesh::Real rho, libMesh::Gradient U, bool is_steady) const
void GRINS::SpalartAllmarasStabilizationHelper::compute_tau_spalart_and_derivs ( AssemblyContext c,
unsigned int  qp,
libMesh::RealGradient &  g,
libMesh::RealTensor &  G,
libMesh::Real  rho,
libMesh::Gradient  U,
libMesh::Real  T,
libMesh::Real &  tau_M,
libMesh::Real &  d_tau_M_d_rho,
libMesh::Gradient &  d_tau_M_d_U,
bool  is_steady 
) const
inline

Definition at line 161 of file spalart_allmaras_stab_helper.h.

172  {
173  this->compute_tau_and_derivs( c, qp, mu*mu, g, G, rho, U, tau_M,
174  d_tau_M_d_rho, d_tau_M_d_U,
175  is_steady );
176  }
void compute_tau_and_derivs(AssemblyContext &c, unsigned int qp, libMesh::Real mat_prop_sq, libMesh::RealGradient &g, libMesh::RealTensor &G, libMesh::Real rho, libMesh::Gradient U, libMesh::Real &tau, libMesh::Real &d_tau_d_rho, libMesh::Gradient &d_tau_d_U, bool is_steady) const
void GRINS::SpalartAllmarasStabilizationHelper::init ( libMesh::FEMSystem &  system)

Definition at line 55 of file spalart_allmaras_stab_helper.C.

References _dim, _flow_vars, _spalart_allmaras_helper, _turbulence_vars, GRINS::TurbulenceVariables::init(), GRINS::PrimitiveFlowVariables::init(), and GRINS::SpalartAllmarasHelper::init_variables().

56  {
57  this->_flow_vars.init(&system);
58  this->_turbulence_vars.init(&system);
59 
60  // Init the variables belonging to SA helper
62 
63  this->_dim = system.get_mesh().mesh_dimension();
64 
65  return;
66  }
virtual void init(libMesh::FEMSystem *system)
virtual void init(libMesh::FEMSystem *system)
unsigned int _dim
Physical dimension of problem.
void init_variables(libMesh::FEMSystem *system)
void GRINS::ParameterUser::register_parameter ( const std::string &  param_name,
libMesh::ParameterMultiPointer< libMesh::Number > &  param_pointer 
) const
virtualinherited

Each subclass will register its copy of an independent.

Reimplemented in GRINS::AxisymmetricHeatTransfer< Conductivity >, GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >, GRINS::IncompressibleNavierStokesBase< Viscosity >, GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >, GRINS::HeatConduction< Conductivity >, GRINS::HeatTransferBase< Conductivity >, and GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >.

Definition at line 50 of file parameter_user.C.

Referenced by GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >::register_parameter(), GRINS::HeatTransferBase< Conductivity >::register_parameter(), GRINS::HeatConduction< Conductivity >::register_parameter(), GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::register_parameter(), GRINS::IncompressibleNavierStokesBase< Viscosity >::register_parameter(), GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >::register_parameter(), and GRINS::AxisymmetricHeatTransfer< Conductivity >::register_parameter().

53  {
54  std::map<std::string, libMesh::Number*>::const_iterator it =
55  _my_parameters.find(param_name);
56 
57  if (it != _my_parameters.end())
58  {
59  std::cout << _my_name << " uses parameter " << param_name
60  << std::endl;
61  param_pointer.push_back(it->second);
62  }
63  }
std::map< std::string, libMesh::Number * > _my_parameters
void GRINS::ParameterUser::set_parameter ( libMesh::Number &  param_variable,
const GetPot &  input,
const std::string &  param_name,
libMesh::Number  param_default 
)
virtualinherited

Each subclass can simultaneously read a parameter value from.

Definition at line 35 of file parameter_user.C.

References GRINS::ParameterUser::_my_name, and GRINS::ParameterUser::_my_parameters.

Referenced by GRINS::AveragedFanAdjointStabilization< Viscosity >::AveragedFanAdjointStabilization(), GRINS::AveragedTurbineAdjointStabilization< Viscosity >::AveragedTurbineAdjointStabilization(), GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >::BoussinesqBuoyancyAdjointStabilization(), GRINS::BoussinesqBuoyancyBase::BoussinesqBuoyancyBase(), GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::BoussinesqBuoyancySPGSMStabilization(), GRINS::ConstantConductivity::ConstantConductivity(), GRINS::ConstantPrandtlConductivity::ConstantPrandtlConductivity(), GRINS::ConstantSourceFunction::ConstantSourceFunction(), GRINS::ConstantSourceTerm::ConstantSourceTerm(), GRINS::ConstantSpecificHeat::ConstantSpecificHeat(), GRINS::ConstantViscosity::ConstantViscosity(), GRINS::ElasticCable< StressStrainLaw >::ElasticCable(), GRINS::ElasticCableConstantGravity::ElasticCableConstantGravity(), GRINS::ElasticMembrane< StressStrainLaw >::ElasticMembrane(), GRINS::ElasticMembraneConstantPressure::ElasticMembraneConstantPressure(), GRINS::HeatConduction< Conductivity >::HeatConduction(), GRINS::HeatTransferBase< Conductivity >::HeatTransferBase(), GRINS::IncompressibleNavierStokesBase< Viscosity >::IncompressibleNavierStokesBase(), GRINS::AverageNusseltNumber::init(), GRINS::MooneyRivlin::MooneyRivlin(), GRINS::ReactingLowMachNavierStokesBase< Mixture, Evaluator >::ReactingLowMachNavierStokesBase(), GRINS::HookesLaw1D::read_input_options(), GRINS::HookesLaw::read_input_options(), GRINS::AxisymmetricBoussinesqBuoyancy::read_input_options(), and GRINS::VelocityDragAdjointStabilization< Viscosity >::VelocityDragAdjointStabilization().

39  {
40  param_variable = input(param_name, param_default);
41 
42  libmesh_assert_msg(!_my_parameters.count(param_name),
43  "ERROR: " << _my_name << " double-registered parameter " <<
44  param_name);
45 
46  _my_parameters[param_name] = &param_variable;
47  }
std::map< std::string, libMesh::Number * > _my_parameters

Member Data Documentation

libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::_C
protected

Definition at line 132 of file spalart_allmaras_stab_helper.h.

Referenced by compute_tau().

unsigned int GRINS::SpalartAllmarasStabilizationHelper::_dim
protected

Physical dimension of problem.

Todo:
Do we really need to cache this?

Definition at line 130 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady(), and init().

PrimitiveFlowVariables GRINS::SpalartAllmarasStabilizationHelper::_flow_vars
protected

Definition at line 134 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady(), and init().

SpalartAllmarasParameters GRINS::SpalartAllmarasStabilizationHelper::_sa_params
protected

Definition at line 140 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady().

SpalartAllmarasHelper GRINS::SpalartAllmarasStabilizationHelper::_spalart_allmaras_helper
protected

Definition at line 138 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady(), and init().

libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::_tau_factor
protected

Definition at line 132 of file spalart_allmaras_stab_helper.h.

Referenced by compute_tau().

TurbulenceVariables GRINS::SpalartAllmarasStabilizationHelper::_turbulence_vars
protected

The documentation for this class was generated from the following files:

Generated on Mon Jun 22 2015 21:32:24 for GRINS-0.6.0 by  doxygen 1.8.9.1