SSG.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) 2015-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2020 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 "SSG.H"
30#include "fvOptions.H"
31#include "wallFvPatch.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35namespace Foam
36{
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>
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 3.4
96 )
97 ),
98 C1s_
99 (
100 dimensioned<scalar>::getOrAddToDict
101 (
102 "C1s",
103 this->coeffDict_,
104 1.8
105 )
106 ),
107 C2_
108 (
109 dimensioned<scalar>::getOrAddToDict
110 (
111 "C2",
112 this->coeffDict_,
113 4.2
114 )
115 ),
116 C3_
117 (
118 dimensioned<scalar>::getOrAddToDict
119 (
120 "C3",
121 this->coeffDict_,
122 0.8
123 )
124 ),
125 C3s_
126 (
127 dimensioned<scalar>::getOrAddToDict
128 (
129 "C3s",
130 this->coeffDict_,
131 1.3
132 )
133 ),
134 C4_
135 (
136 dimensioned<scalar>::getOrAddToDict
137 (
138 "C4",
139 this->coeffDict_,
140 1.25
141 )
142 ),
143 C5_
144 (
145 dimensioned<scalar>::getOrAddToDict
146 (
147 "C5",
148 this->coeffDict_,
149 0.4
150 )
151 ),
152
153 Ceps1_
154 (
155 dimensioned<scalar>::getOrAddToDict
156 (
157 "Ceps1",
158 this->coeffDict_,
159 1.44
160 )
161 ),
162 Ceps2_
163 (
164 dimensioned<scalar>::getOrAddToDict
165 (
166 "Ceps2",
167 this->coeffDict_,
168 1.92
169 )
170 ),
171 Cs_
172 (
173 dimensioned<scalar>::getOrAddToDict
174 (
175 "Cs",
176 this->coeffDict_,
177 0.25
178 )
179 ),
180 Ceps_
181 (
182 dimensioned<scalar>::getOrAddToDict
183 (
184 "Ceps",
185 this->coeffDict_,
186 0.15
187 )
188 ),
189
190 k_
191 (
193 (
194 "k",
195 this->runTime_.timeName(),
196 this->mesh_,
197 IOobject::NO_READ,
198 IOobject::AUTO_WRITE
199 ),
200 0.5*tr(this->R_)
201 ),
202 epsilon_
203 (
205 (
206 "epsilon",
207 this->runTime_.timeName(),
208 this->mesh_,
209 IOobject::MUST_READ,
210 IOobject::AUTO_WRITE
211 ),
212 this->mesh_
213 )
214{
215 if (type == typeName)
216 {
217 this->printCoeffs(type);
218
219 this->boundNormalStress(this->R_);
220 bound(epsilon_, this->epsilonMin_);
221 k_ = 0.5*tr(this->R_);
222 }
223}
224
225
226// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
227
228template<class BasicTurbulenceModel>
230{
232 {
233 Cmu_.readIfPresent(this->coeffDict());
234 C1_.readIfPresent(this->coeffDict());
235 C1s_.readIfPresent(this->coeffDict());
236 C2_.readIfPresent(this->coeffDict());
237 C3_.readIfPresent(this->coeffDict());
238 C3s_.readIfPresent(this->coeffDict());
239 C4_.readIfPresent(this->coeffDict());
240 C5_.readIfPresent(this->coeffDict());
241
242 Ceps1_.readIfPresent(this->coeffDict());
243 Ceps2_.readIfPresent(this->coeffDict());
244 Cs_.readIfPresent(this->coeffDict());
245 Ceps_.readIfPresent(this->coeffDict());
246
247 return true;
248 }
249
250 return false;
251}
252
253
254template<class BasicTurbulenceModel>
256{
258 (
260 (
261 "DREff",
262 (Cs_*(this->k_/this->epsilon_))*this->R_ + I*this->nu()
263 )
264 );
265}
266
267
268template<class BasicTurbulenceModel>
270{
272 (
274 (
275 "DepsilonEff",
276 (Ceps_*(this->k_/this->epsilon_))*this->R_ + I*this->nu()
277 )
278 );
279}
280
281
282template<class BasicTurbulenceModel>
284{
285 if (!this->turbulence_)
286 {
287 return;
288 }
289
290 // Local references
291 const alphaField& alpha = this->alpha_;
292 const rhoField& rho = this->rho_;
293 const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
294 const volVectorField& U = this->U_;
295 volSymmTensorField& R = this->R_;
297
299
301 const volTensorField& gradU = tgradU();
302
303 volSymmTensorField P(-twoSymm(R & gradU));
304 volScalarField G(this->GName(), 0.5*mag(tr(P)));
305
306 // Update epsilon and G at the wall
307 epsilon_.boundaryFieldRef().updateCoeffs();
308
309 // Dissipation equation
311 (
312 fvm::ddt(alpha, rho, epsilon_)
313 + fvm::div(alphaRhoPhi, epsilon_)
314 - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_)
315 ==
316 Ceps1_*alpha*rho*G*epsilon_/k_
317 - fvm::Sp(Ceps2_*alpha*rho*epsilon_/k_, epsilon_)
318 + fvOptions(alpha, rho, epsilon_)
319 );
320
321 epsEqn.ref().relax();
322 fvOptions.constrain(epsEqn.ref());
323 epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
324 solve(epsEqn);
325 fvOptions.correct(epsilon_);
326 bound(epsilon_, this->epsilonMin_);
327
328
329 // Correct the trace of the tensorial production to be consistent
330 // with the near-wall generation from the wall-functions
331 const fvPatchList& patches = this->mesh_.boundary();
332
333 forAll(patches, patchi)
334 {
335 const fvPatch& curPatch = patches[patchi];
336
337 if (isA<wallFvPatch>(curPatch))
338 {
339 forAll(curPatch, facei)
340 {
341 label celli = curPatch.faceCells()[facei];
342 P[celli] *= min
343 (
344 G[celli]/(0.5*mag(tr(P[celli])) + SMALL),
345 1.0
346 );
347 }
348 }
349 }
350
351 volSymmTensorField b(dev(R)/(2*k_));
352 volSymmTensorField S(symm(gradU));
353 volTensorField Omega(skew(gradU));
354
355 // Reynolds stress equation
357 (
359 + fvm::div(alphaRhoPhi, R)
360 - fvm::laplacian(alpha*rho*DREff(), R)
361 + fvm::Sp(((C1_/2)*epsilon_ + (C1s_/2)*G)*alpha*rho/k_, R)
362 ==
363 alpha*rho*P
364 - ((1.0/3.0)*I)*(((2.0 - C1_)*epsilon_ - C1s_*G)*alpha*rho)
365 + (C2_*(alpha*rho*epsilon_))*dev(innerSqr(b))
366 + alpha*rho*k_
367 *(
368 (C3_ - C3s_*mag(b))*dev(S)
369 + C4_*dev(twoSymm(b&S))
370 + C5_*twoSymm(b&Omega)
371 )
372 + fvOptions(alpha, rho, R)
373 );
374
375 REqn.ref().relax();
376 fvOptions.constrain(REqn.ref());
377 solve(REqn);
378 fvOptions.correct(R);
379
380 this->boundNormalStress(R);
381
382 k_ = 0.5*tr(R);
383 bound(k_, this->kMin_);
384
385 correctNut();
386
387 // Correct wall shear-stresses when applying wall-functions
388 this->correctWallShearStress(R);
389}
390
391
392// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
393
394} // End namespace RASModels
395} // End namespace Foam
396
397// ************************************************************************* //
#define R(A, B, C, D, E, F, K, M)
fv::options & fvOptions
surfaceScalarField & phi
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:55
virtual void printCoeffs(const word &type)
Print model coefficients.
Definition: RASModel.C:34
dimensionedScalar epsilonMin_
Lower limit of epsilon.
Definition: RASModel.H:77
Speziale, Sarkar and Gatski Reynolds-stress turbulence model for incompressible and compressible flow...
Definition: SSG.H:101
volScalarField epsilon_
Definition: SSG.H:135
BasicTurbulenceModel::alphaField alphaField
Definition: SSG.H:146
tmp< volSymmTensorField > DepsilonEff() const
Return the effective diffusivity for epsilon.
Definition: SSG.C:269
BasicTurbulenceModel::rhoField rhoField
Definition: SSG.H:147
volScalarField k_
Definition: SSG.H:134
virtual void correct()
Solve the turbulence equations and correct eddy-Viscosity and.
Definition: SSG.C:283
tmp< volSymmTensorField > DREff() const
Return the effective diffusivity for R.
Definition: SSG.C:255
virtual void correctNut()
Update the eddy-viscosity.
Definition: SSG.C:43
BasicTurbulenceModel::transportModel transportModel
Definition: SSG.H:148
virtual bool read()
Read model coefficients if they have changed.
Definition: SSG.C:229
Reynolds-stress turbulence model base class.
void boundNormalStress(volSymmTensorField &R) const
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
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:113
Finite-volume options.
Definition: fvOptions.H:59
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
A class for handling words, derived from Foam::string.
Definition: word.H:68
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:54
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:48
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:48
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
Namespace for OpenFOAM.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
dimensionedSymmTensor sqr(const dimensionedVector &dv)
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:35
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
static const Identity< scalar > I
Definition: Identity.H:94
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
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:33
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
dimensionedTensor skew(const dimensionedTensor &dt)
volScalarField & nu
volScalarField & alpha
CEqn solve()
volScalarField & b
Definition: createFields.H:27
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333