kOmegaSSTBase.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 "kOmegaSSTBase.H"
27 #include "fvModels.H"
28 #include "fvConstraints.H"
29 #include "bound.H"
30 #include "wallDist.H"
31 #include "fvcMeshPhi.H"
32 #include "fvmDiv.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
40 
41 template<class MomentumTransportModel, class BasicMomentumTransportModel>
42 void
44 {
45  omega_ = max(omega_, k_/(this->nutMaxCoeff_*this->nu()));
46 }
47 
48 
49 template<class MomentumTransportModel, class BasicMomentumTransportModel>
52 (
53  const volScalarField& CDkOmega
54 ) const
55 {
56  tmp<volScalarField> CDkOmegaPlus = max
57  (
58  CDkOmega,
60  );
61 
63  (
64  min
65  (
66  max
67  (
68  (scalar(1)/betaStar_)*sqrt(k_)/(omega_*this->y()),
69  scalar(500)*this->nu()/(sqr(this->y())*omega_)
70  ),
71  (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(this->y()))
72  ),
73  scalar(10)
74  );
75 
76  return tanh(pow4(arg1));
77 }
78 
79 template<class MomentumTransportModel, class BasicMomentumTransportModel>
82 {
84  (
85  max
86  (
87  (scalar(2)/betaStar_)*sqrt(k_)/(omega_*this->y()),
88  scalar(500)*this->nu()/(sqr(this->y())*omega_)
89  ),
90  scalar(100)
91  );
92 
93  return tanh(sqr(arg2));
94 }
95 
96 template<class MomentumTransportModel, class BasicMomentumTransportModel>
99 {
100  tmp<volScalarField> arg3 = min
101  (
102  150*this->nu()/(omega_*sqr(this->y())),
103  scalar(10)
104  );
105 
106  return 1 - tanh(pow4(arg3));
107 }
108 
109 template<class MomentumTransportModel, class BasicMomentumTransportModel>
112 {
113  tmp<volScalarField> f23(F2());
114 
115  if (F3_)
116  {
117  f23.ref() *= F3();
118  }
119 
120  return f23;
121 }
122 
123 
124 template<class MomentumTransportModel, class BasicMomentumTransportModel>
126 (
127  const volScalarField& S2,
128  const volScalarField& F2
129 )
130 {
131  this->nut_ = a1_*k_/max(a1_*omega_, b1_*F2*sqrt(S2));
132  this->nut_.correctBoundaryConditions();
133  fvConstraints::New(this->mesh_).constrain(this->nut_);
134 }
135 
136 
137 template<class MomentumTransportModel, class BasicMomentumTransportModel>
139 correctNut()
140 {
141  correctNut(2*magSqr(symm(fvc::grad(this->U_))), F23());
142 }
143 
144 
145 template<class MomentumTransportModel, class BasicMomentumTransportModel>
148 (
150 ) const
151 {
152  return min(G, (c1_*betaStar_)*this->k_()*this->omega_());
153 }
154 
155 
156 template<class MomentumTransportModel, class BasicMomentumTransportModel>
159 (
162 ) const
163 {
164  return betaStar_*omega_();
165 }
166 
167 
168 template<class MomentumTransportModel, class BasicMomentumTransportModel>
171 {
172  return tmp<fvScalarMatrix>
173  (
174  new fvScalarMatrix
175  (
176  k_,
177  dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
178  )
179  );
180 }
181 
182 
183 template<class MomentumTransportModel, class BasicMomentumTransportModel>
186 omegaSource() const
187 {
188  return tmp<fvScalarMatrix>
189  (
190  new fvScalarMatrix
191  (
192  omega_,
193  dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
194  )
195  );
196 }
197 
198 
199 template<class MomentumTransportModel, class BasicMomentumTransportModel>
202 (
204  const volScalarField::Internal& gamma,
206 ) const
207 {
208  return tmp<fvScalarMatrix>
209  (
210  new fvScalarMatrix
211  (
212  omega_,
213  dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
214  )
215  );
216 }
217 
218 
219 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
220 
221 template<class MomentumTransportModel, class BasicMomentumTransportModel>
223 (
224  const word& type,
225  const alphaField& alpha,
226  const rhoField& rho,
227  const volVectorField& U,
228  const surfaceScalarField& alphaRhoPhi,
229  const surfaceScalarField& phi,
231 )
232 :
233  MomentumTransportModel
234  (
235  type,
236  alpha,
237  rho,
238  U,
239  alphaRhoPhi,
240  phi,
241  viscosity
242  ),
243 
244  alphaK1_("alphaK1", this->typeDict(type), 0.85),
245  alphaK2_("alphaK2", this->typeDict(type), 1.0),
246  alphaOmega1_("alphaOmega1", this->typeDict(type), 0.5),
247  alphaOmega2_("alphaOmega2", this->typeDict(type), 0.856),
248  gamma1_("gamma1", this->typeDict(type), 5.0/9.0),
249  gamma2_("gamma2", this->typeDict(type), 0.44),
250  beta1_("beta1", this->typeDict(type), 0.075),
251  beta2_("beta2", this->typeDict(type), 0.0828),
252  betaStar_("betaStar", this->typeDict(type), 0.09),
253  a1_("a1", this->typeDict(type), 0.31),
254  b1_("b1", this->typeDict(type), 1.0),
255  c1_("c1", this->typeDict(type), 10.0),
256  F3_(this->typeDict(type).template lookupOrDefault<Switch>("F3", false)),
257 
258  k_
259  (
260  IOobject
261  (
262  this->groupName("k"),
263  this->runTime_.name(),
264  this->mesh_,
265  IOobject::MUST_READ,
266  IOobject::AUTO_WRITE
267  ),
268  this->mesh_
269  ),
270  omega_
271  (
272  IOobject
273  (
274  this->groupName("omega"),
275  this->runTime_.name(),
276  this->mesh_,
277  IOobject::MUST_READ,
278  IOobject::AUTO_WRITE
279  ),
280  this->mesh_
281  )
282 {
283  bound(k_, this->kMin_);
284  boundOmega();
285 }
286 
287 
288 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
289 
290 template<class MomentumTransportModel, class BasicMomentumTransportModel>
292 {
294  {
295  alphaK1_.readIfPresent(this->typeDict());
296  alphaK2_.readIfPresent(this->typeDict());
297  alphaOmega1_.readIfPresent(this->typeDict());
298  alphaOmega2_.readIfPresent(this->typeDict());
299  gamma1_.readIfPresent(this->typeDict());
300  gamma2_.readIfPresent(this->typeDict());
301  beta1_.readIfPresent(this->typeDict());
302  beta2_.readIfPresent(this->typeDict());
303  betaStar_.readIfPresent(this->typeDict());
304  a1_.readIfPresent(this->typeDict());
305  b1_.readIfPresent(this->typeDict());
306  c1_.readIfPresent(this->typeDict());
307  F3_.readIfPresent("F3", this->typeDict());
308 
309  return true;
310  }
311  else
312  {
313  return false;
314  }
315 }
316 
317 
318 template<class MomentumTransportModel, class BasicMomentumTransportModel>
320 {
321  if (!this->turbulence_)
322  {
323  return;
324  }
325 
326  // Local references
327  const alphaField& alpha = this->alpha_;
328  const rhoField& rho = this->rho_;
329  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
330  const volVectorField& U = this->U_;
331  volScalarField& nut = this->nut_;
332  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
334  (
335  Foam::fvConstraints::New(this->mesh_)
336  );
337 
339 
341  (
342  fvc::div(fvc::absolute(this->phi(), U))()()
343  );
344 
345  tmp<volTensorField> tgradU = fvc::grad(U);
346  volScalarField S2(2*magSqr(symm(tgradU())));
347  volScalarField::Internal GbyNu(dev(twoSymm(tgradU()())) && tgradU()());
348  volScalarField::Internal G(this->GName(), nut()*GbyNu);
349  tgradU.clear();
350 
351  // Update omega and G at the wall
352  omega_.boundaryFieldRef().updateCoeffs();
353 
354  volScalarField CDkOmega
355  (
356  (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_
357  );
358 
359  volScalarField F1(this->F1(CDkOmega));
360  volScalarField F23(this->F23());
361 
362  {
363  volScalarField::Internal gamma(this->gamma(F1));
364  volScalarField::Internal beta(this->beta(F1));
365 
366  // Turbulent frequency equation
367  tmp<fvScalarMatrix> omegaEqn
368  (
369  fvm::ddt(alpha, rho, omega_)
370  + fvm::div(alphaRhoPhi, omega_)
371  - fvm::laplacian(alpha*rho*DomegaEff(F1), omega_)
372  ==
373  alpha()*rho()*gamma
374  *min
375  (
376  GbyNu,
377  (c1_/a1_)*betaStar_*omega_()
378  *max(a1_*omega_(), b1_*F23()*sqrt(S2()))
379  )
380  - fvm::SuSp((2.0/3.0)*alpha()*rho()*gamma*divU, omega_)
381  - fvm::Sp(alpha()*rho()*beta*omega_(), omega_)
382  - fvm::SuSp
383  (
384  alpha()*rho()*(F1() - scalar(1))*CDkOmega()/omega_(),
385  omega_
386  )
387  + Qsas(S2(), gamma, beta)
388  + omegaSource()
389  + fvModels.source(alpha, rho, omega_)
390  );
391 
392  omegaEqn.ref().relax();
393  fvConstraints.constrain(omegaEqn.ref());
394  omegaEqn.ref().boundaryManipulate(omega_.boundaryFieldRef());
395  solve(omegaEqn);
396  fvConstraints.constrain(omega_);
397  boundOmega();
398  }
399 
400  // Turbulent kinetic energy equation
402  (
403  fvm::ddt(alpha, rho, k_)
404  + fvm::div(alphaRhoPhi, k_)
405  - fvm::laplacian(alpha*rho*DkEff(F1), k_)
406  ==
407  alpha()*rho()*Pk(G)
408  - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
409  - fvm::Sp(alpha()*rho()*epsilonByk(F1, F23), k_)
410  + kSource()
411  + fvModels.source(alpha, rho, k_)
412  );
413 
414  kEqn.ref().relax();
415  fvConstraints.constrain(kEqn.ref());
416  solve(kEqn);
418  bound(k_, this->kMin_);
419  boundOmega();
420 
421  correctNut(S2, F23);
422 }
423 
424 
425 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
426 
427 } // End namespace Foam
428 
429 // ************************************************************************* //
scalar y
#define F2(B, C, D)
Definition: SHA1.C:174
#define F1(B, C, D)
Definition: SHA1.C:173
#define F3(B, C, D)
Definition: SHA1.C:175
Bound the given scalar field where it is below the specified minimum.
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...
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
Finite volume constraints.
Definition: fvConstraints.H:68
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Finite volume models.
Definition: fvModels.H:69
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
BasicMomentumTransportModel::alphaField alphaField
void boundOmega()
Bound omega.
Definition: kOmegaSSTBase.C:43
virtual tmp< volScalarField > F1(const volScalarField &CDkOmega) const
Definition: kOmegaSSTBase.C:52
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
virtual tmp< volScalarField > F2() const
Definition: kOmegaSSTBase.C:81
virtual tmp< volScalarField > F23() const
virtual tmp< volScalarField::Internal > epsilonByk(const volScalarField::Internal &F1, const volScalarField::Internal &F2) const
Return epsilon/k which for standard RAS is betaStar*omega.
kOmegaSST(const word &type, const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity)
Construct from components.
virtual tmp< fvScalarMatrix > Qsas(const volScalarField::Internal &S2, const volScalarField::Internal &gamma, const volScalarField::Internal &beta) const
virtual tmp< fvScalarMatrix > omegaSource() const
virtual void correctNut()
virtual tmp< fvScalarMatrix > kSource() const
virtual tmp< volScalarField::Internal > Pk(const volScalarField::Internal &G) const
Return k production rate.
virtual bool read()
Re-read model coefficients if they have changed.
virtual tmp< volScalarField > F3() const
Definition: kOmegaSSTBase.C:98
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
Calculate the mesh motion flux and convert fluxes from absolute to relative and back.
Calculate the matrix for the divergence of the given field and flux.
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))
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp)
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
const dimensionedScalar G
Newtonian constant of gravitation.
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:202
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 > > SuSp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
Namespace for OpenFOAM.
const dimensionSet & dimless
Definition: dimensions.C:138
dimensionedScalar tanh(const dimensionedScalar &ds)
const dimensionSet & dimVolume
Definition: dimensions.C:150
void pow4(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimTime
Definition: dimensions.C:142
void dev(pointPatchField< tensor > &, const pointPatchField< tensor > &)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void symm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
bool bound(volScalarField &, const dimensionedScalar &min)
Bound the given scalar field where it is below the specified min value.
Definition: bound.C:31
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void twoSymm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
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.