LienCubicKE.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-2025 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 "LienCubicKE.H"
27 #include "wallDist.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(LienCubicKE, 0);
51 (
52  RASincompressibleMomentumTransportModel,
53  LienCubicKE,
54  dictionary
55 );
56 
57 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
58 
60 {
61  epsilon_ = max(epsilon_, Cmu_*sqr(k_)/(nutMaxCoeff_*nu()));
62 }
63 
64 
65 tmp<volScalarField> LienCubicKE::fMu() const
66 {
67  const volScalarField yStar(sqrt(k_)*y()/nu());
68 
69  return
70  (scalar(1) - exp(-Anu_*yStar))
71  *(scalar(1) + (2*kappa_/(pow(Cmu_, 0.75))/(yStar + small)));
72 }
73 
74 
75 tmp<volScalarField> LienCubicKE::f2() const
76 {
77  tmp<volScalarField> Rt = sqr(k_)/(nu()*epsilon_);
78 
79  return scalar(1) - 0.3*exp(-sqr(Rt));
80 }
81 
82 
83 tmp<volScalarField> LienCubicKE::E(const volScalarField& f2) const
84 {
85  const volScalarField yStar(sqrt(k_)*y()/nu());
86  const volScalarField le
87  (
88  kappa_*y()/(scalar(1) + (2*kappa_/(pow(Cmu_, 0.75))/(yStar + small)))
89  );
90 
91  return
92  (Ceps2_*pow(Cmu_, 0.75))
93  *(f2*sqrt(k_)*epsilon_/le)*exp(-AE_*sqr(yStar));
94 }
95 
96 
98 {
100 }
101 
102 
104 {
105  volSymmTensorField S(symm(gradU));
106  volTensorField W(skew(gradU));
107 
108  volScalarField sBar((k_/epsilon_)*sqrt(2.0)*mag(S));
109  volScalarField wBar((k_/epsilon_)*sqrt(2.0)*mag(W));
110 
111  volScalarField Cmu((2.0/3.0)/(Cmu1_ + sBar + Cmu2_*wBar));
112  volScalarField fMu(this->fMu());
113 
114  boundEpsilon();
115  nut_ = fMu*Cmu*sqr(k_)/epsilon_;
117 
119  fMu*k_
120  *(
121  // Quadratic terms
122  sqr(k_/epsilon_)/(Cbeta_ + pow3(sBar))
123  *(
125  + Cbeta2_*twoSymm(S&W)
126  + Cbeta3_*dev(symm(W&W))
127  )
128 
129  // Cubic terms
130  - pow3(Cmu*k_/epsilon_)
131  *(
133  + Cgamma4_*twoSymm((innerSqr(S)&W))
134  )
135  );
136 }
137 
138 
139 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
140 
142 (
143  const geometricOneField& alpha,
144  const geometricOneField& rho,
145  const volVectorField& U,
146  const surfaceScalarField& alphaRhoPhi,
147  const surfaceScalarField& phi,
148  const viscosity& viscosity,
149  const word& type
150 )
151 :
152  nonlinearEddyViscosity<incompressible::RASModel>
153  (
154  type,
155  alpha,
156  rho,
157  U,
158  alphaRhoPhi,
159  phi,
160  viscosity
161  ),
162 
163  Ceps1_("Ceps1", coeffDict(), 1.44),
164  Ceps2_("Ceps2", coeffDict(), 1.92),
165  sigmak_("sigmak", coeffDict(), 1.0),
166  sigmaEps_("sigmaEps", coeffDict(), 1.3),
167  Cmu_("Cmu", coeffDict(), 0.09),
168  Cmu1_("Cmu1", coeffDict(), 1.25),
169  Cmu2_("Cmu2", coeffDict(), 0.9),
170  Cbeta_("Cbeta", coeffDict(), 1000.0),
171  Cbeta1_("Cbeta1", coeffDict(), 3.0),
172  Cbeta2_("Cbeta2", coeffDict(), 15.0),
173  Cbeta3_("Cbeta3", coeffDict(), -19.0),
174  Cgamma1_("Cgamma1", coeffDict(), 16.0),
175  Cgamma2_("Cgamma2", coeffDict(), 16.0),
176  Cgamma4_("Cgamma4", coeffDict(), -80.0),
177  kappa_("kappa", coeffDict(), 0.41),
178  Anu_("Anu", coeffDict(), 0.0198),
179  AE_("AE", coeffDict(), 0.00375),
180 
181  k_
182  (
183  IOobject
184  (
185  this->groupName("k"),
186  runTime_.name(),
187  mesh_,
190  ),
191  mesh_
192  ),
193 
194  epsilon_
195  (
196  IOobject
197  (
198  this->groupName("epsilon"),
199  runTime_.name(),
200  mesh_,
203  ),
204  mesh_
205  )
206 {
207  bound(k_, kMin_);
208  boundEpsilon();
209 }
210 
211 
212 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
213 
214 bool LienCubicKE::read()
215 {
217  {
218  Ceps1_.readIfPresent(coeffDict());
219  Ceps2_.readIfPresent(coeffDict());
220  sigmak_.readIfPresent(coeffDict());
221  sigmaEps_.readIfPresent(coeffDict());
222  Cmu_.readIfPresent(coeffDict());
223  Cmu1_.readIfPresent(coeffDict());
224  Cmu2_.readIfPresent(coeffDict());
225  Cbeta_.readIfPresent(coeffDict());
226  Cbeta1_.readIfPresent(coeffDict());
227  Cbeta2_.readIfPresent(coeffDict());
228  Cbeta3_.readIfPresent(coeffDict());
229  Cgamma1_.readIfPresent(coeffDict());
230  Cgamma2_.readIfPresent(coeffDict());
231  Cgamma4_.readIfPresent(coeffDict());
232  kappa_.readIfPresent(coeffDict());
233  Anu_.readIfPresent(coeffDict());
234  AE_.readIfPresent(coeffDict());
235 
236  return true;
237  }
238  else
239  {
240  return false;
241  }
242 }
243 
244 
246 {
247  if (!turbulence_)
248  {
249  return;
250  }
251 
253 
254  tmp<volTensorField> tgradU = fvc::grad(U_);
255  const volTensorField& gradU = tgradU();
256 
258  (
259  GName(),
260  (nut_*twoSymm(gradU) - nonlinearStress_) && gradU
261  );
262 
263 
264  // Update epsilon and G at the wall
266 
267  const volScalarField f2(this->f2());
268 
269  // Dissipation equation
270  tmp<fvScalarMatrix> epsEqn
271  (
273  + fvm::div(phi_, epsilon_)
275  ==
278  + E(f2)
279  );
280 
281  epsEqn.ref().relax();
282  epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
283  solve(epsEqn);
284  boundEpsilon();
285 
286 
287  // Turbulent kinetic energy equation
288  tmp<fvScalarMatrix> kEqn
289  (
290  fvm::ddt(k_)
291  + fvm::div(phi_, k_)
292  - fvm::laplacian(DkEff(), k_)
293  ==
294  G
295  - fvm::Sp(epsilon_/k_, k_)
296  );
297 
298  kEqn.ref().relax();
299  solve(kEqn);
300  bound(k_, kMin_);
301 
302 
303  // Re-calculate viscosity and non-linear stress
304  correctNonlinearStress(gradU);
305 }
306 
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 } // End namespace RASModels
311 } // End namespace incompressible
312 } // End namespace Foam
313 
314 // ************************************************************************* //
scalar y
makeMomentumTransportModelTypes(geometricOneField, geometricOneField, incompressibleMomentumTransportModel)
Definition: LienCubicKE.C:32
Bound the given scalar field where it is below the specified minimum.
void updateCoeffs()
Update the boundary condition coefficients.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
bool readIfPresent(const dictionary &, const unitConversion &defaultUnits=NullObjectRef< unitConversion >())
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.
LienCubicKE(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.
virtual void correctNut()
Correct the eddy-viscosity nut.
tmp< volScalarField > DkEff() const
Return the effective diffusivity for k.
Definition: LienCubicKE.H:158
tmp< volScalarField > f2() const
tmp< volScalarField > E(const volScalarField &f2) const
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
tmp< volScalarField > DepsilonEff() const
Return the effective diffusivity for epsilon.
Definition: LienCubicKE.H:168
virtual void correctNonlinearStress(const volTensorField &gradU)
virtual bool read()
Read RASProperties dictionary.
tmp< volScalarField > fMu() const
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< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
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(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
dimensionedScalar exp(const dimensionedScalar &ds)
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
void dev(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
void twoSymm(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
SurfaceField< scalar > surfaceScalarField
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
VolField< tensor > volTensorField
Definition: volFieldsFwd.H:66
void symm(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
void pow(LagrangianPatchField< typename powProduct< Type, r >::type > &f, const LagrangianPatchField< Type > &f1)
scalarList W(const fluidMulticomponentThermo &thermo)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
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
void pow3(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
VolField< symmTensor > volSymmTensorField
Definition: volFieldsFwd.H:65
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.
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))