kEpsilon.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-2018 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 "kEpsilon.H"
27 #include "fvOptions.H"
28 #include "bound.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace RASModels
35 {
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class BasicTurbulenceModel>
41 {
42  this->nut_ = Cmu_*sqr(k_)/epsilon_;
43  this->nut_.correctBoundaryConditions();
44  fv::options::New(this->mesh_).correct(this->nut_);
45 
46  BasicTurbulenceModel::correctNut();
47 }
48 
49 
50 template<class BasicTurbulenceModel>
52 {
53  return tmp<fvScalarMatrix>
54  (
55  new fvScalarMatrix
56  (
57  k_,
58  dimVolume*this->rho_.dimensions()*k_.dimensions()
59  /dimTime
60  )
61  );
62 }
63 
64 
65 template<class BasicTurbulenceModel>
67 {
68  return tmp<fvScalarMatrix>
69  (
70  new fvScalarMatrix
71  (
72  epsilon_,
73  dimVolume*this->rho_.dimensions()*epsilon_.dimensions()
74  /dimTime
75  )
76  );
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81 
82 template<class BasicTurbulenceModel>
84 (
85  const alphaField& alpha,
86  const rhoField& rho,
87  const volVectorField& U,
88  const surfaceScalarField& alphaRhoPhi,
89  const surfaceScalarField& phi,
90  const transportModel& transport,
91  const word& propertiesName,
92  const word& type
93 )
94 :
96  (
97  type,
98  alpha,
99  rho,
100  U,
101  alphaRhoPhi,
102  phi,
103  transport,
104  propertiesName
105  ),
106 
107  Cmu_
108  (
110  (
111  "Cmu",
112  this->coeffDict_,
113  0.09
114  )
115  ),
116  C1_
117  (
119  (
120  "C1",
121  this->coeffDict_,
122  1.44
123  )
124  ),
125  C2_
126  (
128  (
129  "C2",
130  this->coeffDict_,
131  1.92
132  )
133  ),
134  C3_
135  (
137  (
138  "C3",
139  this->coeffDict_,
140  0
141  )
142  ),
143  sigmak_
144  (
146  (
147  "sigmak",
148  this->coeffDict_,
149  1.0
150  )
151  ),
152  sigmaEps_
153  (
155  (
156  "sigmaEps",
157  this->coeffDict_,
158  1.3
159  )
160  ),
161 
162  k_
163  (
164  IOobject
165  (
166  IOobject::groupName("k", alphaRhoPhi.group()),
167  this->runTime_.timeName(),
168  this->mesh_,
171  ),
172  this->mesh_
173  ),
174  epsilon_
175  (
176  IOobject
177  (
178  IOobject::groupName("epsilon", alphaRhoPhi.group()),
179  this->runTime_.timeName(),
180  this->mesh_,
183  ),
184  this->mesh_
185  )
186 {
187  bound(k_, this->kMin_);
188  bound(epsilon_, this->epsilonMin_);
189 
190  if (type == typeName)
191  {
192  this->printCoeffs(type);
193  }
194 }
195 
196 
197 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
198 
199 template<class BasicTurbulenceModel>
201 {
203  {
204  Cmu_.readIfPresent(this->coeffDict());
205  C1_.readIfPresent(this->coeffDict());
206  C2_.readIfPresent(this->coeffDict());
207  C3_.readIfPresent(this->coeffDict());
208  sigmak_.readIfPresent(this->coeffDict());
209  sigmaEps_.readIfPresent(this->coeffDict());
210 
211  return true;
212  }
213  else
214  {
215  return false;
216  }
217 }
218 
219 
220 template<class BasicTurbulenceModel>
222 {
223  if (!this->turbulence_)
224  {
225  return;
226  }
227 
228  // Local references
229  const alphaField& alpha = this->alpha_;
230  const rhoField& rho = this->rho_;
231  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
232  const volVectorField& U = this->U_;
233  volScalarField& nut = this->nut_;
234  fv::options& fvOptions(fv::options::New(this->mesh_));
235 
237 
239  (
240  fvc::div(fvc::absolute(this->phi(), U))().v()
241  );
242 
243  tmp<volTensorField> tgradU = fvc::grad(U);
245  (
246  this->GName(),
247  nut.v()*(dev(twoSymm(tgradU().v())) && tgradU().v())
248  );
249  tgradU.clear();
250 
251  // Update epsilon and G at the wall
252  epsilon_.boundaryFieldRef().updateCoeffs();
253 
254  // Dissipation equation
255  tmp<fvScalarMatrix> epsEqn
256  (
257  fvm::ddt(alpha, rho, epsilon_)
258  + fvm::div(alphaRhoPhi, epsilon_)
259  - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_)
260  ==
261  C1_*alpha()*rho()*G*epsilon_()/k_()
262  - fvm::SuSp(((2.0/3.0)*C1_ - C3_)*alpha()*rho()*divU, epsilon_)
263  - fvm::Sp(C2_*alpha()*rho()*epsilon_()/k_(), epsilon_)
264  + epsilonSource()
265  + fvOptions(alpha, rho, epsilon_)
266  );
267 
268  epsEqn.ref().relax();
269  fvOptions.constrain(epsEqn.ref());
270  epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
271  solve(epsEqn);
272  fvOptions.correct(epsilon_);
273  bound(epsilon_, this->epsilonMin_);
274 
275  // Turbulent kinetic energy equation
277  (
278  fvm::ddt(alpha, rho, k_)
279  + fvm::div(alphaRhoPhi, k_)
280  - fvm::laplacian(alpha*rho*DkEff(), k_)
281  ==
282  alpha()*rho()*G
283  - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
284  - fvm::Sp(alpha()*rho()*epsilon_()/k_(), k_)
285  + kSource()
286  + fvOptions(alpha, rho, k_)
287  );
288 
289  kEqn.ref().relax();
290  fvOptions.constrain(kEqn.ref());
291  solve(kEqn);
292  fvOptions.correct(k_);
293  bound(k_, this->kMin_);
294 
295  correctNut();
296 }
297 
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 } // End namespace RASModels
302 } // End namespace Foam
303 
304 // ************************************************************************* //
virtual tmp< fvScalarMatrix > epsilonSource() const
Definition: kEpsilon.C:66
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
tmp< fvMatrix< Type > > SuSp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:230
fv::options & fvOptions
surfaceScalarField & phi
void correct(GeometricField< Type, fvPatchField, volMesh > &field)
Apply correction to field.
const dimensionedScalar G
Newtonian constant of gravitation.
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
virtual tmp< fvScalarMatrix > kSource() const
Definition: kEpsilon.C:51
Generic dimensioned Type class.
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
Eddy viscosity turbulence model base class.
Definition: eddyViscosity.H:49
Finite-volume options.
Definition: fvOptions.H:52
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
BasicTurbulenceModel::alphaField alphaField
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:49
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
bool read(const char *, int32_t &)
Definition: int32IO.C:85
const Internal & v() const
Return a const-reference to the dimensioned internal field.
Definition: volFieldsI.H:31
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Standard k-epsilon turbulence model for incompressible and compressible flows including rapid distort...
Definition: kEpsilon.H:83
A class for handling words, derived from string.
Definition: word.H:59
SolverPerformance< Type > solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
static word groupName(Name name, const word &group)
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:46
void constrain(fvMatrix< Type > &eqn)
Apply constraints to equation.
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:46
Bound the given scalar field if it has gone unbounded.
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/ubuntu/OpenFOAM-6/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0));alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:72
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:481
virtual bool read()
Re-read model coefficients if they have changed.
Definition: kEpsilon.C:200
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:188
U
Definition: pEqn.H:72
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:33
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
BasicTurbulenceModel::transportModel transportModel
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
virtual void correctNut()
Definition: kEpsilon.C:40
zeroField divU
Definition: alphaSuSp.H:3
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: kEpsilon.C:221
static options & New(const fvMesh &mesh)
Construct fvOptions and register to datbase if not present.
Definition: fvOptions.C:101
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
scalar nut
Namespace for OpenFOAM.