realizableKE.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 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 "realizableKE.H"
27 #include "bound.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace RASModels
34 {
35 
36 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
37 
38 template<class BasicTurbulenceModel>
40 (
41  const volTensorField& gradU,
42  const volScalarField& S2,
43  const volScalarField& magS
44 )
45 {
46  tmp<volSymmTensorField> tS = dev(symm(gradU));
47  const volSymmTensorField& S = tS();
48 
50  (
51  (2*sqrt(2.0))*((S&S)&&S)
52  /(
53  magS*S2
54  + dimensionedScalar("small", dimensionSet(0, 0, -3, 0, 0), SMALL)
55  )
56  );
57 
58  tS.clear();
59 
60  volScalarField phis
61  (
62  (1.0/3.0)*acos(min(max(sqrt(6.0)*W, -scalar(1)), scalar(1)))
63  );
64  volScalarField As(sqrt(6.0)*cos(phis));
65  volScalarField Us(sqrt(S2/2.0 + magSqr(skew(gradU))));
66 
67  return 1.0/(A0_ + As*Us*k_/epsilon_);
68 }
69 
70 
71 template<class BasicTurbulenceModel>
73 (
74  const volTensorField& gradU,
75  const volScalarField& S2,
76  const volScalarField& magS
77 )
78 {
79  this->nut_ = rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
80  this->nut_.correctBoundaryConditions();
81 
82  BasicTurbulenceModel::correctNut();
83 }
84 
85 
86 template<class BasicTurbulenceModel>
88 {
89  tmp<volTensorField> tgradU = fvc::grad(this->U_);
90  volScalarField S2(2*magSqr(dev(symm(tgradU()))));
91  volScalarField magS(sqrt(S2));
92  correctNut(tgradU(), S2, magS);
93 }
94 
95 
96 template<class BasicTurbulenceModel>
98 {
99  return tmp<fvScalarMatrix>
100  (
101  new fvScalarMatrix
102  (
103  k_,
104  dimVolume*this->rho_.dimensions()*k_.dimensions()
105  /dimTime
106  )
107  );
108 }
109 
110 
111 template<class BasicTurbulenceModel>
113 {
114  return tmp<fvScalarMatrix>
115  (
116  new fvScalarMatrix
117  (
118  epsilon_,
119  dimVolume*this->rho_.dimensions()*epsilon_.dimensions()
120  /dimTime
121  )
122  );
123 }
124 
125 
126 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
127 
128 template<class BasicTurbulenceModel>
130 (
131  const alphaField& alpha,
132  const rhoField& rho,
133  const volVectorField& U,
134  const surfaceScalarField& alphaRhoPhi,
135  const surfaceScalarField& phi,
136  const transportModel& transport,
137  const word& propertiesName,
138  const word& type
139 )
140 :
142  (
143  type,
144  alpha,
145  rho,
146  U,
147  alphaRhoPhi,
148  phi,
149  transport,
150  propertiesName
151  ),
152 
153  Cmu_
154  (
156  (
157  "Cmu",
158  this->coeffDict_,
159  0.09
160  )
161  ),
162  A0_
163  (
165  (
166  "A0",
167  this->coeffDict_,
168  4.0
169  )
170  ),
171  C2_
172  (
174  (
175  "C2",
176  this->coeffDict_,
177  1.9
178  )
179  ),
180  sigmak_
181  (
183  (
184  "sigmak",
185  this->coeffDict_,
186  1.0
187  )
188  ),
189  sigmaEps_
190  (
192  (
193  "sigmaEps",
194  this->coeffDict_,
195  1.2
196  )
197  ),
198 
199  k_
200  (
201  IOobject
202  (
203  "k",
204  this->runTime_.timeName(),
205  this->mesh_,
208  ),
209  this->mesh_
210  ),
211  epsilon_
212  (
213  IOobject
214  (
215  "epsilon",
216  this->runTime_.timeName(),
217  this->mesh_,
220  ),
221  this->mesh_
222  )
223 {
224  bound(k_, this->kMin_);
225  bound(epsilon_, this->epsilonMin_);
226 
227  if (type == typeName)
228  {
229  this->printCoeffs(type);
230  }
231 }
232 
233 
234 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
235 
236 template<class BasicTurbulenceModel>
238 {
240  {
241  Cmu_.readIfPresent(this->coeffDict());
242  A0_.readIfPresent(this->coeffDict());
243  C2_.readIfPresent(this->coeffDict());
244  sigmak_.readIfPresent(this->coeffDict());
245  sigmaEps_.readIfPresent(this->coeffDict());
246 
247  return true;
248  }
249  else
250  {
251  return false;
252  }
253 }
254 
255 
256 template<class BasicTurbulenceModel>
258 {
259  if (!this->turbulence_)
260  {
261  return;
262  }
263 
264  // Local references
265  const alphaField& alpha = this->alpha_;
266  const rhoField& rho = this->rho_;
267  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
268  const volVectorField& U = this->U_;
269  volScalarField& nut = this->nut_;
270 
272 
274 
275  tmp<volTensorField> tgradU = fvc::grad(U);
276  volScalarField S2(2*magSqr(dev(symm(tgradU()))));
277  volScalarField magS(sqrt(S2));
278 
279  volScalarField eta(magS*k_/epsilon_);
280  volScalarField C1(max(eta/(scalar(5) + eta), scalar(0.43)));
281 
282  volScalarField G(this->GName(), nut*(tgradU() && dev(twoSymm(tgradU()))));
283 
284  // Update epsilon and G at the wall
285  epsilon_.boundaryField().updateCoeffs();
286 
287  // SAF: limiting thermo->nu(). If psiThermo is used rho might be < 0
288  // temporarily when p < 0 then nu < 0 which needs limiting
289  volScalarField nuLimited
290  (
291  max
292  (
293  this->nu(),
294  dimensionedScalar("zero", this->nu()().dimensions(), 0.0)
295  )
296  );
297 
298  // Dissipation equation
299  tmp<fvScalarMatrix> epsEqn
300  (
301  fvm::ddt(alpha, rho, epsilon_)
302  + fvm::div(alphaRhoPhi, epsilon_)
303  - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_)
304  ==
305  C1*alpha*rho*magS*epsilon_
306  - fvm::Sp
307  (
308  C2_*alpha*rho*epsilon_/(k_ + sqrt(nuLimited*epsilon_)),
309  epsilon_
310  )
311  + epsilonSource()
312  );
313 
314  epsEqn().relax();
315 
316  epsEqn().boundaryManipulate(epsilon_.boundaryField());
317 
318  solve(epsEqn);
319  bound(epsilon_, this->epsilonMin_);
320 
321 
322  // Turbulent kinetic energy equation
323 
325  (
326  fvm::ddt(alpha, rho, k_)
327  + fvm::div(alphaRhoPhi, k_)
328  - fvm::laplacian(alpha*rho*DkEff(), k_)
329  ==
330  alpha*rho*G
331  - fvm::SuSp(2.0/3.0*alpha*rho*divU, k_)
332  - fvm::Sp(alpha*rho*epsilon_/k_, k_)
333  + kSource()
334  );
335 
336  kEqn().relax();
337  solve(kEqn);
338  bound(k_, this->kMin_);
339 
340  correctNut(tgradU(), S2, magS);
341 }
342 
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 } // End namespace RASModels
347 } // End namespace Foam
348 
349 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
realizableKE.H
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:82
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
Foam::RASModels::realizableKE::epsilonSource
virtual tmp< fvScalarMatrix > epsilonSource() const
Definition: realizableKE.C:112
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::skew
dimensionedTensor skew(const dimensionedTensor &dt)
Definition: dimensionedTensor.C:135
Foam::IOobject::AUTO_WRITE
@ AUTO_WRITE
Definition: IOobject.H:117
Foam::constant::universal::G
const dimensionedScalar G
Newtonian constant of gravitation.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::RASModel
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:49
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::bound
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:33
Foam::RASModels::realizableKE::read
virtual bool read()
Re-read model coefficients if they have changed.
Definition: realizableKE.C:237
Foam::fvc::div
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:116
Foam::RASModels::realizableKE::rCmu
tmp< volScalarField > rCmu(const volTensorField &gradU, const volScalarField &S2, const volScalarField &magS)
Definition: realizableKE.C:40
U
U
Definition: pEqn.H:46
Foam::fvm::Sp
tmp< fvMatrix< Type > > Sp(const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)
nu
volScalarField & nu
Definition: readMechanicalProperties.H:179
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
nut
nut
Definition: createTDFields.H:71
Foam::RASModels::realizableKE::kSource
virtual tmp< fvScalarMatrix > kSource() const
Definition: realizableKE.C:97
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
bound.H
Bound the given scalar field if it has gone unbounded.
correct
fvOptions correct(rho)
Foam::fvm::SuSp
tmp< fvMatrix< Type > > SuSp(const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::RASModel::rhoField
BasicTurbulenceModel::rhoField rhoField
Definition: RASModel.H:100
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::RASModels::realizableKE::correctNut
virtual void correctNut()
Definition: realizableKE.C:87
Foam::RASModel::alphaField
BasicTurbulenceModel::alphaField alphaField
Definition: RASModel.H:99
rho
rho
Definition: pEqn.H:3
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::RASModel::transportModel
BasicTurbulenceModel::transportModel transportModel
Definition: RASModel.H:101
Foam::solve
SolverPerformance< Type > solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
Foam::fvm::ddt
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:46
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
divU
volScalarField divU(fvc::div(fvc::absolute(phi, U)))
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
Foam::acos
dimensionedScalar acos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:259
Foam::RASModels::realizableKE::realizableKE
realizableKE(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const transportModel &transport, const word &propertiesName=turbulenceModel::propertiesName, const word &type=typeName)
Construct from components.
Definition: realizableKE.C:130
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::eddyViscosity
Eddy viscosity turbulence model base class.
Definition: eddyViscosity.H:52
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::fvm::div
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:46
Foam::RASModels::realizableKE::correct
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: realizableKE.C:257
Foam::tmp::clear
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:172
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::twoSymm
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:93
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Foam::fvc::absolute
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:187
Foam::dev
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:104
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:256