Loading...
Searching...
No Matches
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-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
35namespace Foam
37namespace RASModels
38{
39
40// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
41
42template<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
55template<class BasicTurbulenceModel>
56LRR<BasicTurbulenceModel>::LRR
57(
58 const alphaField& alpha,
59 const rhoField& rho,
60 const volVectorField& U,
61 const surfaceScalarField& alphaRhoPhi,
63 const transportModel& transport,
64 const word& propertiesName,
65 const word& type
66)
67:
68 ReynoldsStress<RASModel<BasicTurbulenceModel>>
69 (
70 type,
71 alpha,
72 rho,
73 U,
74 alphaRhoPhi,
75 phi,
76 transport,
77 propertiesName
78 ),
79
80 Cmu_
81 (
82 dimensioned<scalar>::getOrAddToDict
83 (
84 "Cmu",
85 this->coeffDict_,
86 0.09
87 )
88 ),
89 C1_
90 (
91 dimensioned<scalar>::getOrAddToDict
92 (
93 "C1",
94 this->coeffDict_,
95 1.8
96 )
97 ),
98 C2_
99 (
100 dimensioned<scalar>::getOrAddToDict
101 (
102 "C2",
103 this->coeffDict_,
104 0.6
105 )
106 ),
107 Ceps1_
108 (
109 dimensioned<scalar>::getOrAddToDict
110 (
111 "Ceps1",
112 this->coeffDict_,
113 1.44
114 )
115 ),
116 Ceps2_
117 (
118 dimensioned<scalar>::getOrAddToDict
119 (
120 "Ceps2",
121 this->coeffDict_,
122 1.92
123 )
124 ),
125 Cs_
126 (
127 dimensioned<scalar>::getOrAddToDict
128 (
129 "Cs",
130 this->coeffDict_,
131 0.25
132 )
133 ),
134 Ceps_
135 (
136 dimensioned<scalar>::getOrAddToDict
137 (
138 "Ceps",
139 this->coeffDict_,
140 0.15
141 )
142 ),
143
144 wallReflection_
145 (
146 Switch::getOrAddToDict
147 (
148 "wallReflection",
149 this->coeffDict_,
150 true
151 )
152 ),
153 kappa_
154 (
155 dimensioned<scalar>::getOrAddToDict
156 (
157 "kappa",
158 this->coeffDict_,
159 0.41
160 )
161 ),
162 Cref1_
163 (
164 dimensioned<scalar>::getOrAddToDict
165 (
166 "Cref1",
167 this->coeffDict_,
168 0.5
169 )
170 ),
171 Cref2_
172 (
173 dimensioned<scalar>::getOrAddToDict
174 (
175 "Cref2",
176 this->coeffDict_,
177 0.3
178 )
179 ),
180
181 k_
182 (
184 (
185 "k",
186 this->runTime_.timeName(),
187 this->mesh_,
188 IOobject::NO_READ,
189 IOobject::AUTO_WRITE
190 ),
191 0.5*tr(this->R_)
192 ),
193 epsilon_
194 (
196 (
197 "epsilon",
198 this->runTime_.timeName(),
199 this->mesh_,
200 IOobject::MUST_READ,
201 IOobject::AUTO_WRITE
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_);
214}
215
216
217// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
218
219template<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;
239
240 return false;
241}
242
243
244template<class BasicTurbulenceModel>
246{
248 (
250 (
251 "DREff",
252 (Cs_*(this->k_/this->epsilon_))*this->R_ + I*this->nu()
253 )
254 );
255}
256
257
258template<class BasicTurbulenceModel>
260{
262 (
264 (
265 "DepsilonEff",
266 (Ceps_*(this->k_/this->epsilon_))*this->R_ + I*this->nu()
267 )
268 );
269}
270
271
272template<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_;
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 // Push any changed cell values to coupled neighbours
299 epsilon_.boundaryFieldRef().template evaluateCoupled<coupledFvPatch>();
300
301 // Dissipation equation
303 (
304 fvm::ddt(alpha, rho, epsilon_)
305 + fvm::div(alphaRhoPhi, epsilon_)
306 - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_)
307 ==
308 Ceps1_*alpha*rho*G*epsilon_/k_
309 - fvm::Sp(Ceps2_*alpha*rho*epsilon_/k_, epsilon_)
310 + fvOptions(alpha, rho, epsilon_)
311 );
312
313 epsEqn.ref().relax();
314 fvOptions.constrain(epsEqn.ref());
315 epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
316 solve(epsEqn);
317 fvOptions.correct(epsilon_);
318 bound(epsilon_, this->epsilonMin_);
319
320
321 // Correct the trace of the tensorial production to be consistent
322 // with the near-wall generation from the wall-functions
323 const fvPatchList& patches = this->mesh_.boundary();
324
325 forAll(patches, patchi)
326 {
327 const fvPatch& curPatch = patches[patchi];
328
329 if (isA<wallFvPatch>(curPatch))
330 {
331 forAll(curPatch, facei)
332 {
333 label celli = curPatch.faceCells()[facei];
334 P[celli] *= min
335 (
336 G[celli]/(0.5*mag(tr(P[celli])) + SMALL),
337 1.0
338 );
339 }
340 }
341 }
342
343 // Reynolds stress equation
344 tmp<fvSymmTensorMatrix> REqn
345 (
347 + fvm::div(alphaRhoPhi, R)
348 - fvm::laplacian(alpha*rho*DREff(), R)
349 + fvm::Sp(C1_*alpha*rho*epsilon_/k_, R)
350 ==
351 alpha*rho*P
352 - (2.0/3.0*(1 - C1_)*I)*alpha*rho*epsilon_
353 - C2_*alpha*rho*dev(P)
354 + fvOptions(alpha, rho, R)
355 );
356
357 // Optionally add wall-refection term
358 if (wallReflection_)
359 {
360 const volVectorField& n_(wallDist::New(this->mesh_).n());
361 const volScalarField& y_(wallDist::New(this->mesh_).y());
362
363 const volSymmTensorField reflect
364 (
365 Cref1_*R - ((Cref2_*C2_)*(k_/epsilon_))*dev(P)
366 );
367
368 REqn.ref() +=
369 ((3*pow(Cmu_, 0.75)/kappa_)*(alpha*rho*sqrt(k_)/y_))
370 *devSymm((n_ & reflect)*n_);
371 }
372
373 REqn.ref().relax();
374 fvOptions.constrain(REqn.ref());
375 solve(REqn);
376 fvOptions.correct(R);
377
378 this->boundNormalStress(R);
379
380 k_ = 0.5*tr(R);
381
382 correctNut();
383
384 // Correct wall shear-stresses when applying wall-functions
385 this->correctWallShearStress(R);
386}
387
388
389// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
390
391} // End namespace RASModels
392} // End namespace Foam
393
394// ************************************************************************* //
scalar y
#define R(A, B, C, D, E, F, K, M)
label n
fv::options & fvOptions
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
static FOAM_NO_DANGLING_REFERENCE const wallDist & New(const fvMesh &mesh, Args &&... args)
Templated abstract base class for RAS turbulence models.
Definition RASModel.H:81
volScalarField epsilon_
Definition LRR.H:144
BasicTurbulenceModel::alphaField alphaField
Definition LRR.H:157
tmp< volSymmTensorField > DepsilonEff() const
Return the effective diffusivity for epsilon.
Definition LRR.C:252
BasicTurbulenceModel::rhoField rhoField
Definition LRR.H:158
volScalarField k_
Definition LRR.H:143
dimensionedScalar C1_
Definition LRR.H:124
virtual void correct()
Solve the turbulence equations and correct eddy-Viscosity and.
Definition LRR.C:266
dimensionedScalar Ceps2_
Definition LRR.H:128
dimensionedScalar kappa_
Definition LRR.H:136
tmp< volSymmTensorField > DREff() const
Return the effective diffusivity for R.
Definition LRR.C:238
dimensionedScalar C2_
Definition LRR.H:125
dimensionedScalar Cref1_
Definition LRR.H:137
virtual void correctNut()
Update the eddy-viscosity.
Definition LRR.C:36
dimensionedScalar Cs_
Definition LRR.H:129
BasicTurbulenceModel::transportModel transportModel
Definition LRR.H:159
Switch wallReflection_
Definition LRR.H:135
dimensionedScalar Ceps1_
Definition LRR.H:127
dimensionedScalar Cmu_
Definition LRR.H:122
dimensionedScalar Cref2_
Definition LRR.H:138
dimensionedScalar Ceps_
Definition LRR.H:130
virtual bool read()
Read model coefficients if they have changed.
Definition LRR.C:213
Reynolds-stress turbulence model base class.
virtual tmp< volSymmTensorField > R() const
ReynoldsStress(const word &modelName, const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const transportModel &transport, const word &propertiesName)
void correctWallShearStress(volSymmTensorField &R) const
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
Generic dimensioned Type class.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
virtual const labelUList & faceCells() const
Return faceCells.
Definition fvPatch.C:107
void correct(GeometricField< Type, PatchField, GeoMesh > &field)
Apply correction to field.
Finite-volume options, which is an IOdictionary of values and a fv::optionList.
Definition fvOptions.H:69
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present otherwise lookup and return.
Definition fvOptions.C:116
A class for managing temporary objects.
Definition tmp.H:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
Base-class for all transport models used by the incompressible turbulence models.
A class for handling words, derived from Foam::string.
Definition word.H:66
U
Definition pEqn.H:72
thermo correct()
const polyBoundaryMesh & patches
word timeName
Definition getTimeIndex.H:3
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition fvcGrad.C:47
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition fvmDiv.C:41
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition fvmDdt.C:41
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
Namespace for OpenFOAM.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
GeometricField< vector, fvPatchField, volMesh > volVectorField
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
PtrList< fvPatch > fvPatchList
Store lists of fvPatch as a PtrList.
Definition fvPatch.H:64
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition int32.H:127
dimensionedSymmTensor sqr(const dimensionedVector &dv)
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition bound.C:29
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
static const Identity< scalar > I
Definition Identity.H:100
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
SymmTensor< Cmpt > devSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of the symmetric part of a SymmTensor.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
GeometricField< tensor, fvPatchField, volMesh > volTensorField
dimensionedScalar sqrt(const dimensionedScalar &ds)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
volScalarField & nu
volScalarField & alpha
CEqn solve()
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299