qZeta.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 "qZeta.H"
27 #include "fvcMagSqrGradGrad.H"
28 #include "bound.H"
30 
32 (
33  geometricOneField,
34  geometricOneField,
35  incompressibleMomentumTransportModel
36 )
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 namespace incompressible
43 {
44 namespace RASModels
45 {
46 
47 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
48 
49 defineTypeNameAndDebug(qZeta, 0);
51 (
52  RASincompressibleMomentumTransportModel,
53  qZeta,
54  dictionary
55 );
56 
57 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
58 
59 void qZeta::boundZeta()
60 {
61  tmp<volScalarField> tCmuk2(Cmu_*sqr(k_));
62  zeta_ = max(zeta_, Cmu_*pow3(q_)/((2*nutMaxCoeff_)*nu()));
63 }
64 
65 
66 tmp<volScalarField> qZeta::fMu() const
67 {
68  const volScalarField Rt(q_*k_/(2.0*nu()*zeta_));
69 
70  if (anisotropic_)
71  {
72  return exp((-scalar(2.5) + Rt/20.0)/pow3(scalar(1) + Rt/130.0));
73  }
74  else
75  {
76  return
77  exp(-6.0/sqr(scalar(1) + Rt/50.0))
78  *(scalar(1) + 3.0*exp(-Rt/10.0));
79  }
80 }
81 
82 
83 tmp<volScalarField> qZeta::f2() const
84 {
85  tmp<volScalarField> Rt = q_*k_/(2.0*nu()*zeta_);
86  return scalar(1) - 0.3*exp(-sqr(Rt));
87 }
88 
89 
90 void qZeta::correctNut()
91 {
92  nut_ = Cmu_*fMu()*sqr(k_)/epsilon_;
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98 
100 (
101  const geometricOneField& alpha,
102  const geometricOneField& rho,
103  const volVectorField& U,
104  const surfaceScalarField& alphaRhoPhi,
105  const surfaceScalarField& phi,
106  const viscosity& viscosity,
107  const word& type
108 )
109 :
110  eddyViscosity<incompressible::RASModel>
111  (
112  type,
113  alpha,
114  rho,
115  U,
116  alphaRhoPhi,
117  phi,
118  viscosity
119  ),
120 
121  Cmu_
122  (
124  (
125  "Cmu",
126  coeffDict_,
127  0.09
128  )
129  ),
130  C1_
131  (
133  (
134  "C1",
135  coeffDict_,
136  1.44
137  )
138  ),
139  C2_
140  (
142  (
143  "C2",
144  coeffDict_,
145  1.92
146  )
147  ),
148  sigmaZeta_
149  (
151  (
152  "sigmaZeta",
153  coeffDict_,
154  1.3
155  )
156  ),
157  anisotropic_
158  (
160  (
161  "anisotropic",
162  coeffDict_,
163  false
164  )
165  ),
166 
167  qMin_("qMin", sqrt(kMin_)),
168 
169  k_
170  (
171  IOobject
172  (
173  this->groupName("k"),
174  runTime_.name(),
175  mesh_,
178  ),
179  mesh_
180  ),
181 
182  epsilon_
183  (
184  IOobject
185  (
186  this->groupName("epsilon"),
187  runTime_.name(),
188  mesh_,
191  ),
192  mesh_
193  ),
194 
195  q_
196  (
197  IOobject
198  (
199  this->groupName("q"),
200  runTime_.name(),
201  mesh_,
204  ),
205  sqrt(max(k_, kMin_)),
206  k_.boundaryField().types()
207  ),
208 
209  zeta_
210  (
211  IOobject
212  (
213  this->groupName("zeta"),
214  runTime_.name(),
215  mesh_,
218  ),
219  epsilon_/(2.0*q_),
220  epsilon_.boundaryField().types()
221  )
222 {
223  boundZeta();
224 
225  if (type == typeName)
226  {
227  printCoeffs(type);
228  }
229 }
230 
231 
232 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
233 
234 bool qZeta::read()
235 {
237  {
238  Cmu_.readIfPresent(coeffDict());
239  C1_.readIfPresent(coeffDict());
240  C2_.readIfPresent(coeffDict());
241  sigmaZeta_.readIfPresent(coeffDict());
242  anisotropic_.readIfPresent("anisotropic", coeffDict());
243 
244  qMin_.readIfPresent(*this);
245 
246  return true;
247  }
248  else
249  {
250  return false;
251  }
252 }
253 
254 
255 void qZeta::correct()
256 {
257  if (!turbulence_)
258  {
259  return;
260  }
261 
263 
264  volScalarField G(GName(), nut_/(2.0*q_)*2*magSqr(symm(fvc::grad(U_))));
265  const volScalarField E(nu()*nut_/q_*fvc::magSqrGradGrad(U_));
266 
267  // Zeta equation
268  tmp<fvScalarMatrix> zetaEqn
269  (
270  fvm::ddt(zeta_)
271  + fvm::div(phi_, zeta_)
273  ==
274  (2.0*C1_ - 1)*G*zeta_/q_
275  - fvm::SuSp((2.0*C2_*f2() - dimensionedScalar(1.0))*zeta_/q_, zeta_)
276  + E
277  );
278 
279  zetaEqn.ref().relax();
280  solve(zetaEqn);
281  boundZeta();
282 
283 
284  // q equation
285  tmp<fvScalarMatrix> qEqn
286  (
287  fvm::ddt(q_)
288  + fvm::div(phi_, q_)
289  - fvm::laplacian(DqEff(), q_)
290  ==
291  G - fvm::Sp(zeta_/q_, q_)
292  );
293 
294  qEqn.ref().relax();
295  solve(qEqn);
296  bound(q_, qMin_);
297  boundZeta();
298 
299  // Re-calculate k and epsilon
300  k_ = sqr(q_);
302 
303  epsilon_ = 2*q_*zeta_;
305 
306  correctNut();
307 }
308 
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 } // End namespace RASModels
313 } // End namespace incompressible
314 } // End namespace Foam
315 
316 // ************************************************************************* //
Bound the given scalar field where it is below the specified minimum.
void correctBoundaryConditions()
Correct boundary field.
bool readIfPresent(const word &, const dictionary &)
Update the value of the Switch if it is found in the dictionary.
Definition: Switch.C:135
static Switch lookupOrAddToDict(const word &, dictionary &, const Switch &defaultValue=false)
Construct from dictionary, supplying default value so that if the.
Definition: Switch.C:111
static dimensioned< scalar > lookupOrAddToDict(const word &, dictionary &, const dimensionSet &dims=dimless, const scalar &defaultValue=pTraits< scalar >::zero)
Construct from dictionary, with default value.
bool readIfPresent(const dictionary &)
Update the value of dimensioned<Type> if found in the dictionary.
virtual bool read()=0
Re-read model coefficients if they have changed.
Definition: eddyViscosity.C:74
virtual void correct()=0
Solve the turbulence equations and correct the turbulence viscosity.
virtual void correctNut()
Correct the eddy-viscosity nut.
tmp< volScalarField > f2() const
qZeta(const geometricOneField &alpha, const geometricOneField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity, const word &type=typeName)
Construct from components.
void boundZeta()
Bound epsilon and return Cmu*sqr(k) for nut.
tmp< volScalarField > DqEff() const
Return the effective diffusivity for q.
Definition: qZeta.H:142
dimensionedScalar sigmaZeta_
Definition: qZeta.H:84
dimensionedScalar qMin_
Lower limit of q.
Definition: qZeta.H:88
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
virtual bool read()
Read RASProperties dictionary.
tmp< volScalarField > fMu() const
tmp< volScalarField > DzetaEff() const
Return the effective diffusivity for epsilon.
Definition: qZeta.H:152
Calculate the magnitude of the square of the gradient of the gradient of the given volField.
U
Definition: pEqn.H:72
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionedScalar G
Newtonian constant of gravitation.
tmp< volScalarField > magSqrGradGrad(const VolField< Type > &vf)
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 > > SuSp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
Namespace for OpenFOAM.
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedScalar exp(const dimensionedScalar &ds)
VolField< vector > volVectorField
Definition: volFieldsFwd.H:65
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar pow3(const dimensionedScalar &ds)
SurfaceField< scalar > surfaceScalarField
dimensionedScalar sqrt(const dimensionedScalar &ds)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:64
defineTypeNameAndDebug(combustionModel, 0)
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
dimensioned< scalar > magSqr(const dimensioned< Type > &)
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.
makeMomentumTransportModelTypes(geometricOneField, geometricOneField, incompressibleMomentumTransportModel)
Definition: qZeta.C:32
Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.name(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Creating face flux\n"<< endl;surfaceScalarField phi(IOobject("phi", runTime.name(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(mesh.Sf().dimensions() *U.dimensions(), 0));autoPtr< viscosityModel > viscosity(viscosityModel::New(mesh))