GRINS-0.8.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-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 #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  libMesh::Real compute_tau_spalart( AssemblyContext& c,
55  unsigned int qp,
56  libMesh::RealGradient& g,
57  libMesh::RealTensor& G,
58  libMesh::Real rho,
59  libMesh::Gradient U,
60  libMesh::Real mu,
61  bool is_steady ) const;
62 
64  unsigned int qp,
65  libMesh::RealGradient& g,
66  libMesh::RealTensor& G,
67  libMesh::Real rho,
68  libMesh::Gradient U,
69  libMesh::Real T,
70  libMesh::Real &tau_M,
71  libMesh::Real &d_tau_M_d_rho,
72  libMesh::Gradient &d_tau_M_d_U,
73  bool is_steady ) const;
74 
75  libMesh::Real compute_tau( AssemblyContext& c,
76  unsigned int qp,
77  libMesh::Real mat_prop_sq,
78  libMesh::RealGradient& g,
79  libMesh::RealTensor& G,
80  libMesh::Real rho,
81  libMesh::Gradient U,
82  bool is_steady ) const;
83 
85  unsigned int qp,
86  libMesh::Real mat_prop_sq,
87  libMesh::RealGradient& g,
88  libMesh::RealTensor& G,
89  libMesh::Real rho,
90  libMesh::Gradient U,
91  libMesh::Real& tau,
92  libMesh::Real& d_tau_d_rho,
93  libMesh::Gradient& d_tau_d_U,
94  bool is_steady ) const;
95 
96 
97  libMesh::Real compute_res_spalart_steady( AssemblyContext& context,
98  unsigned int qp,
99  const libMesh::Real rho,
100  const libMesh::Real mu,
101  const libMesh::Real distance_qp,
102  const bool infinite_distance) const;
103 
105  unsigned int qp,
106  const libMesh::Real rho,
107  const libMesh::Real mu,
108  libMesh::Gradient &res_M,
109  libMesh::Tensor &d_res_M_dgradp,
110  libMesh::Tensor &d_res_M_dU,
111  libMesh::Gradient &d_res_Muvw_dgraduvw,
112  libMesh::Tensor &d_res_Muvw_dhessuvw
113  ) const;
114 
115  libMesh::Real compute_res_spalart_transient( AssemblyContext& context,
116  unsigned int qp,
117  const libMesh::Real rho ) const;
118 
120  unsigned int qp,
121  const libMesh::Real rho,
122  libMesh::RealGradient &res_M,
123  libMesh::Real &d_res_Muvw_duvw
124  ) const;
125 
126  // Registers all parameters in this physics and in its property
127  // classes
128  virtual void register_parameter
129  ( const std::string & param_name,
131  const;
132 
133  protected:
134 
135  libMesh::Real _C, _tau_factor;
136 
139 
141 
143 
145 
146  }; // class SpalartAllmarasStabilizationHelper
147 
148  /* ------------- Inline Functions ---------------*/
149 
150  inline
152  unsigned int qp,
153  libMesh::RealGradient& g,
154  libMesh::RealTensor& G,
155  libMesh::Real rho,
156  libMesh::Gradient U,
157  libMesh::Real mu,
158  bool is_steady ) const
159  {
160  return this->compute_tau( c, qp, mu*mu, g, G, rho, U, is_steady );
161  }
162 
163  inline void
166  unsigned int qp,
167  libMesh::RealGradient& g,
168  libMesh::RealTensor& G,
169  libMesh::Real rho,
170  libMesh::Gradient U,
171  libMesh::Real mu,
172  libMesh::Real& tau_M,
173  libMesh::Real &d_tau_M_d_rho,
174  libMesh::Gradient &d_tau_M_d_U,
175  bool is_steady ) const
176  {
177  this->compute_tau_and_derivs( c, qp, mu*mu, g, G, rho, U, tau_M,
178  d_tau_M_d_rho, d_tau_M_d_U,
179  is_steady );
180  }
181 
182 
183  inline
185  unsigned int /*qp*/,
186  libMesh::Real mat_prop_sq,
187  libMesh::RealGradient& /*g*/,
188  libMesh::RealTensor& G,
189  libMesh::Real rho,
190  libMesh::Gradient U,
191  bool is_steady ) const
192  {
193  libMesh::Real tau = (rho*U)*(G*(rho*U)) + this->_C*mat_prop_sq*G.contract(G);
194 
195  if(!is_steady)
196  tau += (2.0*rho/c.get_deltat_value())*(2.0*rho/c.get_deltat_value());
197 
198  return this->_tau_factor/std::sqrt(tau);
199  }
200 
201  inline
202  void
205  unsigned int /*qp*/,
206  libMesh::Real mat_prop_sq,
207  libMesh::RealGradient& /*g*/, // constant
208  libMesh::RealTensor& G, // constant
209  libMesh::Real rho,
210  libMesh::Gradient U,
211  libMesh::Real& tau,
212  libMesh::Real& d_tau_d_rho,
213  libMesh::Gradient& d_tau_d_U,
214  bool is_steady ) const
215  {
216  libMesh::Gradient rhoU = rho*U;
217  libMesh::Gradient GrhoU = G*rhoU;
218  libMesh::Real rhoUGrhoU = rhoU * GrhoU;
219  libMesh::Real GG = G.contract(G);
220  tau = rhoUGrhoU + this->_C*mat_prop_sq*GG;
221  d_tau_d_rho = rhoUGrhoU*2/rho;
222  d_tau_d_U = 2*rho*GrhoU;
223 
224  if(!is_steady)
225  {
226  libMesh::Real two_rho_over_dt = 2*rho/c.get_deltat_value();
227  tau += two_rho_over_dt * two_rho_over_dt;
228  d_tau_d_rho += 4*two_rho_over_dt/c.get_deltat_value();
229  }
230 
231  // But what we've computed so far isn't tau; we need
232  // tau = _tau_factor/ sqrt(our_tau)
233 
234  libMesh::Real root_oldtau = std::sqrt(tau);
235  libMesh::Real d_tau_d_oldtau = -this->_tau_factor / (tau*root_oldtau) / 2;
236 
237  d_tau_d_rho = d_tau_d_oldtau * d_tau_d_rho;
238  d_tau_d_U = d_tau_d_oldtau * d_tau_d_U;
239 
240  tau = this->_tau_factor / root_oldtau;
241  }
242 
243 }
244 #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)
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 Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1