GRINS-0.6.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-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 #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"
35 
36 //Utils
38 
39 // libMesh foward declarations
40 class GetPot;
41 
42 namespace GRINS
43 {
45  {
46  public:
47 
48  SpalartAllmarasStabilizationHelper( const std::string& helper_name, const GetPot& input );
49 
51 
52  void init( libMesh::FEMSystem& system );
53 
54 
55  libMesh::Real compute_tau_spalart( AssemblyContext& c,
56  unsigned int qp,
57  libMesh::RealGradient& g,
58  libMesh::RealTensor& G,
59  libMesh::Real rho,
60  libMesh::Gradient U,
61  libMesh::Real mu,
62  bool is_steady ) const;
63 
65  unsigned int qp,
66  libMesh::RealGradient& g,
67  libMesh::RealTensor& G,
68  libMesh::Real rho,
69  libMesh::Gradient U,
70  libMesh::Real T,
71  libMesh::Real &tau_M,
72  libMesh::Real &d_tau_M_d_rho,
73  libMesh::Gradient &d_tau_M_d_U,
74  bool is_steady ) const;
75 
76  libMesh::Real compute_tau( AssemblyContext& c,
77  unsigned int qp,
78  libMesh::Real mat_prop_sq,
79  libMesh::RealGradient& g,
80  libMesh::RealTensor& G,
81  libMesh::Real rho,
82  libMesh::Gradient U,
83  bool is_steady ) const;
84 
86  unsigned int qp,
87  libMesh::Real mat_prop_sq,
88  libMesh::RealGradient& g,
89  libMesh::RealTensor& G,
90  libMesh::Real rho,
91  libMesh::Gradient U,
92  libMesh::Real& tau,
93  libMesh::Real& d_tau_d_rho,
94  libMesh::Gradient& d_tau_d_U,
95  bool is_steady ) const;
96 
97 
98  libMesh::Real compute_res_spalart_steady( AssemblyContext& context,
99  unsigned int qp,
100  const libMesh::Real rho,
101  const libMesh::Real mu,
102  const libMesh::Real distance_qp) 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  protected:
127 
129 
130  unsigned int _dim;
131 
132  libMesh::Real _C, _tau_factor;
133 
135 
137 
139 
141 
142  }; // class SpalartAllmarasStabilizationHelper
143 
144  /* ------------- Inline Functions ---------------*/
145 
146  inline
148  unsigned int qp,
149  libMesh::RealGradient& g,
150  libMesh::RealTensor& G,
151  libMesh::Real rho,
152  libMesh::Gradient U,
153  libMesh::Real mu,
154  bool is_steady ) const
155  {
156  return this->compute_tau( c, qp, mu*mu, g, G, rho, U, is_steady );
157  }
158 
159  inline void
162  unsigned int qp,
163  libMesh::RealGradient& g,
164  libMesh::RealTensor& G,
165  libMesh::Real rho,
166  libMesh::Gradient U,
167  libMesh::Real mu,
168  libMesh::Real& tau_M,
169  libMesh::Real &d_tau_M_d_rho,
170  libMesh::Gradient &d_tau_M_d_U,
171  bool is_steady ) const
172  {
173  this->compute_tau_and_derivs( c, qp, mu*mu, g, G, rho, U, tau_M,
174  d_tau_M_d_rho, d_tau_M_d_U,
175  is_steady );
176  }
177 
178 
179  inline
181  unsigned int /*qp*/,
182  libMesh::Real mat_prop_sq,
183  libMesh::RealGradient& /*g*/,
184  libMesh::RealTensor& G,
185  libMesh::Real rho,
186  libMesh::Gradient U,
187  bool is_steady ) const
188  {
189  libMesh::Real tau = (rho*U)*(G*(rho*U)) + this->_C*mat_prop_sq*G.contract(G);
190 
191  if(!is_steady)
192  tau += (2.0*rho/c.get_deltat_value())*(2.0*rho/c.get_deltat_value());
193 
194  return this->_tau_factor/std::sqrt(tau);
195  }
196 
197  inline
198  void
201  unsigned int /*qp*/,
202  libMesh::Real mat_prop_sq,
203  libMesh::RealGradient& /*g*/, // constant
204  libMesh::RealTensor& G, // constant
205  libMesh::Real rho,
206  libMesh::Gradient U,
207  libMesh::Real& tau,
208  libMesh::Real& d_tau_d_rho,
209  libMesh::Gradient& d_tau_d_U,
210  bool is_steady ) const
211  {
212  libMesh::Gradient rhoU = rho*U;
213  libMesh::Gradient GrhoU = G*rhoU;
214  libMesh::Real rhoUGrhoU = rhoU * GrhoU;
215  libMesh::Real GG = G.contract(G);
216  tau = rhoUGrhoU + this->_C*mat_prop_sq*GG;
217  d_tau_d_rho = rhoUGrhoU*2/rho;
218  d_tau_d_U = 2*rho*GrhoU;
219 
220  if(!is_steady)
221  {
222  libMesh::Real two_rho_over_dt = 2*rho/c.get_deltat_value();
223  tau += two_rho_over_dt * two_rho_over_dt;
224  d_tau_d_rho += 4*two_rho_over_dt/c.get_deltat_value();
225  }
226 
227  // But what we've computed so far isn't tau; we need
228  // tau = _tau_factor/ sqrt(our_tau)
229 
230  libMesh::Real root_oldtau = std::sqrt(tau);
231  libMesh::Real d_tau_d_oldtau = -this->_tau_factor / (tau*root_oldtau) / 2;
232 
233  d_tau_d_rho = d_tau_d_oldtau * d_tau_d_rho;
234  d_tau_d_U = d_tau_d_oldtau * d_tau_d_U;
235 
236  tau = this->_tau_factor / root_oldtau;
237  }
238 
239 }
240 #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_res_spalart_steady(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, const libMesh::Real distance_qp) 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
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
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 Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1