GRINS-0.6.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-2015 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 //libMesh
30 #include "libmesh/getpot.h"
31 #include "libmesh/mesh.h"
32 #include "libmesh/fem_system.h"
33 
34 namespace GRINS
35 {
36 
38  const GetPot& input)
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),
44  _spalart_allmaras_helper(input),
45  _sa_params(input)
46  {
47  return;
48  }
49 
51  {
52  return;
53  }
54 
55  void SpalartAllmarasStabilizationHelper::init( libMesh::FEMSystem& system )
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  }
67 
69  unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, const libMesh::Real distance_qp ) const
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  }
106 
108  ( AssemblyContext& /*context*/,
109  unsigned int /*qp*/, const libMesh::Real /*rho*/, const libMesh::Real /*mu*/,
110  libMesh::Gradient& /*res_M*/,
111  libMesh::Tensor& /*d_res_M_dgradp*/,
112  libMesh::Tensor& /*d_res_M_dU*/,
113  libMesh::Gradient& /*d_res_Muvw_dgraduvw*/,
114  libMesh::Tensor& /*d_res_Muvw_dhessuvw*/
115  ) const
116  {
117  // To be filled when we start using analytic jacobians with SA
118  libmesh_not_implemented();
119  }
120 
121 
122  libMesh::Real SpalartAllmarasStabilizationHelper::compute_res_spalart_transient( AssemblyContext& context, unsigned int qp, const libMesh::Real rho ) const
123  {
124  libMesh::Number nu_dot = context.interior_value(this->_turbulence_vars.nu_var(), qp);
125 
126  return rho*nu_dot;
127  }
128 
129 
131  ( AssemblyContext& /*context*/,
132  unsigned int /*qp*/,
133  const libMesh::Real /*rho*/,
134  libMesh::RealGradient& /*res_M*/,
135  libMesh::Real& /*d_res_Muvw_duvw*/
136  ) const
137  {
138  libmesh_not_implemented();
139  }
140 
141 } // namespace GRINS
VariableIndex nu_var() const
libMesh::Real source_fn(libMesh::Number nu, libMesh::Real mu, libMesh::Real wall_distance, libMesh::Real vorticity_value) 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::Real destruction_fn(libMesh::Number nu, libMesh::Real wall_distance, libMesh::Real S_tilde) 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
GRINS namespace.
virtual void init(libMesh::FEMSystem *system)
libMesh::Real compute_res_spalart_transient(AssemblyContext &context, unsigned int qp, const libMesh::Real rho) const
virtual void init(libMesh::FEMSystem *system)
libMesh::Real vorticity(AssemblyContext &context, unsigned int qp) const
SpalartAllmarasStabilizationHelper(const std::string &helper_name, const GetPot &input)
unsigned int _dim
Physical dimension of problem.
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

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