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  dimensions::turbulentKineticEnergy
270  ),
271  omega_
272  (
273  IOobject
274  (
275  this->groupName("omega"),
276  this->runTime_.name(),
277  this->mesh_,
278  IOobject::MUST_READ,
279  IOobject::AUTO_WRITE
280  ),
281  this->mesh_,
282  dimensions::turbulentOmega
283  )
284 {
285  bound(k_, this->kMin_);
286  boundOmega();
287 }
288 
289 
290 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
291 
292 template<class MomentumTransportModel, class BasicMomentumTransportModel>
294 {
296  {
297  alphaK1_.readIfPresent(this->typeDict());
298  alphaK2_.readIfPresent(this->typeDict());
299  alphaOmega1_.readIfPresent(this->typeDict());
300  alphaOmega2_.readIfPresent(this->typeDict());
301  gamma1_.readIfPresent(this->typeDict());
302  gamma2_.readIfPresent(this->typeDict());
303  beta1_.readIfPresent(this->typeDict());
304  beta2_.readIfPresent(this->typeDict());
305  betaStar_.readIfPresent(this->typeDict());
306  a1_.readIfPresent(this->typeDict());
307  b1_.readIfPresent(this->typeDict());
308  c1_.readIfPresent(this->typeDict());
309  F3_.readIfPresent("F3", this->typeDict());
310 
311  return true;
312  }
313  else
314  {
315  return false;
316  }
317 }
318 
319 
320 template<class MomentumTransportModel, class BasicMomentumTransportModel>
322 {
323  if (!this->turbulence_)
324  {
325  return;
326  }
327 
328  // Local references
329  const alphaField& alpha = this->alpha_;
330  const rhoField& rho = this->rho_;
331  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
332  const volVectorField& U = this->U_;
333  volScalarField& nut = this->nut_;
334  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
336  (
337  Foam::fvConstraints::New(this->mesh_)
338  );
339 
341 
343  (
344  fvc::div(fvc::absolute(this->phi(), U))()()
345  );
346 
347  tmp<volTensorField> tgradU = fvc::grad(U);
348  volScalarField S2(2*magSqr(symm(tgradU())));
349  volScalarField::Internal GbyNu(dev(twoSymm(tgradU()())) && tgradU()());
350  volScalarField::Internal G(this->GName(), nut()*GbyNu);
351  tgradU.clear();
352 
353  // Update omega and G at the wall
354  omega_.boundaryFieldRef().updateCoeffs();
355 
356  volScalarField CDkOmega
357  (
358  (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_
359  );
360 
361  volScalarField F1(this->F1(CDkOmega));
362  volScalarField F23(this->F23());
363 
364  {
365  volScalarField::Internal gamma(this->gamma(F1));
366  volScalarField::Internal beta(this->beta(F1));
367 
368  // Turbulent frequency equation
369  tmp<fvScalarMatrix> omegaEqn
370  (
371  fvm::ddt(alpha, rho, omega_)
372  + fvm::div(alphaRhoPhi, omega_)
373  - fvm::laplacian(alpha*rho*DomegaEff(F1), omega_)
374  ==
375  alpha()*rho()*gamma
376  *min
377  (
378  GbyNu,
379  (c1_/a1_)*betaStar_*omega_()
380  *max(a1_*omega_(), b1_*F23()*sqrt(S2()))
381  )
382  - fvm::SuSp((2.0/3.0)*alpha()*rho()*gamma*divU, omega_)
383  - fvm::Sp(alpha()*rho()*beta*omega_(), omega_)
384  - fvm::SuSp
385  (
386  alpha()*rho()*(F1() - scalar(1))*CDkOmega()/omega_(),
387  omega_
388  )
389  + Qsas(S2(), gamma, beta)
390  + omegaSource()
391  + fvModels.source(alpha, rho, omega_)
392  );
393 
394  omegaEqn.ref().relax();
395  fvConstraints.constrain(omegaEqn.ref());
396  omegaEqn.ref().boundaryManipulate(omega_.boundaryFieldRef());
397  solve(omegaEqn);
398  fvConstraints.constrain(omega_);
399  boundOmega();
400  }
401 
402  // Turbulent kinetic energy equation
404  (
405  fvm::ddt(alpha, rho, k_)
406  + fvm::div(alphaRhoPhi, k_)
407  - fvm::laplacian(alpha*rho*DkEff(F1), k_)
408  ==
409  alpha()*rho()*Pk(G)
410  - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
411  - fvm::Sp(alpha()*rho()*epsilonByk(F1, F23), k_)
412  + kSource()
413  + fvModels.source(alpha, rho, k_)
414  );
415 
416  kEqn.ref().relax();
417  fvConstraints.constrain(kEqn.ref());
418  solve(kEqn);
420  bound(k_, this->kMin_);
421  boundOmega();
422 
423  correctNut(S2, F23);
424 }
425 
426 
427 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
428 
429 } // End namespace Foam
430 
431 // ************************************************************************* //
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.
const dimensionSet turbulentKineticEnergy
const dimensionSet dimless
const dimensionSet turbulentOmega
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.
dimensionedScalar tanh(const dimensionedScalar &ds)
const dimensionSet & dimVolume
Definition: dimensions.C:282
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:277
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.