GRINS-0.7.0
List of all members | Public Member Functions | Protected Attributes
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 bool infinite_distance) 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
 
virtual void register_parameter (const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 
- Public Member Functions inherited from GRINS::StabilizationHelper
 StabilizationHelper (const std::string &helper_name)
 
 ~StabilizationHelper ()
 
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
 
- Public Member Functions inherited from GRINS::ParameterUser
 ParameterUser (const std::string &user_name)
 
virtual ~ParameterUser ()
 
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 set_parameter (libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void set_parameter (libMesh::ParsedFEMFunction< libMesh::Number > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void move_parameter (const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &old_func, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFEMFunction< libMesh::Number > &old_func, libMesh::ParsedFEMFunction< libMesh::Number > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 

Protected Attributes

unsigned int _dim
 Physical dimension of problem. More...
 
libMesh::Real _C
 
libMesh::Real _tau_factor
 
const VelocityFEVariables_flow_vars
 
const PressureFEVariable_press_var
 
const TurbulenceFEVariables_turbulence_vars
 
SpalartAllmarasHelper _spalart_allmaras_helper
 
SpalartAllmarasParameters _sa_params
 

Additional Inherited Members

- Static Public Attributes inherited from GRINS::ParameterUser
static std::string zero_vector_function = std::string("{0}")
 A parseable function string with LIBMESH_DIM components, all 0. More...
 

Detailed Description

Definition at line 46 of file spalart_allmaras_stab_helper.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file spalart_allmaras_stab_helper.C.

References _C, _tau_factor, and GRINS::ParameterUser::set_parameter().

46  : StabilizationHelper(helper_name),
47  _C( input("Stabilization/tau_constant_vel", input("Stabilization/tau_constant", 1.0 ) ) ),
48  _tau_factor( input("Stabilization/tau_factor_vel", input("Stabilization/tau_factor", 0.5 ) ) ),
49  _flow_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<VelocityFEVariables>(VariablesParsing::velocity_section())),
50  _press_var(GRINSPrivate::VariableWarehouse::get_variable_subclass<PressureFEVariable>(VariablesParsing::pressure_section())),
51  _turbulence_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<TurbulenceFEVariables>(VariablesParsing::turbulence_section())),
53  _sa_params(input)
54  {
55  this->set_parameter(this->_C ,input, "Stabilization/tau_constant_vel" , this->_C );
56  this->set_parameter(this->_tau_factor ,input, "Stabilization/tau_factor_sa", this->_tau_factor );
57  }
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.
static std::string velocity_section()
static std::string pressure_section()
StabilizationHelper(const std::string &helper_name)
Definition: stab_helper.C:36
static std::string turbulence_section()
GRINS::SpalartAllmarasStabilizationHelper::~SpalartAllmarasStabilizationHelper ( )

Definition at line 67 of file spalart_allmaras_stab_helper.C.

68  {
69  return;
70  }

Member Function Documentation

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 bool  infinite_distance 
) const

Definition at line 80 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_kappa(), GRINS::SpalartAllmarasParameters::get_sigma(), GRINS::TurbulenceFEVariables::nu(), GRINS::SpalartAllmarasParameters::source_fn(), GRINS::VelocityFEVariables::u(), GRINS::VelocityFEVariables::v(), GRINS::SpalartAllmarasHelper::vorticity(), and GRINS::VelocityFEVariables::w().

82  {
83  // The flow velocity
84  libMesh::Number u,v;
85  u = context.interior_value(this->_flow_vars.u(), qp);
86  v = context.interior_value(this->_flow_vars.v(), qp);
87 
88  libMesh::NumberVectorValue U(u,v);
89  if ( context.get_system().get_mesh().mesh_dimension() == 3 )
90  U(2) = context.interior_value(this->_flow_vars.w(), qp);
91 
92  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
93  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
94 
95  libMesh::Number nu_value = context.interior_value(this->_turbulence_vars.nu(), qp);
96 
97  libMesh::RealGradient grad_nu = context.fixed_interior_gradient(this->_turbulence_vars.nu(), qp);
98 
99  libMesh::RealTensor hess_nu = context.fixed_interior_hessian(this->_turbulence_vars.nu(), qp);
100 
101  // The convection term
102  libMesh::Number rhoUdotGradnu = rho*(U*grad_nu);
103 
104  // The diffusion term
105  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);
106 
107  // The source term
108  libMesh::Real vorticity_value_qp = this->_spalart_allmaras_helper.vorticity(context, qp);
109  libMesh::Real S_tilde = this->_sa_params.source_fn(nu_value, mu, distance_qp, vorticity_value_qp, infinite_distance);
110  libMesh::Real source_term = this->_sa_params.get_cb1()*S_tilde*nu_value;
111 
112  libMesh::Real kappa2 = (this->_sa_params.get_kappa())*(this->_sa_params.get_kappa());
113  libMesh::Real cw1 = this->_sa_params.get_cb1()/kappa2 + (1.0 + this->_sa_params.get_cb2())/this->_sa_params.get_sigma();
114 
115  // The destruction term
116  libMesh::Real fw = this->_sa_params.destruction_fn(nu_value, distance_qp, S_tilde, infinite_distance);
117  libMesh::Real destruction_term = 0.0;
118  if(infinite_distance)
119  {
120  destruction_term = 0.0;
121  }
122  else
123  {
124  destruction_term = cw1*fw*pow(nu_value/distance_qp, 2.);
125  }
126 
127  return rhoUdotGradnu + source_term + inv_sigmadivnuplusnuphysicalGradnu - destruction_term;
128  }
libMesh::Real source_fn(libMesh::Number nu, libMesh::Real mu, libMesh::Real wall_distance, libMesh::Real vorticity_value, bool infinite_distance) const
libMesh::Real vorticity(AssemblyContext &context, unsigned int qp) const
libMesh::Real destruction_fn(libMesh::Number nu, libMesh::Real wall_distance, libMesh::Real S_tilde, bool infinite_distance) 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 131 of file spalart_allmaras_stab_helper.C.

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

