GRINS-0.7.0
spalart_allmaras_stab_helper.h
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 #ifndef GRINS_SPALART_ALLMARAS_STAB_HELPER_H
26 #define GRINS_SPALART_ALLMARAS_STAB_HELPER_H
27 
28 // GRINS
29 #include "grins/stab_helper.h"
30 #include "grins/assembly_context.h"
33 #include "grins/parameter_user.h"
34 
35 //Utils
37 
38 // libMesh foward declarations
39 class GetPot;
40 
41 namespace GRINS
42 {
43  // Forward declarations
44  class TurbulenceFEVariables;
45 
47  {
48  public:
49 
50  SpalartAllmarasStabilizationHelper( const std::string& helper_name, const GetPot& input );
51 
53 
54  void init( libMesh::FEMSystem& system );
55 
56 
57  libMesh::Real compute_tau_spalart( AssemblyContext& c,
58  unsigned int qp,
59  libMesh::RealGradient& g,
60  libMesh::RealTensor& G,
61  libMesh::Real rho,
62  libMesh::Gradient U,
63  libMesh::Real mu,
64  bool is_steady ) const;
65 
67  unsigned int qp,
68  libMesh::RealGradient& g,
69  libMesh::RealTensor& G,
70  libMesh::Real rho,
71  libMesh::Gradient U,
72  libMesh::Real T,
73  libMesh::Real &tau_M,
74  libMesh::Real &d_tau_M_d_rho,
75  libMesh::Gradient &d_tau_M_d_U,
76  bool is_steady ) const;
77 
78  libMesh::Real compute_tau( AssemblyContext& c,
79  unsigned int qp,
80  libMesh::Real mat_prop_sq,
81  libMesh::RealGradient& g,
82  libMesh::RealTensor& G,
83  libMesh::Real rho,
84  libMesh::Gradient U,
85  bool is_steady ) const;
86 
88  unsigned int qp,
89  libMesh::Real mat_prop_sq,
90  libMesh::RealGradient& g,
91  libMesh::RealTensor& G,
92  libMesh::Real rho,
93  libMesh::Gradient U,
94  libMesh::Real& tau,
95  libMesh::Real& d_tau_d_rho,
96  libMesh::Gradient& d_tau_d_U,
97  bool is_steady ) const;
98 
99 
100  libMesh::Real compute_res_spalart_steady( AssemblyContext& context,
101  unsigned int qp,
102  const libMesh::Real rho,
103  const libMesh::Real mu,
104  const libMesh::Real distance_qp,
105  const bool infinite_distance) const;
106 
108  unsigned int qp,
109  const libMesh::Real rho,
110  const libMesh::Real mu,
111  libMesh::Gradient &res_M,
112  libMesh::Tensor &d_res_M_dgradp,
113  libMesh::Tensor &d_res_M_dU,
114  libMesh::Gradient &d_res_Muvw_dgraduvw,
115  libMesh::Tensor &d_res_Muvw_dhessuvw
116  ) const;
117 
118  libMesh::Real compute_res_spalart_transient( AssemblyContext& context,
119  unsigned int qp,
120  const libMesh::Real rho ) const;
121 
123  unsigned int qp,
124  const libMesh::Real rho,
125  libMesh::RealGradient &res_M,
126  libMesh::Real &d_res_Muvw_duvw
127  ) const;
128 
129  // Registers all parameters in this physics and in its property
130  // classes
131  virtual void register_parameter
132  ( const std::string & param_name,
134  const;
135 
136  protected:
137 
139 
140  unsigned int _dim;
141 
142  libMesh::Real _C, _tau_factor;
143 
146 
148 
150 
152 
153  }; // class SpalartAllmarasStabilizationHelper
154 
155  /* ------------- Inline Functions ---------------*/
156 
157  inline
159  unsigned int qp,
160  libMesh::RealGradient& g,
161  libMesh::RealTensor& G,
162  libMesh::Real rho,
163  libMesh::Gradient U,
164  libMesh::Real mu,
165  bool is_steady ) const
166  {
167  return this->compute_tau( c, qp, mu*mu, g, G, rho, U, is_steady );
168  }
169 
170  inline void
173  unsigned int qp,
174  libMesh::RealGradient& g,
175  libMesh::RealTensor& G,
176  libMesh::Real rho,
177  libMesh::Gradient U,
178  libMesh::Real mu,
179  libMesh::Real& tau_M,
180  libMesh::Real &d_tau_M_d_rho,
181  libMesh::Gradient &d_tau_M_d_U,
182  bool is_steady ) const
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  }
188 
189 
190  inline
192  unsigned int /*qp*/,
193  libMesh::Real mat_prop_sq,
194  libMesh::RealGradient& /*g*/,
195  libMesh::RealTensor& G,
196  libMesh::Real rho,
197  libMesh::Gradient U,
198  bool is_steady ) const
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  }
207 
208  inline
209  void
212  unsigned int /*qp*/,
213  libMesh::Real mat_prop_sq,
214  libMesh::RealGradient& /*g*/, // constant
215  libMesh::RealTensor& G, // constant
216  libMesh::Real rho,
217  libMesh::Gradient U,
218  libMesh::Real& tau,
219  libMesh::Real& d_tau_d_rho,
220  libMesh::Gradient& d_tau_d_U,
221  bool is_steady ) const
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  }
249 
250 }
251 #endif // GRINS_SPALART_ALLMARAS_STAB_HELPER_H
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 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
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.
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_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
SpalartAllmarasStabilizationHelper(const std::string &helper_name, const GetPot &input)
unsigned int _dim
Physical dimension of problem.
Encapsulate Spalart-Allmaras model parameters.
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
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

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