SpalartAllmaras.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 "SpalartAllmaras.H"
27 #include "bound.H"
28 #include "wallDist.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace RASModels
35 {
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class BasicTurbulenceModel>
41 {
42  return nuTilda_/this->nu();
43 }
44 
45 
46 template<class BasicTurbulenceModel>
48 (
49  const volScalarField& chi
50 ) const
51 {
52  const volScalarField chi3(pow3(chi));
53  return chi3/(chi3 + pow3(Cv1_));
54 }
55 
56 
57 template<class BasicTurbulenceModel>
59 (
60  const volScalarField& chi,
61  const volScalarField& fv1
62 ) const
63 {
64  return 1.0 - chi/(1.0 + chi*fv1);
65 }
66 
67 
68 template<class BasicTurbulenceModel>
70 (
71  const volScalarField& chi,
72  const volScalarField& fv1
73 ) const
74 {
75  volScalarField Omega(::sqrt(2.0)*mag(skew(fvc::grad(this->U_))));
76 
77  return
78  (
79  max
80  (
81  Omega
82  + fv2(chi, fv1)*nuTilda_/sqr(kappa_*y_),
83  Cs_*Omega
84  )
85  );
86 }
87 
88 
89 template<class BasicTurbulenceModel>
91 (
92  const volScalarField& Stilda
93 ) const
94 {
96  (
97  min
98  (
99  nuTilda_
100  /(
101  max
102  (
103  Stilda,
104  dimensionedScalar("SMALL", Stilda.dimensions(), SMALL)
105  )
106  *sqr(kappa_*y_)
107  ),
108  scalar(10.0)
109  )
110  );
111  r.boundaryField() == 0.0;
112 
113  const volScalarField g(r + Cw2_*(pow6(r) - r));
114 
115  return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
116 }
117 
118 
119 template<class BasicTurbulenceModel>
121 (
122  const volScalarField& fv1
123 )
124 {
125  this->nut_ = nuTilda_*fv1;
126  this->nut_.correctBoundaryConditions();
127 
128  BasicTurbulenceModel::correctNut();
129 }
130 
131 
132 template<class BasicTurbulenceModel>
134 {
135  correctNut(fv1(this->chi()));
136 }
137 
138 
139 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
140 
141 template<class BasicTurbulenceModel>
143 (
144  const alphaField& alpha,
145  const rhoField& rho,
146  const volVectorField& U,
147  const surfaceScalarField& alphaRhoPhi,
148  const surfaceScalarField& phi,
149  const transportModel& transport,
150  const word& propertiesName,
151  const word& type
152 )
153 :
155  (
156  type,
157  alpha,
158  rho,
159  U,
160  alphaRhoPhi,
161  phi,
162  transport,
163  propertiesName
164  ),
165 
166  sigmaNut_
167  (
169  (
170  "sigmaNut",
171  this->coeffDict_,
172  0.66666
173  )
174  ),
175  kappa_
176  (
178  (
179  "kappa",
180  this->coeffDict_,
181  0.41
182  )
183  ),
184 
185  Cb1_
186  (
188  (
189  "Cb1",
190  this->coeffDict_,
191  0.1355
192  )
193  ),
194  Cb2_
195  (
197  (
198  "Cb2",
199  this->coeffDict_,
200  0.622
201  )
202  ),
203  Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
204  Cw2_
205  (
207  (
208  "Cw2",
209  this->coeffDict_,
210  0.3
211  )
212  ),
213  Cw3_
214  (
216  (
217  "Cw3",
218  this->coeffDict_,
219  2.0
220  )
221  ),
222  Cv1_
223  (
225  (
226  "Cv1",
227  this->coeffDict_,
228  7.1
229  )
230  ),
231  Cs_
232  (
234  (
235  "Cs",
236  this->coeffDict_,
237  0.3
238  )
239  ),
240 
241  nuTilda_
242  (
243  IOobject
244  (
245  "nuTilda",
246  this->runTime_.timeName(),
247  this->mesh_,
250  ),
251  this->mesh_
252  ),
253 
254  y_(wallDist::New(this->mesh_).y())
255 {
256  if (type == typeName)
257  {
258  correctNut();
259  this->printCoeffs(type);
260  }
261 }
262 
263 
264 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
265 
266 template<class BasicTurbulenceModel>
268 {
270  {
271  sigmaNut_.readIfPresent(this->coeffDict());
272  kappa_.readIfPresent(this->coeffDict());
273 
274  Cb1_.readIfPresent(this->coeffDict());
275  Cb2_.readIfPresent(this->coeffDict());
276  Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
277  Cw2_.readIfPresent(this->coeffDict());
278  Cw3_.readIfPresent(this->coeffDict());
279  Cv1_.readIfPresent(this->coeffDict());
280  Cs_.readIfPresent(this->coeffDict());
281 
282  return true;
283  }
284  else
285  {
286  return false;
287  }
288 }
289 
290 
291 template<class BasicTurbulenceModel>
293 {
294  return tmp<volScalarField>
295  (
296  new volScalarField("DnuTildaEff", (nuTilda_ + this->nu())/sigmaNut_)
297  );
298 }
299 
300 
301 template<class BasicTurbulenceModel>
303 {
304  return tmp<volScalarField>
305  (
306  new volScalarField
307  (
308  IOobject
309  (
310  "k",
311  this->runTime_.timeName(),
312  this->mesh_
313  ),
314  this->mesh_,
315  dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0)
316  )
317  );
318 }
319 
320 
321 template<class BasicTurbulenceModel>
323 {
324  WarningIn("tmp<volScalarField> SpalartAllmaras::epsilon() const")
325  << "Turbulence kinetic energy dissipation rate not defined for "
326  << "Spalart-Allmaras model. Returning zero field"
327  << endl;
328 
329  return tmp<volScalarField>
330  (
331  new volScalarField
332  (
333  IOobject
334  (
335  "epsilon",
336  this->runTime_.timeName(),
337  this->mesh_
338  ),
339  this->mesh_,
340  dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0)
341  )
342  );
343 }
344 
345 
346 template<class BasicTurbulenceModel>
348 {
349  if (!this->turbulence_)
350  {
351  return;
352  }
353 
354  // Local references
355  const alphaField& alpha = this->alpha_;
356  const rhoField& rho = this->rho_;
357  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
358 
360 
361  const volScalarField chi(this->chi());
362  const volScalarField fv1(this->fv1(chi));
363 
364  const volScalarField Stilda(this->Stilda(chi, fv1));
365 
366  tmp<fvScalarMatrix> nuTildaEqn
367  (
368  fvm::ddt(alpha, rho, nuTilda_)
369  + fvm::div(alphaRhoPhi, nuTilda_)
370  - fvm::laplacian(alpha*rho*DnuTildaEff(), nuTilda_)
371  - Cb2_/sigmaNut_*alpha*rho*magSqr(fvc::grad(nuTilda_))
372  ==
373  Cb1_*alpha*rho*Stilda*nuTilda_
374  - fvm::Sp(Cw1_*alpha*rho*fw(Stilda)*nuTilda_/sqr(y_), nuTilda_)
375  );
376 
377  nuTildaEqn().relax();
378  solve(nuTildaEqn);
379  bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
380  nuTilda_.correctBoundaryConditions();
381 
382  correctNut(fv1);
383 }
384 
385 
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 
388 } // End namespace RASModels
389 } // End namespace Foam
390 
391 // ************************************************************************* //
dimensionedScalar sqrt(const dimensionedScalar &ds)
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:46
dimensionedScalar pow3(const dimensionedScalar &ds)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:46
dimensionedTensor skew(const dimensionedTensor &dt)
dimensioned< scalar > mag(const dimensioned< Type > &)
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Bound the given scalar field if it has gone unbounded.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
static const wallDist & New(const fvMesh &mesh)
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/dm2/henry/OpenFOAM/OpenFOAM-3.0.x/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:74
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:33
A class for handling words, derived from string.
Definition: word.H:59
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
tmp< volScalarField > DnuTildaEff() const
Return the effective diffusivity for nuTilda.
virtual tmp< volScalarField > k() const
Return the turbulence kinetic energy.
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:49
tmp< volScalarField > chi() const
tmp< fvMatrix< Type > > Sp(const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)
Namespace for OpenFOAM.
dimensionedScalar pow6(const dimensionedScalar &ds)
tmp< volScalarField > Stilda(const volScalarField &chi, const volScalarField &fv1) const
Generic dimensioned Type class.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define WarningIn(functionName)
Report a warning using Foam::Warning.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Dimension set for the base types.
Definition: dimensionSet.H:116
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
BasicTurbulenceModel::transportModel transportModel
Definition: RASModel.H:101
bool readIfPresent(const dictionary &)
Update the value of dimensioned<Type> if found in the dictionary.
Eddy viscosity turbulence model base class.
Definition: eddyViscosity.H:52
const dimensionSet & dimensions() const
Return dimensions.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
surfaceScalarField & phi
tmp< volScalarField > fw(const volScalarField &Stilda) const
virtual bool read()
Read RASProperties dictionary.
solverPerformance solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
virtual tmp< volScalarField > epsilon() const
Return the turbulence kinetic energy dissipation rate.
const dimensionedVector & g
scalar y
void correctBoundaryConditions()
Correct boundary field.
tmp< volScalarField > fv1(const volScalarField &chi) const
bool read(const char *, int32_t &)
Definition: int32IO.C:87
volScalarField & nu
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
tmp< volScalarField > fv2(const volScalarField &chi, const volScalarField &fv1) const
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
BasicTurbulenceModel::rhoField rhoField
Definition: RASModel.H:100
Spalart-Allmaras one-eqn mixing-length model for incompressible and compressible external flows...
BasicTurbulenceModel::alphaField alphaField
Definition: RASModel.H:99
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A class for managing temporary objects.
Definition: PtrList.H:118
U
Definition: pEqn.H:82