GRINS-0.7.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-2016 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
35 
36 //libMesh
37 #include "libmesh/getpot.h"
38 #include "libmesh/mesh.h"
39 #include "libmesh/fem_system.h"
40 
41 namespace GRINS
42 {
43 
45  const GetPot& input)
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())),
52  _spalart_allmaras_helper(input),
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  }
58 
60  ( const std::string &param_name, libMesh::ParameterMultiAccessor<libMesh::Number> & param_pointer)
61  const
62  {
63  ParameterUser::register_parameter(param_name, param_pointer);
64  this->_sa_params.register_parameter(param_name, param_pointer);
65  }
66 
68  {
69  return;
70  }
71 
72  void SpalartAllmarasStabilizationHelper::init( libMesh::FEMSystem& system )
73  {
74  // Init the variables belonging to SA helper
76 
77  this->_dim = system.get_mesh().mesh_dimension();
78  }
79 
81  unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, const libMesh::Real distance_qp, const bool infinite_distance) const
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  }
129 
131  ( AssemblyContext& /*context*/,
132  unsigned int /*qp*/, const libMesh::Real /*rho*/, const libMesh::Real /*mu*/,
133  libMesh::Gradient& /*res_M*/,
134  libMesh::Tensor& /*d_res_M_dgradp*/,
135  libMesh::Tensor& /*d_res_M_dU*/,
136  libMesh::Gradient& /*d_res_Muvw_dgraduvw*/,
137  libMesh::Tensor& /*d_res_Muvw_dhessuvw*/
138  ) const
139  {
140  // To be filled when we start using analytic jacobians with SA
141  libmesh_not_implemented();
142  }
143 
144 
145  libMesh::Real SpalartAllmarasStabilizationHelper::compute_res_spalart_transient( AssemblyContext& context, unsigned int qp, const libMesh::Real rho ) const
146  {
147  libMesh::Number nu_dot = context.interior_value(this->_turbulence_vars.nu(), qp);
148 
149  return rho*nu_dot;
150  }
151 
152 
154  ( AssemblyContext& /*context*/,
155  unsigned int /*qp*/,
156  const libMesh::Real /*rho*/,
157  libMesh::RealGradient& /*res_M*/,
158  libMesh::Real& /*d_res_Muvw_duvw*/
159  ) const
160  {
161  libmesh_not_implemented();
162  }
163 
164 } // 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
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
Physical dimension of problem.
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 init_variables(libMesh::FEMSystem *system)
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 Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10