1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "SpalartAllmaras.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace incompressible
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 defineTypeNameAndDebug(SpalartAllmaras, 0);
42 addToRunTimeSelectionTable(RASModel, SpalartAllmaras, dictionary);
44 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
46 tmp<volScalarField> SpalartAllmaras::chi() const
52 tmp<volScalarField> SpalartAllmaras::fv1(const volScalarField& chi) const
54 volScalarField chi3 = pow3(chi);
55 return chi3/(chi3 + pow3(Cv1_));
59 tmp<volScalarField> SpalartAllmaras::fv2
61 const volScalarField& chi,
62 const volScalarField& fv1
65 // Model adjustment, Eric Paterson: boundedness of
66 // turbulent viscosity. HJ, 24/Aug/2010
67 return 1.0 - chi/(1.0 + chi*fv1);
68 //return 1.0/pow3(scalar(1) + chi/Cv2);
72 tmp<volScalarField> SpalartAllmaras::fv3
74 const volScalarField& chi,
75 const volScalarField& fv1
78 volScalarField chiByCv2 = (1/Cv2_)*chi;
83 *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
84 /pow3(scalar(1) + chiByCv2);
88 tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const
90 volScalarField r = min
94 max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL))
99 r.boundaryField() == 0.0;
101 volScalarField g = r + Cw2_*(pow6(r) - r);
103 return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
107 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
109 SpalartAllmaras::SpalartAllmaras
111 const volVectorField& U,
112 const surfaceScalarField& phi,
113 transportModel& lamTransportModel
116 RASModel(typeName, U, phi, lamTransportModel),
120 dimensioned<scalar>::lookupOrAddToDict
129 dimensioned<scalar>::lookupOrAddToDict
139 dimensioned<scalar>::lookupOrAddToDict
148 dimensioned<scalar>::lookupOrAddToDict
155 Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
158 dimensioned<scalar>::lookupOrAddToDict
167 dimensioned<scalar>::lookupOrAddToDict
176 dimensioned<scalar>::lookupOrAddToDict
185 dimensioned<scalar>::lookupOrAddToDict
225 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
227 tmp<volScalarField> SpalartAllmaras::DnuTildaEff() const
229 return tmp<volScalarField>
231 new volScalarField("DnuTildaEff", nuTilda_/sigmaNut_ + nu())
236 tmp<volScalarField> SpalartAllmaras::k() const
238 return tmp<volScalarField>
249 dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0)
255 tmp<volScalarField> SpalartAllmaras::epsilon() const
257 return tmp<volScalarField>
268 dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0)
274 tmp<volSymmTensorField> SpalartAllmaras::R() const
276 return tmp<volSymmTensorField>
278 new volSymmTensorField
288 ((2.0/3.0)*I)*k() - nut()*twoSymm(fvc::grad(U_))
294 tmp<volSymmTensorField> SpalartAllmaras::devReff() const
296 return tmp<volSymmTensorField>
298 new volSymmTensorField
308 -nuEff()*dev(twoSymm(fvc::grad(U_)))
314 tmp<fvVectorMatrix> SpalartAllmaras::divDevReff(volVectorField& U) const
316 volScalarField nuEff_ = nuEff();
320 - fvm::laplacian(nuEff_, U)
321 - fvc::div(nuEff_*dev(fvc::grad(U)().T()))
326 bool SpalartAllmaras::read()
328 if (RASModel::read())
330 sigmaNut_.readIfPresent(coeffDict());
332 Cb1_.readIfPresent(coeffDict());
333 Cb2_.readIfPresent(coeffDict());
334 Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
335 Cw2_.readIfPresent(coeffDict());
336 Cw3_.readIfPresent(coeffDict());
337 Cv1_.readIfPresent(coeffDict());
338 Cv2_.readIfPresent(coeffDict());
349 void SpalartAllmaras::correct()
351 if (mesh_.changing())
353 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
363 if (mesh_.changing())
368 volScalarField chi = this->chi();
369 volScalarField fv1 = this->fv1(chi);
371 volScalarField Stilda =
372 // fv3(chi, fv1)*::sqrt(2.0)*mag(skew(fvc::grad(U_)))
373 sqrt(2.0)*mag(skew(fvc::grad(U_)))
374 + fv2(chi, fv1)*nuTilda_/sqr(kappa_*d_);
376 tmp<fvScalarMatrix> nuTildaEqn
379 + fvm::div(phi_, nuTilda_)
380 + fvm::SuSp(-fvc::div(phi_), nuTilda_)
381 - fvm::laplacian(DnuTildaEff(), nuTilda_)
382 - Cb2_/sigmaNut_*magSqr(fvc::grad(nuTilda_))
385 - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_/sqr(d_), nuTilda_)
388 nuTildaEqn().relax();
390 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
391 nuTilda_.correctBoundaryConditions();
393 nut_.internalField() = fv1*nuTilda_.internalField();
394 nut_.correctBoundaryConditions();
398 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
400 } // End namespace RASModels
401 } // End namespace incompressible
402 } // End namespace Foam
404 // ************************************************************************* //