GRINS-0.8.0
spalart_allmaras_stab_helper.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // This class
28 
29 // GRINS
33 #include "grins/single_variable.h"
34 
35 //libMesh
36 #include "libmesh/getpot.h"
37 #include "libmesh/mesh.h"
38 #include "libmesh/fem_system.h"
39 
40 namespace GRINS
41 {
42 
44  const GetPot& input)
45  : StabilizationHelper(helper_name),
46  _C( input("Stabilization/tau_constant_vel", input("Stabilization/tau_constant", 1.0 ) ) ),
47  _tau_factor( input("Stabilization/tau_factor_vel", input("Stabilization/tau_factor", 0.5 ) ) ),
48  _flow_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<VelocityVariable>(VariablesParsing::velocity_variable_name(input,PhysicsNaming::spalart_allmaras(),VariablesParsing::PHYSICS))),
49  _press_var(GRINSPrivate::VariableWarehouse::get_variable_subclass<PressureFEVariable>(VariablesParsing::press_variable_name(input,PhysicsNaming::spalart_allmaras(),VariablesParsing::PHYSICS))),
50  _turbulence_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<TurbulenceFEVariables>(VariablesParsing::turb_variable_name(input,PhysicsNaming::spalart_allmaras(),VariablesParsing::PHYSICS))),
51  _spalart_allmaras_helper(input),
52  _sa_params(input)
53  {
54  this->set_parameter(this->_C ,input, "Stabilization/tau_constant_vel" , this->_C );
55  this->set_parameter(this->_tau_factor ,input, "Stabilization/tau_factor_sa", this->_tau_factor );
56  }
57 
59  ( const std::string &param_name, libMesh::ParameterMultiAccessor<libMesh::Number> & param_pointer)
60  const
61  {
62  ParameterUser::register_parameter(param_name, param_pointer);
63  this->_sa_params.register_parameter(param_name, param_pointer);
64  }
65 
67  unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, const libMesh::Real distance_qp, const bool infinite_distance) const
68  {
69  // The flow velocity
70  libMesh::Number u,v;
71  u = context.interior_value(this->_flow_vars.u(), qp);
72  v = context.interior_value(this->_flow_vars.v(), qp);
73 
74  libMesh::NumberVectorValue U(u,v);
75  if ( this->_flow_vars.dim() == 3 )
76  U(2) = context.interior_value(this->_flow_vars.w(), qp);
77 
78  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
79  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
80 
81  libMesh::Number nu_value = context.interior_value(this->_turbulence_vars.nu(), qp);
82 
83  libMesh::RealGradient grad_nu = context.fixed_interior_gradient(this->_turbulence_vars.nu(), qp);
84 
85  libMesh::RealTensor hess_nu = context.fixed_interior_hessian(this->_turbulence_vars.nu(), qp);
86 
87  // The convection term
88  libMesh::Number rhoUdotGradnu = rho*(U*grad_nu);
89 
90  // The diffusion term
91  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->_flow_vars.dim() == 3)?hess_nu(2,2):0)) + this->_sa_params.get_cb2()*grad_nu*grad_nu);
92 
93  // The source term
94  libMesh::Real vorticity_value_qp = this->_spalart_allmaras_helper.vorticity(context, qp);
95  libMesh::Real S_tilde = this->_sa_params.source_fn(nu_value, mu, distance_qp, vorticity_value_qp, infinite_distance);
96  libMesh::Real source_term = this->_sa_params.get_cb1()*S_tilde*nu_value;
97 
98  libMesh::Real kappa2 = (this->_sa_params.get_kappa())*(this->_sa_params.get_kappa());
99  libMesh::Real cw1 = this->_sa_params.get_cb1()/kappa2 + (1.0 + this->_sa_params.get_cb2())/this->_sa_params.get_sigma();
100 
101  // The destruction term
102  libMesh::Real fw = this->_sa_params.destruction_fn(nu_value, distance_qp, S_tilde, infinite_distance);
103  libMesh::Real destruction_term = 0.0;
104  if(infinite_distance)
105  {
106  destruction_term = 0.0;
107  }
108  else
109  {
110  destruction_term = cw1*fw*pow(nu_value/distance_qp, 2.);
111  }
112 
113  return rhoUdotGradnu + source_term + inv_sigmadivnuplusnuphysicalGradnu - destruction_term;
114  }
115 
117  ( AssemblyContext& /*context*/,
118  unsigned int /*qp*/, const libMesh::Real /*rho*/, const libMesh::Real /*mu*/,
119  libMesh::Gradient& /*res_M*/,
120  libMesh::Tensor& /*d_res_M_dgradp*/,
121  libMesh::Tensor& /*d_res_M_dU*/,
122  libMesh::Gradient& /*d_res_Muvw_dgraduvw*/,
123  libMesh::Tensor& /*d_res_Muvw_dhessuvw*/
124  ) const
125  {
126  // To be filled when we start using analytic jacobians with SA
127  libmesh_not_implemented();
128  }
129 
130 
131  libMesh::Real SpalartAllmarasStabilizationHelper::compute_res_spalart_transient( AssemblyContext& context, unsigned int qp, const libMesh::Real rho ) const
132  {
133  libMesh::Number nu_dot = context.interior_value(this->_turbulence_vars.nu(), qp);
134 
135  return rho*nu_dot;
136  }
137 
138 
140  ( AssemblyContext& /*context*/,
141  unsigned int /*qp*/,
142  const libMesh::Real /*rho*/,
143  libMesh::RealGradient& /*res_M*/,
144  libMesh::Real& /*d_res_Muvw_duvw*/
145  ) const
146  {
147  libmesh_not_implemented();
148  }
149 
150 } // namespace GRINS
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.
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::Real source_fn(libMesh::Number nu, libMesh::Real mu, libMesh::Real wall_distance, libMesh::Real vorticity_value, bool infinite_distance) const
VariableIndex nu() const
GRINS namespace.
libMesh::Real compute_res_spalart_transient(AssemblyContext &context, unsigned int qp, const libMesh::Real rho) 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.
libMesh::Real vorticity(AssemblyContext &context, unsigned int qp) const
SpalartAllmarasStabilizationHelper(const std::string &helper_name, const GetPot &input)
libMesh::Real destruction_fn(libMesh::Number nu, libMesh::Real wall_distance, libMesh::Real S_tilde, bool infinite_distance) const
unsigned int dim() const
Number of components.
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.
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_steady(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, const libMesh::Real distance_qp, const bool infinite_distance) const

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1