SpalartAllmaras.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "SpalartAllmaras.H"
30 #include "fvOptions.H"
31 #include "bound.H"
32 #include "wallDist.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace RASModels
39 {
40 
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42 
43 template<class BasicTurbulenceModel>
45 {
46  return nuTilda_/this->nu();
47 }
48 
49 
50 template<class BasicTurbulenceModel>
52 (
53  const volScalarField& chi
54 ) const
55 {
56  const volScalarField chi3(pow3(chi));
57 
58  return chi3/(chi3 + pow3(Cv1_));
59 }
60 
61 
62 template<class BasicTurbulenceModel>
64 (
65  const volScalarField::Internal& chi,
66  const volScalarField::Internal& fv1
67 ) const
68 {
69  return scalar(1) - chi/(scalar(1) + chi*fv1);
70 }
71 
72 
73 template<class BasicTurbulenceModel>
75 const
76 {
77  const volScalarField chi(this->chi());
78 
79  const volScalarField fv1(this->fv1(chi));
80 
81  const volScalarField::Internal Omega
82  (
83  ::sqrt(scalar(2))*mag(skew(fvc::grad(this->U_)().v()))
84  );
85 
86  return
87  (
88  max
89  (
90  Omega + fv2(chi(), fv1())*nuTilda_()/sqr(kappa_*y_),
91  Cs_*Omega
92  )
93  );
94 }
95 
96 
97 template<class BasicTurbulenceModel>
99 (
100  const volScalarField::Internal& Stilda
101 ) const
102 {
104  (
105  min
106  (
107  nuTilda_
108  /(
109  max
110  (
111  Stilda,
112  dimensionedScalar(Stilda.dimensions(), SMALL)
113  )
114  *sqr(kappa_*y_)
115  ),
116  scalar(10)
117  )
118  );
119 
120  const volScalarField::Internal g(r + Cw2_*(pow6(r) - r));
121 
122  return
123  g*pow
124  (
125  (scalar(1) + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)),
126  scalar(1)/scalar(6)
127  );
128 }
129 
130 
131 template<class BasicTurbulenceModel>
133 {
134  this->nut_ = nuTilda_*this->fv1(this->chi());
135  this->nut_.correctBoundaryConditions();
136  fv::options::New(this->mesh_).correct(this->nut_);
137 
138  BasicTurbulenceModel::correctNut();
139 }
140 
141 
142 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
143 
144 template<class BasicTurbulenceModel>
146 (
147  const alphaField& alpha,
148  const rhoField& rho,
149  const volVectorField& U,
150  const surfaceScalarField& alphaRhoPhi,
151  const surfaceScalarField& phi,
152  const transportModel& transport,
153  const word& propertiesName,
154  const word& type
155 )
156 :
157  eddyViscosity<RASModel<BasicTurbulenceModel>>
158  (
159  type,
160  alpha,
161  rho,
162  U,
163  alphaRhoPhi,
164  phi,
165  transport,
166  propertiesName
167  ),
168 
169  sigmaNut_
170  (
171  dimensioned<scalar>::getOrAddToDict
172  (
173  "sigmaNut",
174  this->coeffDict_,
175  scalar(2)/scalar(3)
176  )
177  ),
178  kappa_
179  (
180  dimensioned<scalar>::getOrAddToDict
181  (
182  "kappa",
183  this->coeffDict_,
184  0.41
185  )
186  ),
187 
188  Cb1_
189  (
190  dimensioned<scalar>::getOrAddToDict
191  (
192  "Cb1",
193  this->coeffDict_,
194  0.1355
195  )
196  ),
197  Cb2_
198  (
199  dimensioned<scalar>::getOrAddToDict
200  (
201  "Cb2",
202  this->coeffDict_,
203  0.622
204  )
205  ),
206  Cw1_(Cb1_/sqr(kappa_) + (scalar(1) + Cb2_)/sigmaNut_),
207  Cw2_
208  (
209  dimensioned<scalar>::getOrAddToDict
210  (
211  "Cw2",
212  this->coeffDict_,
213  0.3
214  )
215  ),
216  Cw3_
217  (
218  dimensioned<scalar>::getOrAddToDict
219  (
220  "Cw3",
221  this->coeffDict_,
222  2.0
223  )
224  ),
225  Cv1_
226  (
227  dimensioned<scalar>::getOrAddToDict
228  (
229  "Cv1",
230  this->coeffDict_,
231  7.1
232  )
233  ),
234  Cs_
235  (
236  dimensioned<scalar>::getOrAddToDict
237  (
238  "Cs",
239  this->coeffDict_,
240  0.3
241  )
242  ),
243 
244  nuTilda_
245  (
246  IOobject
247  (
248  "nuTilda",
249  this->runTime_.timeName(),
250  this->mesh_,
251  IOobject::MUST_READ,
252  IOobject::AUTO_WRITE
253  ),
254  this->mesh_
255  ),
256 
257  y_(wallDist::New(this->mesh_).y())
258 {
259  if (type == typeName)
260  {
261  this->printCoeffs(type);
262  }
263 }
264 
265 
266 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
267 
268 template<class BasicTurbulenceModel>
270 {
272  {
273  sigmaNut_.readIfPresent(this->coeffDict());
274  kappa_.readIfPresent(this->coeffDict());
275 
276  Cb1_.readIfPresent(this->coeffDict());
277  Cb2_.readIfPresent(this->coeffDict());
278  Cw1_ = Cb1_/sqr(kappa_) + (scalar(1) + Cb2_)/sigmaNut_;
279  Cw2_.readIfPresent(this->coeffDict());
280  Cw3_.readIfPresent(this->coeffDict());
281  Cv1_.readIfPresent(this->coeffDict());
282  Cs_.readIfPresent(this->coeffDict());
283 
284  return true;
285  }
286 
287  return false;
288 }
289 
290 
291 template<class BasicTurbulenceModel>
293 {
295  (
296  "DnuTildaEff",
297  (nuTilda_ + this->nu())/sigmaNut_
298  );
299 }
300 
301 
302 template<class BasicTurbulenceModel>
304 {
305  // (B:Eq. 4.50)
306  const scalar Cmu = 0.09;
307 
309  (
310  IOobject
311  (
312  IOobject::groupName("k", this->alphaRhoPhi_.group()),
313  this->runTime_.timeName(),
314  this->mesh_
315  ),
316  cbrt(this->fv1(this->chi()))
317  *nuTilda_
318  *::sqrt(scalar(2)/Cmu)
319  *mag(symm(fvc::grad(this->U_))),
320  this->nut_.boundaryField().types()
321  );
322 }
323 
324 
325 template<class BasicTurbulenceModel>
327 {
328  // (B:Eq. 4.50)
329  const scalar Cmu = 0.09;
330  const dimensionedScalar nutSMALL(sqr(dimLength)/dimTime, SMALL);
331 
333  (
334  IOobject
335  (
336  IOobject::groupName("epsilon", this->alphaRhoPhi_.group()),
337  this->runTime_.timeName(),
338  this->mesh_
339  ),
340  pow(this->fv1(this->chi()), 0.5)
341  *pow(::sqrt(Cmu)*this->k(), 2)
342  /(nuTilda_ + this->nut_ + nutSMALL),
343  this->nut_.boundaryField().types()
344  );
345 }
346 
347 
348 template<class BasicTurbulenceModel>
350 {
351  // (P:p. 384)
352  const scalar betaStar = 0.09;
353  const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL);
354 
356  (
357  IOobject
358  (
359  IOobject::groupName("omega", this->alphaRhoPhi_.group()),
360  this->runTime_.timeName(),
361  this->mesh_
362  ),
363  this->epsilon()/(betaStar*(this->k() + k0)),
364  this->nut_.boundaryField().types()
365  );
366 }
367 
368 
369 template<class BasicTurbulenceModel>
371 {
372  if (!this->turbulence_)
373  {
374  return;
375  }
376 
377  {
378  // Construct local convenience references
379  const alphaField& alpha = this->alpha_;
380  const rhoField& rho = this->rho_;
381  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
382  fv::options& fvOptions(fv::options::New(this->mesh_));
383 
385 
386  const volScalarField::Internal Stilda(this->Stilda());
387 
388  tmp<fvScalarMatrix> nuTildaEqn
389  (
390  fvm::ddt(alpha, rho, nuTilda_)
391  + fvm::div(alphaRhoPhi, nuTilda_)
392  - fvm::laplacian(alpha*rho*DnuTildaEff(), nuTilda_)
393  - Cb2_/sigmaNut_*alpha*rho*magSqr(fvc::grad(nuTilda_))
394  ==
395  Cb1_*alpha()*rho()*Stilda*nuTilda_()
396  - fvm::Sp(Cw1_*alpha()*rho()*fw(Stilda)*nuTilda_()/sqr(y_), nuTilda_)
397  + fvOptions(alpha, rho, nuTilda_)
398  );
399 
400  nuTildaEqn.ref().relax();
401  fvOptions.constrain(nuTildaEqn.ref());
402  solve(nuTildaEqn);
403  fvOptions.correct(nuTilda_);
404  bound(nuTilda_, dimensionedScalar(nuTilda_.dimensions(), Zero));
405  nuTilda_.correctBoundaryConditions();
406  }
407 
408  // Update nut with latest available nuTilda
409  correctNut();
410 }
411 
412 
413 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
414 
415 } // End namespace RASModels
416 } // End namespace Foam
417 
418 // ************************************************************************* //
wallDist.H
Foam::RASModels::SpalartAllmaras::DnuTildaEff
tmp< volScalarField > DnuTildaEff() const
Definition: SpalartAllmaras.C:285
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:165
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:77
Foam::IOobject::AUTO_WRITE
@ AUTO_WRITE
Definition: IOobject.H:190
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:47
fvOptions.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::RASModels::SpalartAllmaras::correctNut
virtual void correctNut()
Definition: SpalartAllmaras.C:125
Foam::fv::optionList::correct
void correct(GeometricField< Type, fvPatchField, volMesh > &field)
Definition: fvOptionListTemplates.C:348
Foam::skew
dimensionedTensor skew(const dimensionedTensor &dt)
Definition: dimensionedTensor.C:131
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
SpalartAllmaras.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:57
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::RASModels::SpalartAllmaras::fv1
tmp< volScalarField > fv1(const volScalarField &chi) const
Definition: SpalartAllmaras.C:45
Foam::RASModel
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:48
Foam::fv::options::New
static options & New(const fvMesh &mesh)
Definition: fvOptions.C:96
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Definition: readThermalProperties.H:212
Foam::bound
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Definition: bound.C:28
Foam::read
bool read(const char *buf, int32_t &val)
Definition: int32.H:125
Foam::MeshObject< fvMesh, UpdateableMeshObject, wallDist >::New
static const wallDist & New(const fvMesh &mesh, Args &&... args)
Definition: MeshObject.C:41
Foam::RASModels::SpalartAllmaras::k
virtual tmp< volScalarField > k() const
Definition: SpalartAllmaras.C:296
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Definition: hashSets.C:26
Foam::RASModels::SpalartAllmaras::omega
virtual tmp< volScalarField > omega() const
Definition: SpalartAllmaras.C:342
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
nu
volScalarField & nu
Definition: readMechanicalProperties.H:176
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::pow6
dimensionedScalar pow6(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:115
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:220
Foam::fvm::Sp
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
fvOptions
fv::options & fvOptions
Definition: setRegionFluidFields.H:23
Foam::dimensioned::readIfPresent
bool readIfPresent(const dictionary &dict)
Definition: dimensionedType.C:476
Foam::wallDist
Interface to run-time selectable methods to calculate the distance-to-wall and normal-to-wall fields.
Definition: wallDist.H:71
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:82
Foam::RASModels::SpalartAllmaras::read
virtual bool read()
Definition: SpalartAllmaras.C:262
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:41
rho
rho
Definition: readInitialConditions.H:88
bound.H
Bound the given scalar field if it has gone unbounded.
correct
fvOptions correct(rho)
Foam::solve
SolverPerformance< Type > solve(faMatrix< Type > &, Istream &)
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:36
Foam::RASModels::SpalartAllmaras::correct
virtual void correct()
Definition: SpalartAllmaras.C:363
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:68
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Definition: hashSets.C:40
Foam::fv::options
Finite-volume options.
Definition: fvOptions.H:51
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::RASModel::rhoField
BasicTurbulenceModel::rhoField rhoField
Definition: RASModel.H:94
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:36
g
const uniformDimensionedVectorField & g
Definition: createFluidFields.H:26
Foam
Definition: atmBoundaryLayer.C:26
Foam::RASModel::alphaField
BasicTurbulenceModel::alphaField alphaField
Definition: RASModel.H:93
Foam::DimensionedField::dimensions
const dimensionSet & dimensions() const
Definition: DimensionedFieldI.H:42
Foam::transportModel
Base-class for all transport models used by the incompressible turbulence models.
Definition: transportModel.H:49
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Definition: DimensionedFieldReuseFunctions.H:100
Foam::RASModel::transportModel
BasicTurbulenceModel::transportModel transportModel
Definition: RASModel.H:95
U
U
Definition: pEqn.H:72
Foam::RASModels::SpalartAllmaras
Spalart-Allmaras one-transport-equation linear-eddy-viscosity turbulence closure model for incompress...
Definition: SpalartAllmaras.H:128
Foam::fvm::ddt
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:41
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:44
Foam::RASModels::SpalartAllmaras::Stilda
tmp< volScalarField::Internal > Stilda() const
Definition: SpalartAllmaras.C:67
Foam::RASModels::SpalartAllmaras::fw
tmp< volScalarField::Internal > fw(const volScalarField::Internal &Stilda) const
Definition: SpalartAllmaras.C:92
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:137
Foam::RASModels::SpalartAllmaras::chi
tmp< volScalarField > chi() const
Definition: SpalartAllmaras.C:37
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Definition: POSIX.C:717
k
label k
Definition: LISASMDCalcMethod2.H:41
Foam::tmp::New
static tmp< T > New(Args &&... args)
Foam::RASModel::printCoeffs
virtual void printCoeffs(const word &type)
Definition: RASModel.C:27
Foam::eddyViscosity
Eddy viscosity turbulence model base class.
Definition: eddyViscosity.H:51
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Foam::cbrt
dimensionedScalar cbrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:148
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:49
Foam::fvm::div
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:41
Foam::RASModels::SpalartAllmaras::epsilon
virtual tmp< volScalarField > epsilon() const
Definition: SpalartAllmaras.C:319
Foam::RASModels::SpalartAllmaras::fv2
tmp< volScalarField::Internal > fv2(const volScalarField::Internal &chi, const volScalarField::Internal &fv1) const
Definition: SpalartAllmaras.C:57
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:181