LRR.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "LRR.H"
30 #include "fvOptions.H"
31 #include "wallFvPatch.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace RASModels
38 {
39 
40 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
41 
42 template<class BasicTurbulenceModel>
44 {
45  this->nut_ = this->Cmu_*sqr(k_)/epsilon_;
46  this->nut_.correctBoundaryConditions();
47  fv::options::New(this->mesh_).correct(this->nut_);
48 
49  BasicTurbulenceModel::correctNut();
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
55 template<class BasicTurbulenceModel>
57 (
58  const alphaField& alpha,
59  const rhoField& rho,
60  const volVectorField& U,
61  const surfaceScalarField& alphaRhoPhi,
62  const surfaceScalarField& phi,
63  const transportModel& transport,
64  const word& propertiesName,
65  const word& type
66 )
67 :
69  (
70  type,
71  alpha,
72  rho,
73  U,
74  alphaRhoPhi,
75  phi,
76  transport,
77  propertiesName
78  ),
79 
80  Cmu_
81  (
83  (
84  "Cmu",
85  this->coeffDict_,
86  0.09
87  )
88  ),
89  C1_
90  (
92  (
93  "C1",
94  this->coeffDict_,
95  1.8
96  )
97  ),
98  C2_
99  (
101  (
102  "C2",
103  this->coeffDict_,
104  0.6
105  )
106  ),
107  Ceps1_
108  (
110  (
111  "Ceps1",
112  this->coeffDict_,
113  1.44
114  )
115  ),
116  Ceps2_
117  (
119  (
120  "Ceps2",
121  this->coeffDict_,
122  1.92
123  )
124  ),
125  Cs_
126  (
128  (
129  "Cs",
130  this->coeffDict_,
131  0.25
132  )
133  ),
134  Ceps_
135  (
137  (
138  "Ceps",
139  this->coeffDict_,
140  0.15
141  )
142  ),
143 
144  wallReflection_
145  (
147  (
148  "wallReflection",
149  this->coeffDict_,
150  true
151  )
152  ),
153  kappa_
154  (
156  (
157  "kappa",
158  this->coeffDict_,
159  0.41
160  )
161  ),
162  Cref1_
163  (
165  (
166  "Cref1",
167  this->coeffDict_,
168  0.5
169  )
170  ),
171  Cref2_
172  (
174  (
175  "Cref2",
176  this->coeffDict_,
177  0.3
178  )
179  ),
180 
181  k_
182  (
183  IOobject
184  (
185  "k",
186  this->runTime_.timeName(),
187  this->mesh_,
190  ),
191  0.5*tr(this->R_)
192  ),
193  epsilon_
194  (
195  IOobject
196  (
197  "epsilon",
198  this->runTime_.timeName(),
199  this->mesh_,
202  ),
203  this->mesh_
204  )
205 {
206  if (type == typeName)
207  {
208  this->printCoeffs(type);
209 
210  this->boundNormalStress(this->R_);
211  bound(epsilon_, this->epsilonMin_);
212  k_ = 0.5*tr(this->R_);
213  }
214 }
215 
216 
217 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
218 
219 template<class BasicTurbulenceModel>
221 {
223  {
224  Cmu_.readIfPresent(this->coeffDict());
225  C1_.readIfPresent(this->coeffDict());
226  C2_.readIfPresent(this->coeffDict());
227  Ceps1_.readIfPresent(this->coeffDict());
228  Ceps2_.readIfPresent(this->coeffDict());
229  Cs_.readIfPresent(this->coeffDict());
230  Ceps_.readIfPresent(this->coeffDict());
231 
232  wallReflection_.readIfPresent("wallReflection", this->coeffDict());
233  kappa_.readIfPresent(this->coeffDict());
234  Cref1_.readIfPresent(this->coeffDict());
235  Cref2_.readIfPresent(this->coeffDict());
236 
237  return true;
238  }
239 
240  return false;
241 }
242 
243 
244 template<class BasicTurbulenceModel>
246 {
248  (
250  (
251  "DREff",
252  (Cs_*(this->k_/this->epsilon_))*this->R_ + I*this->nu()
253  )
254  );
255 }
256 
257 
258 template<class BasicTurbulenceModel>
260 {
262  (
264  (
265  "DepsilonEff",
266  (Ceps_*(this->k_/this->epsilon_))*this->R_ + I*this->nu()
267  )
268  );
269 }
270 
271 
272 template<class BasicTurbulenceModel>
274 {
275  if (!this->turbulence_)
276  {
277  return;
278  }
279 
280  // Local references
281  const alphaField& alpha = this->alpha_;
282  const rhoField& rho = this->rho_;
283  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
284  const volVectorField& U = this->U_;
285  volSymmTensorField& R = this->R_;
286  fv::options& fvOptions(fv::options::New(this->mesh_));
287 
289 
291  const volTensorField& gradU = tgradU();
292 
293  volSymmTensorField P(-twoSymm(R & gradU));
294  volScalarField G(this->GName(), 0.5*mag(tr(P)));
295 
296  // Update epsilon and G at the wall
297  epsilon_.boundaryFieldRef().updateCoeffs();
298 
299  // Dissipation equation
300  tmp<fvScalarMatrix> epsEqn
301  (
302  fvm::ddt(alpha, rho, epsilon_)
303  + fvm::div(alphaRhoPhi, epsilon_)
304  - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_)
305  ==
306  Ceps1_*alpha*rho*G*epsilon_/k_
307  - fvm::Sp(Ceps2_*alpha*rho*epsilon_/k_, epsilon_)
308  + fvOptions(alpha, rho, epsilon_)
309  );
310 
311  epsEqn.ref().relax();
312  fvOptions.constrain(epsEqn.ref());
313  epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
314  solve(epsEqn);
315  fvOptions.correct(epsilon_);
316  bound(epsilon_, this->epsilonMin_);
317 
318 
319  // Correct the trace of the tensorial production to be consistent
320  // with the near-wall generation from the wall-functions
321  const fvPatchList& patches = this->mesh_.boundary();
322 
323  forAll(patches, patchi)
324  {
325  const fvPatch& curPatch = patches[patchi];
326 
327  if (isA<wallFvPatch>(curPatch))
328  {
329  forAll(curPatch, facei)
330  {
331  label celli = curPatch.faceCells()[facei];
332  P[celli] *= min
333  (
334  G[celli]/(0.5*mag(tr(P[celli])) + SMALL),
335  1.0
336  );
337  }
338  }
339  }
340 
341  // Reynolds stress equation
343  (
344  fvm::ddt(alpha, rho, R)
345  + fvm::div(alphaRhoPhi, R)
346  - fvm::laplacian(alpha*rho*DREff(), R)
347  + fvm::Sp(C1_*alpha*rho*epsilon_/k_, R)
348  ==
349  alpha*rho*P
350  - (2.0/3.0*(1 - C1_)*I)*alpha*rho*epsilon_
351  - C2_*alpha*rho*dev(P)
352  + fvOptions(alpha, rho, R)
353  );
354 
355  // Optionally add wall-refection term
356  if (wallReflection_)
357  {
358  const volVectorField& n_(wallDist::New(this->mesh_).n());
359  const volScalarField& y_(wallDist::New(this->mesh_).y());
360 
361  const volSymmTensorField reflect
362  (
363  Cref1_*R - ((Cref2_*C2_)*(k_/epsilon_))*dev(P)
364  );
365 
366  REqn.ref() +=
367  ((3*pow(Cmu_, 0.75)/kappa_)*(alpha*rho*sqrt(k_)/y_))
368  *dev(symm((n_ & reflect)*n_));
369  }
370 
371  REqn.ref().relax();
372  fvOptions.constrain(REqn.ref());
373  solve(REqn);
374  fvOptions.correct(R);
375 
376  this->boundNormalStress(R);
377 
378  k_ = 0.5*tr(R);
379 
380  correctNut();
381 
382  // Correct wall shear-stresses when applying wall-functions
383  this->correctWallShearStress(R);
384 }
385 
386 
387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
388 
389 } // End namespace RASModels
390 } // End namespace Foam
391 
392 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:84
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
fvOptions.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::optionList::correct
void correct(GeometricField< Type, fvPatchField, volMesh > &field)
Apply correction to field.
Definition: fvOptionListTemplates.C:355
Foam::RASModels::LRR::rhoField
BasicTurbulenceModel::rhoField rhoField
Definition: LRR.H:156
Foam::constant::universal::G
const dimensionedScalar G
Newtonian constant of gravitation.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::RASModel
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:52
Foam::fv::options::New
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present.
Definition: fvOptions.C:103
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::bound
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:35
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::MeshObject< fvMesh, UpdateableMeshObject, wallDist >::New
static const wallDist & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
wallFvPatch.H
rho
rho
Definition: readInitialConditions.H:88
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::RASModels::LRR
Launder, Reece and Rodi Reynolds-stress turbulence model for incompressible and compressible flows.
Definition: LRR.H:103
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
nu
volScalarField & nu
Definition: readMechanicalProperties.H:176
n
label n
Definition: TABSMDCalcMethod2.H:31
R
#define R(A, B, C, D, E, F, K, M)
Foam::ReynoldsStress
Reynolds-stress turbulence model base class.
Definition: ReynoldsStress.H:53
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::RASModels::LRR::alphaField
BasicTurbulenceModel::alphaField alphaField
Definition: LRR.H:155
Foam::RASModels::LRR::correctNut
virtual void correctNut()
Update the eddy-viscosity.
Definition: LRR.C:43
Foam::fvm::Sp
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
fvOptions
fv::options & fvOptions
Definition: setRegionFluidFields.H:23
LRR.H
Foam::RASModels::LRR::DepsilonEff
tmp< volSymmTensorField > DepsilonEff() const
Return the effective diffusivity for epsilon.
Definition: LRR.C:259
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:48
correct
fvOptions correct(rho)
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::solve
SolverPerformance< Type > solve(faMatrix< Type > &, Istream &)
Solve returning the solution statistics given convergence tolerance.
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::RASModels::LRR::read
virtual bool read()
Read model coefficients if they have changed.
Definition: LRR.C:220
Foam::fv::options
Finite-volume options.
Definition: fvOptions.H:55
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam::RASModels::LRR::correct
virtual void correct()
Solve the turbulence equations and correct eddy-Viscosity and.
Definition: LRR.C:273
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
U
U
Definition: pEqn.H:72
Foam::fvm::ddt
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:48
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::RASModels::LRR::transportModel
BasicTurbulenceModel::transportModel transportModel
Definition: LRR.H:157
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::RASModels::LRR::DREff
tmp< volSymmTensorField > DREff() const
Return the effective diffusivity for R.
Definition: LRR.C:245
Foam::fvPatch::faceCells
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:113
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:51
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::fvm::div
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:48
Foam::twoSymm
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:95
Foam::I
static const Identity< scalar > I
Definition: Identity.H:95
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::Switch::getOrAddToDict
static Switch getOrAddToDict(const word &key, dictionary &dict, const Switch deflt=switchType::FALSE)
Definition: Switch.C:164
Foam::IOobject::MUST_READ
Definition: IOobject.H:185
Foam::dev
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:106