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-2023 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 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
38 
39 template<class MomentumTransportModel, class BasicMomentumTransportModel>
40 tmp<volScalarField>
42 (
43  const volScalarField& CDkOmega
44 ) const
45 {
46  tmp<volScalarField> CDkOmegaPlus = max
47  (
48  CDkOmega,
50  );
51 
52  tmp<volScalarField> arg1 = min
53  (
54  min
55  (
56  max
57  (
58  (scalar(1)/betaStar_)*sqrt(k_)/(omega_*y_),
59  scalar(500)*this->nu()/(sqr(y_)*omega_)
60  ),
61  (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(y_))
62  ),
63  scalar(10)
64  );
65 
66  return tanh(pow4(arg1));
67 }
68 
69 template<class MomentumTransportModel, class BasicMomentumTransportModel>
70 tmp<volScalarField>
72 F2() const
73 {
74  tmp<volScalarField> arg2 = min
75  (
76  max
77  (
78  (scalar(2)/betaStar_)*sqrt(k_)/(omega_*y_),
79  scalar(500)*this->nu()/(sqr(y_)*omega_)
80  ),
81  scalar(100)
82  );
83 
84  return tanh(sqr(arg2));
85 }
86 
87 template<class MomentumTransportModel, class BasicMomentumTransportModel>
88 tmp<volScalarField>
90 F3() const
91 {
92  tmp<volScalarField> arg3 = min
93  (
94  150*this->nu()/(omega_*sqr(y_)),
95  scalar(10)
96  );
97 
98  return 1 - tanh(pow4(arg3));
99 }
100 
101 template<class MomentumTransportModel, class BasicMomentumTransportModel>
102 tmp<volScalarField>
103 kOmegaSST<MomentumTransportModel, BasicMomentumTransportModel>::kOmegaSST::
104 F23() const
105 {
106  tmp<volScalarField> f23(F2());
107 
108  if (F3_)
109  {
110  f23.ref() *= F3();
111  }
112 
113  return f23;
114 }
115 
116 
117 template<class MomentumTransportModel, class BasicMomentumTransportModel>
119 (
120  const volScalarField& S2,
121  const volScalarField& F2
122 )
123 {
124  this->nut_ = a1_*k_/max(a1_*omega_, b1_*F2*sqrt(S2));
125  this->nut_.correctBoundaryConditions();
126  fvConstraints::New(this->mesh_).constrain(this->nut_);
127 }
128 
129 
130 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
131 
132 template<class MomentumTransportModel, class BasicMomentumTransportModel>
134 correctNut()
135 {
136  correctNut(2*magSqr(symm(fvc::grad(this->U_))), F23());
137 }
138 
139 
140 template<class MomentumTransportModel, class BasicMomentumTransportModel>
143 (
145 ) const
146 {
147  return min(G, (c1_*betaStar_)*this->k_()*this->omega_());
148 }
149 
150 
151 template<class MomentumTransportModel, class BasicMomentumTransportModel>
154 (
157 ) const
158 {
159  return betaStar_*omega_();
160 }
161 
162 
163 template<class MomentumTransportModel, class BasicMomentumTransportModel>
166 {
167  return tmp<fvScalarMatrix>
168  (
169  new fvScalarMatrix
170  (
171  k_,
172  dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
173  )
174  );
175 }
176 
177 
178 template<class MomentumTransportModel, class BasicMomentumTransportModel>
181 omegaSource() const
182 {
183  return tmp<fvScalarMatrix>
184  (
185  new fvScalarMatrix
186  (
187  omega_,
188  dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
189  )
190  );
191 }
192 
193 
194 template<class MomentumTransportModel, class BasicMomentumTransportModel>
197 (
198  const volScalarField::Internal& S2,
199  const volScalarField::Internal& gamma,
200  const volScalarField::Internal& beta
201 ) const
202 {
203  return tmp<fvScalarMatrix>
204  (
205  new fvScalarMatrix
206  (
207  omega_,
208  dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
209  )
210  );
211 }
212 
213 
214 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
215 
216 template<class MomentumTransportModel, class BasicMomentumTransportModel>
218 (
219  const word& type,
220  const alphaField& alpha,
221  const rhoField& rho,
223  const surfaceScalarField& alphaRhoPhi,
224  const surfaceScalarField& phi,
225  const viscosity& viscosity
226 )
227 :
228  MomentumTransportModel
229  (
231  alpha,
233  U,
234  alphaRhoPhi,
235  phi,
236  viscosity
237  ),
238 
239  alphaK1_
240  (
241  dimensioned<scalar>::lookupOrAddToDict
242  (
243  "alphaK1",
244  this->coeffDict_,
245  0.85
246  )
247  ),
248  alphaK2_
249  (
250  dimensioned<scalar>::lookupOrAddToDict
251  (
252  "alphaK2",
253  this->coeffDict_,
254  1.0
255  )
256  ),
257  alphaOmega1_
258  (
259  dimensioned<scalar>::lookupOrAddToDict
260  (
261  "alphaOmega1",
262  this->coeffDict_,
263  0.5
264  )
265  ),
266  alphaOmega2_
267  (
268  dimensioned<scalar>::lookupOrAddToDict
269  (
270  "alphaOmega2",
271  this->coeffDict_,
272  0.856
273  )
274  ),
275  gamma1_
276  (
277  dimensioned<scalar>::lookupOrAddToDict
278  (
279  "gamma1",
280  this->coeffDict_,
281  5.0/9.0
282  )
283  ),
284  gamma2_
285  (
286  dimensioned<scalar>::lookupOrAddToDict
287  (
288  "gamma2",
289  this->coeffDict_,
290  0.44
291  )
292  ),
293  beta1_
294  (
295  dimensioned<scalar>::lookupOrAddToDict
296  (
297  "beta1",
298  this->coeffDict_,
299  0.075
300  )
301  ),
302  beta2_
303  (
304  dimensioned<scalar>::lookupOrAddToDict
305  (
306  "beta2",
307  this->coeffDict_,
308  0.0828
309  )
310  ),
311  betaStar_
312  (
313  dimensioned<scalar>::lookupOrAddToDict
314  (
315  "betaStar",
316  this->coeffDict_,
317  0.09
318  )
319  ),
320  a1_
321  (
322  dimensioned<scalar>::lookupOrAddToDict
323  (
324  "a1",
325  this->coeffDict_,
326  0.31
327  )
328  ),
329  b1_
330  (
331  dimensioned<scalar>::lookupOrAddToDict
332  (
333  "b1",
334  this->coeffDict_,
335  1.0
336  )
337  ),
338  c1_
339  (
340  dimensioned<scalar>::lookupOrAddToDict
341  (
342  "c1",
343  this->coeffDict_,
344  10.0
345  )
346  ),
347  F3_
348  (
349  Switch::lookupOrAddToDict
350  (
351  "F3",
352  this->coeffDict_,
353  false
354  )
355  ),
356 
357  y_(wallDist::New(this->mesh_).y()),
358 
359  k_
360  (
361  IOobject
362  (
363  this->groupName("k"),
364  this->runTime_.name(),
365  this->mesh_,
366  IOobject::MUST_READ,
367  IOobject::AUTO_WRITE
368  ),
369  this->mesh_
370  ),
371  omega_
372  (
373  IOobject
374  (
375  this->groupName("omega"),
376  this->runTime_.name(),
377  this->mesh_,
378  IOobject::MUST_READ,
379  IOobject::AUTO_WRITE
380  ),
381  this->mesh_
382  )
383 {
384  bound(k_, this->kMin_);
385  bound(omega_, this->omegaMin_);
386 }
387 
388 
389 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
390 
391 template<class MomentumTransportModel, class BasicMomentumTransportModel>
393 {
395  {
396  alphaK1_.readIfPresent(this->coeffDict());
397  alphaK2_.readIfPresent(this->coeffDict());
398  alphaOmega1_.readIfPresent(this->coeffDict());
399  alphaOmega2_.readIfPresent(this->coeffDict());
400  gamma1_.readIfPresent(this->coeffDict());
401  gamma2_.readIfPresent(this->coeffDict());
402  beta1_.readIfPresent(this->coeffDict());
403  beta2_.readIfPresent(this->coeffDict());
404  betaStar_.readIfPresent(this->coeffDict());
405  a1_.readIfPresent(this->coeffDict());
406  b1_.readIfPresent(this->coeffDict());
407  c1_.readIfPresent(this->coeffDict());
408  F3_.readIfPresent("F3", this->coeffDict());
409 
410  return true;
411  }
412  else
413  {
414  return false;
415  }
416 }
417 
418 
419 template<class MomentumTransportModel, class BasicMomentumTransportModel>
421 {
422  if (!this->turbulence_)
423  {
424  return;
425  }
426 
427  // Local references
428  const alphaField& alpha = this->alpha_;
429  const rhoField& rho = this->rho_;
430  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
431  const volVectorField& U = this->U_;
432  volScalarField& nut = this->nut_;
433  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
435  (
436  Foam::fvConstraints::New(this->mesh_)
437  );
438 
440 
442  (
443  fvc::div(fvc::absolute(this->phi(), U))()()
444  );
445 
446  tmp<volTensorField> tgradU = fvc::grad(U);
447  volScalarField S2(2*magSqr(symm(tgradU())));
448  volScalarField::Internal GbyNu(dev(twoSymm(tgradU()())) && tgradU()());
449  volScalarField::Internal G(this->GName(), nut()*GbyNu);
450  tgradU.clear();
451 
452  // Update omega and G at the wall
453  omega_.boundaryFieldRef().updateCoeffs();
454 
455  volScalarField CDkOmega
456  (
457  (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_
458  );
459 
460  volScalarField F1(this->F1(CDkOmega));
461  volScalarField F23(this->F23());
462 
463  {
464  volScalarField::Internal gamma(this->gamma(F1));
465  volScalarField::Internal beta(this->beta(F1));
466 
467  // Turbulent frequency equation
468  tmp<fvScalarMatrix> omegaEqn
469  (
470  fvm::ddt(alpha, rho, omega_)
471  + fvm::div(alphaRhoPhi, omega_)
472  - fvm::laplacian(alpha*rho*DomegaEff(F1), omega_)
473  ==
474  alpha()*rho()*gamma
475  *min
476  (
477  GbyNu,
478  (c1_/a1_)*betaStar_*omega_()
479  *max(a1_*omega_(), b1_*F23()*sqrt(S2()))
480  )
481  - fvm::SuSp((2.0/3.0)*alpha()*rho()*gamma*divU, omega_)
482  - fvm::Sp(alpha()*rho()*beta*omega_(), omega_)
483  - fvm::SuSp
484  (
485  alpha()*rho()*(F1() - scalar(1))*CDkOmega()/omega_(),
486  omega_
487  )
488  + Qsas(S2(), gamma, beta)
489  + omegaSource()
490  + fvModels.source(alpha, rho, omega_)
491  );
492 
493  omegaEqn.ref().relax();
494  fvConstraints.constrain(omegaEqn.ref());
495  omegaEqn.ref().boundaryManipulate(omega_.boundaryFieldRef());
496  solve(omegaEqn);
497  fvConstraints.constrain(omega_);
498  bound(omega_, this->omegaMin_);
499  }
500 
501  // Turbulent kinetic energy equation
503  (
504  fvm::ddt(alpha, rho, k_)
505  + fvm::div(alphaRhoPhi, k_)
506  - fvm::laplacian(alpha*rho*DkEff(F1), k_)
507  ==
508  alpha()*rho()*Pk(G)
509  - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
510  - fvm::Sp(alpha()*rho()*epsilonByk(F1, F23), k_)
511  + kSource()
512  + fvModels.source(alpha, rho, k_)
513  );
514 
515  kEqn.ref().relax();
516  fvConstraints.constrain(kEqn.ref());
517  solve(kEqn);
519  bound(k_, this->kMin_);
520 
521  correctNut(S2, F23);
522 }
523 
524 
525 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
526 
527 } // End namespace Foam
528 
529 // ************************************************************************* //
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.
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
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:100
Generic dimensioned Type class.
Finite volume constraints.
Definition: fvConstraints.H:62
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:65
BasicMomentumTransportModel::alphaField alphaField
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
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.
BasicMomentumTransportModel::rhoField rhoField
A class for managing temporary objects.
Definition: tmp.H:55
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:237
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
Interface to run-time selectable methods to calculate the distance-to-wall and normal-to-wall fields.
Definition: wallDist.H:71
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
const scalar nut
U
Definition: pEqn.H:72
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, const SuType &Su)
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 > > Sp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > SuSp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
Namespace for OpenFOAM.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
const dimensionSet dimless
dimensionedScalar tanh(const dimensionedScalar &ds)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const dimensionSet dimTime
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionSet dimVolume
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:61
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
dimensionedScalar pow4(const dimensionedScalar &ds)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
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 complex &)
Return a string representation of a complex.
Definition: complex.C:47
dimensioned< scalar > magSqr(const 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.