Definition at line 145 of file spalart_allmaras_stab_helper.C.

References _turbulence_vars, and GRINS::TurbulenceFEVariables::nu().

146  {
147  libMesh::Number nu_dot = context.interior_value(this->_turbulence_vars.nu(), qp);
148 
149  return rho*nu_dot;
150  }
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 154 of file spalart_allmaras_stab_helper.C.

160  {
161  libmesh_not_implemented();
162  }
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 191 of file spalart_allmaras_stab_helper.h.

References _C, and _tau_factor.

Referenced by compute_tau_spalart().

199  {
200  libMesh::Real tau = (rho*U)*(G*(rho*U)) + this->_C*mat_prop_sq*G.contract(G);
201 
202  if(!is_steady)
203  tau += (2.0*rho/c.get_deltat_value())*(2.0*rho/c.get_deltat_value());
204 
205  return this->_tau_factor/std::sqrt(tau);
206  }
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 211 of file spalart_allmaras_stab_helper.h.

222  {
223  libMesh::Gradient rhoU = rho*U;
224  libMesh::Gradient GrhoU = G*rhoU;
225  libMesh::Real rhoUGrhoU = rhoU * GrhoU;
226  libMesh::Real GG = G.contract(G);
227  tau = rhoUGrhoU + this->_C*mat_prop_sq*GG;
228  d_tau_d_rho = rhoUGrhoU*2/rho;
229  d_tau_d_U = 2*rho*GrhoU;
230 
231  if(!is_steady)
232  {
233  libMesh::Real two_rho_over_dt = 2*rho/c.get_deltat_value();
234  tau += two_rho_over_dt * two_rho_over_dt;
235  d_tau_d_rho += 4*two_rho_over_dt/c.get_deltat_value();
236  }
237 
238  // But what we've computed so far isn't tau; we need
239  // tau = _tau_factor/ sqrt(our_tau)
240 
241  libMesh::Real root_oldtau = std::sqrt(tau);
242  libMesh::Real d_tau_d_oldtau = -this->_tau_factor / (tau*root_oldtau) / 2;
243 
244  d_tau_d_rho = d_tau_d_oldtau * d_tau_d_rho;
245  d_tau_d_U = d_tau_d_oldtau * d_tau_d_U;
246 
247  tau = this->_tau_factor / root_oldtau;
248  }
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 158 of file spalart_allmaras_stab_helper.h.

References compute_tau().

166  {
167  return this->compute_tau( c, qp, mu*mu, g, G, rho, U, is_steady );
168  }
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 172 of file spalart_allmaras_stab_helper.h.

183  {
184  this->compute_tau_and_derivs( c, qp, mu*mu, g, G, rho, U, tau_M,
185  d_tau_M_d_rho, d_tau_M_d_U,
186  is_steady );
187  }
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 72 of file spalart_allmaras_stab_helper.C.

References _dim, _spalart_allmaras_helper, and GRINS::SpalartAllmarasHelper::init_variables().

73  {
74  // Init the variables belonging to SA helper
76 
77  this->_dim = system.get_mesh().mesh_dimension();
78  }
unsigned int _dim
Physical dimension of problem.
void init_variables(libMesh::FEMSystem *system)
void GRINS::SpalartAllmarasStabilizationHelper::register_parameter ( const std::string &  param_name,
libMesh::ParameterMultiAccessor< libMesh::Number > &  param_pointer 
) const
virtual

Each subclass will register its copy of an independent.

Reimplemented from GRINS::ParameterUser.

Definition at line 60 of file spalart_allmaras_stab_helper.C.

References GRINS::ParameterUser::register_parameter().

62  {
63  ParameterUser::register_parameter(param_name, param_pointer);
64  this->_sa_params.register_parameter(param_name, param_pointer);
65  }
virtual void register_parameter(const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
Each subclass will register its copy of an independent.

Member Data Documentation

libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::_C
protected
unsigned int GRINS::SpalartAllmarasStabilizationHelper::_dim
protected

Physical dimension of problem.

Todo:
Do we really need to cache this?

Definition at line 140 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady(), and init().

const VelocityFEVariables& GRINS::SpalartAllmarasStabilizationHelper::_flow_vars
protected

Definition at line 144 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady().

const PressureFEVariable& GRINS::SpalartAllmarasStabilizationHelper::_press_var
protected

Definition at line 145 of file spalart_allmaras_stab_helper.h.

SpalartAllmarasParameters GRINS::SpalartAllmarasStabilizationHelper::_sa_params
protected

Definition at line 151 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady().

SpalartAllmarasHelper GRINS::SpalartAllmarasStabilizationHelper::_spalart_allmaras_helper
protected

Definition at line 149 of file spalart_allmaras_stab_helper.h.

Referenced by compute_res_spalart_steady(), and init().

libMesh::Real GRINS::SpalartAllmarasStabilizationHelper::_tau_factor
protected
const TurbulenceFEVariables& GRINS::SpalartAllmarasStabilizationHelper::_turbulence_vars
protected

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

Generated on Thu Jun 2 2016 21:52:32 for GRINS-0.7.0 by  doxygen 1.8.10