SpalartAllmarasDES.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "SpalartAllmarasDES.H"
27 #include "fvModels.H"
28 #include "fvConstraints.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace LESModels
35 {
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class BasicMomentumTransportModel>
41 {
42  return volScalarField::New
43  (
44  typedName("chi"),
45  nuTilda_/this->nu()
46  );
47 }
48 
49 
50 template<class BasicMomentumTransportModel>
52 (
53  const volScalarField& chi
54 ) const
55 {
56  const volScalarField chi3("chi3", pow3(chi));
57  return volScalarField::New
58  (
59  typedName("fv1"),
60  chi3/(chi3 + pow3(Cv1_))
61  );
62 }
63 
64 
65 template<class BasicMomentumTransportModel>
68 (
69  const volScalarField::Internal& chi,
70  const volScalarField::Internal& fv1
71 ) const
72 {
74  (
75  typedName("fv2"),
76  1.0 - chi/(1.0 + chi*fv1)
77  );
78 }
79 
80 
81 template<class BasicMomentumTransportModel>
84 (
85  const volTensorField::Internal& gradU
86 ) const
87 {
89  (
90  typedName("Omega"),
91  sqrt(2.0)*mag(skew(gradU))
92  );
93 }
94 
95 
96 template<class BasicMomentumTransportModel>
99 (
100  const volScalarField::Internal& chi,
101  const volScalarField::Internal& fv1,
102  const volScalarField::Internal& Omega,
103  const volScalarField::Internal& dTilda
104 ) const
105 {
107  (
108  typedName("Stilda"),
109  max
110  (
111  Omega
112  + fv2(chi, fv1)*nuTilda_()/sqr(kappa_*dTilda),
113  Cs_*Omega
114  )
115  );
116 }
117 
118 
119 template<class BasicMomentumTransportModel>
121 (
122  const volScalarField::Internal& nur,
123  const volScalarField::Internal& Omega,
124  const volScalarField::Internal& dTilda
125 ) const
126 {
128  (
129  typedName("r"),
130  min
131  (
132  nur
133  /(
134  max
135  (
136  Omega,
137  dimensionedScalar(Omega.dimensions(), small)
138  )
139  *sqr(kappa_*dTilda)
140  ),
141  scalar(10)
142  )
143  );
144 }
145 
146 
147 template<class BasicMomentumTransportModel>
150 (
151  const volScalarField::Internal& Omega,
152  const volScalarField::Internal& dTilda
153 ) const
154 {
155  const volScalarField::Internal r(this->r(nuTilda_, Omega, dTilda));
156  const volScalarField::Internal g(typedName("g"), r + Cw2_*(pow6(r) - r));
157 
159  (
160  typedName("fw"),
161  g*pow((1 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0)
162  );
163 }
164 
165 
166 template<class BasicMomentumTransportModel>
169 (
170  const volScalarField::Internal& chi,
171  const volScalarField::Internal& fv1,
172  const volTensorField::Internal& gradU
173 ) const
174 {
176  (
177  typedName("dTilda"),
178  min(CDES_*this->delta()(), this->y())
179  );
180 }
181 
182 
183 template<class BasicMomentumTransportModel>
185 (
186  const volScalarField::Internal& dTilda
187 ) const
188 {
189  if (this->mesh_.temporaryObjectCached(typedName("LESRegion")))
190  {
192  (
193  typedName("LESRegion"),
194  neg(dTilda - this->y()())
195  );
196  }
197 }
198 
199 
200 template<class BasicMomentumTransportModel>
202 (
203  const volScalarField& fv1
204 )
205 {
206  this->nut_ = nuTilda_*fv1;
207  this->nut_.correctBoundaryConditions();
208  fvConstraints::New(this->mesh_).constrain(this->nut_);
209 }
210 
211 
212 template<class BasicMomentumTransportModel>
214 {
215  correctNut(fv1(this->chi()));
216 }
217 
218 
219 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
220 
221 template<class BasicMomentumTransportModel>
223 (
224  const alphaField& alpha,
225  const rhoField& rho,
226  const volVectorField& U,
227  const surfaceScalarField& alphaRhoPhi,
228  const surfaceScalarField& phi,
229  const viscosity& viscosity,
230  const word& type
231 )
232 :
233  LESeddyViscosity<BasicMomentumTransportModel>
234  (
235  type,
236  alpha,
237  rho,
238  U,
239  alphaRhoPhi,
240  phi,
241  viscosity
242  ),
243 
244  sigmaNut_("sigmaNut", this->typeDict(type), 0.66666),
245  kappa_("kappa", this->typeDict(type), 0.41),
246  Cb1_("Cb1", this->typeDict(type), 0.1355),
247  Cb2_("Cb2", this->typeDict(type), 0.622),
248  Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
249  Cw2_("Cw2", this->typeDict(type), 0.3),
250  Cw3_("Cw3", this->typeDict(type), 2.0),
251  Cv1_("Cv1", this->typeDict(type), 7.1),
252  Cs_("Cs", this->typeDict(type), 0.3),
253  CDES_("CDES", this->typeDict(type), 0.65),
254  ck_("ck", this->typeDict(type), 0.07),
255 
256  nuTilda_
257  (
258  IOobject
259  (
260  "nuTilda",
261  this->runTime_.name(),
262  this->mesh_,
263  IOobject::MUST_READ,
264  IOobject::AUTO_WRITE
265  ),
266  this->mesh_,
267  dimensions::turbulentViscosity
268  )
269 {}
270 
271 
272 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
273 
274 template<class BasicMomentumTransportModel>
276 {
278  {
279  sigmaNut_.readIfPresent(this->typeDict());
280  kappa_.readIfPresent(*this);
281 
282  Cb1_.readIfPresent(this->typeDict());
283  Cb2_.readIfPresent(this->typeDict());
284  Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
285  Cw2_.readIfPresent(this->typeDict());
286  Cw3_.readIfPresent(this->typeDict());
287  Cv1_.readIfPresent(this->typeDict());
288  Cs_.readIfPresent(this->typeDict());
289 
290  CDES_.readIfPresent(this->typeDict());
291  ck_.readIfPresent(this->typeDict());
292 
293  return true;
294  }
295  else
296  {
297  return false;
298  }
299 }
300 
301 
302 template<class BasicMomentumTransportModel>
304 DnuTildaEff() const
305 {
306  return volScalarField::New
307  (
308  "DnuTildaEff",
309  (nuTilda_ + this->nu())/sigmaNut_
310  );
311 }
312 
313 
314 template<class BasicMomentumTransportModel>
316 {
317  const volScalarField chi(this->chi());
318  const volScalarField fv1(this->fv1(chi));
319 
320  volScalarField dTildaExtrapolated
321  (
322  IOobject
323  (
324  "dTildaExtrapolated",
325  this->mesh_.time().name(),
326  this->mesh_
327  ),
328  this->mesh_,
329  dimLength,
331  );
332  dTildaExtrapolated.internalFieldRef() =
333  dTilda(chi, fv1, fvc::grad(this->U_));
334  dTildaExtrapolated.correctBoundaryConditions();
335 
337  (
339  (
340  typedName("k"),
341  sqr(this->nut()/ck_/dTildaExtrapolated)
342  )
343  );
344 
345  const fvPatchList& patches = this->mesh_.boundary();
346  volScalarField::Boundary& kBf = tk.ref().boundaryFieldRef();
347 
349  {
350  if (isA<wallFvPatch>(patches[patchi]))
351  {
352  kBf[patchi] = 0;
353  }
354  }
355 
356  return tk;
357 }
358 
359 
360 template<class BasicMomentumTransportModel>
362 {
363  if (!this->turbulence_)
364  {
365  return;
366  }
367 
368  // Local references
369  const alphaField& alpha = this->alpha_;
370  const rhoField& rho = this->rho_;
371  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
372  const volVectorField& U = this->U_;
373  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
375  (
376  Foam::fvConstraints::New(this->mesh_)
377  );
378 
380 
381  const volScalarField chi(this->chi());
382  const volScalarField fv1(this->fv1(chi));
383 
384  tmp<volTensorField> tgradU = fvc::grad(U);
385  const volScalarField::Internal Omega(this->Omega(tgradU()));
386  const volScalarField::Internal dTilda(this->dTilda(chi, fv1, tgradU()));
387  const volScalarField::Internal Stilda
388  (
389  this->Stilda(chi, fv1, Omega, dTilda)
390  );
391  tgradU.clear();
392 
393  tmp<fvScalarMatrix> nuTildaEqn
394  (
395  fvm::ddt(alpha, rho, nuTilda_)
396  + fvm::div(alphaRhoPhi, nuTilda_)
397  - fvm::laplacian(alpha*rho*DnuTildaEff(), nuTilda_)
398  - Cb2_/sigmaNut_*alpha*rho*magSqr(fvc::grad(nuTilda_))
399  ==
400  Cb1_*alpha()*rho()*Stilda*nuTilda_()
401  - fvm::Sp
402  (
403  Cw1_*alpha()*rho()*fw(Stilda, dTilda)*nuTilda_()/sqr(dTilda),
404  nuTilda_
405  )
406  + fvModels.source(alpha, rho, nuTilda_)
407  );
408 
409  nuTildaEqn.ref().relax();
410  fvConstraints.constrain(nuTildaEqn.ref());
411  solve(nuTildaEqn);
412  fvConstraints.constrain(nuTilda_);
413  bound(nuTilda_, dimensionedScalar(nuTilda_.dimensions(), 0));
414  nuTilda_.correctBoundaryConditions();
415 
416  correctNut();
417 
418  // Optionally cache the LESRegion field
419  cacheLESRegion(dTilda);
420 }
421 
422 
423 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
424 
425 } // End namespace LESModels
426 } // End namespace Foam
427 
428 // ************************************************************************* //
scalar y
scalar delta
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
static fvConstraints & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricBoundaryField class.
Generic GeometricField class.
Internal & internalFieldRef()
Return a reference to the dimensioned internal field.
void correctBoundaryConditions()
Correct boundary field.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Eddy viscosity LES SGS model base class.
BasicMomentumTransportModel::alphaField alphaField
BasicMomentumTransportModel::rhoField rhoField
tmp< volScalarField > chi() const
tmp< volScalarField::Internal > Stilda(const volScalarField::Internal &chi, const volScalarField::Internal &fv1, const volScalarField::Internal &Omega, const volScalarField::Internal &dTilda) const
tmp< volScalarField::Internal > Omega(const volTensorField::Internal &gradU) const
virtual tmp< volScalarField > k() const
Return SGS kinetic energy.
virtual void correct()
Correct nuTilda and related properties.
tmp< volScalarField > DnuTildaEff() const
Return the effective diffusivity for nuTilda.
tmp< volScalarField > fv1(const volScalarField &chi) const
tmp< volScalarField::Internal > fv2(const volScalarField::Internal &chi, const volScalarField::Internal &fv1) const
virtual tmp< volScalarField::Internal > dTilda(const volScalarField::Internal &chi, const volScalarField::Internal &fv1, const volTensorField::Internal &gradU) const
Length scale.
SpalartAllmarasDES(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity, const word &type=typeName)
Construct from components.
virtual void cacheLESRegion(const volScalarField::Internal &dTilda) const
Cache the LES region indicator field.
tmp< volScalarField::Internal > fw(const volScalarField::Internal &Omega, const volScalarField::Internal &dTilda) const
tmp< volScalarField::Internal > r(const volScalarField::Internal &nur, const volScalarField::Internal &Omega, const volScalarField::Internal &dTilda) const
virtual bool read()
Read model coefficients if they have changed.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
virtual void correct()=0
Solve the turbulence equations and correct the turbulence viscosity.
Finite volume constraints.
Definition: fvConstraints.H:68
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
Finite volume models.
Definition: fvModels.H:69
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
A class for managing temporary objects.
Definition: tmp.H:55
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:253
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
const scalar nut
label patchi
const fvPatchList & patches
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionSet turbulentViscosity
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
Namespace for OpenFOAM.
void skew(pointPatchField< tensor > &, const pointPatchField< tensor > &)
const dimensionSet & dimLength
Definition: dimensions.C:276
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
void pow6(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:188
bool bound(volScalarField &, const dimensionedScalar &min)
Bound the given scalar field where it is below the specified min value.
Definition: bound.C:31
void pow3(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
dimensionedScalar neg(const dimensionedScalar &ds)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.