1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "SpalartAllmaras.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace incompressible
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(SpalartAllmaras, 0);
41 addToRunTimeSelectionTable(RASModel, SpalartAllmaras, dictionary);
43 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
45 tmp<volScalarField> SpalartAllmaras::chi() const
51 tmp<volScalarField> SpalartAllmaras::fv1(const volScalarField& chi) const
53 const volScalarField chi3(pow3(chi));
54 return chi3/(chi3 + pow3(Cv1_));
58 tmp<volScalarField> SpalartAllmaras::fv2
60 const volScalarField& chi,
61 const volScalarField& fv1
64 return 1.0/pow3(scalar(1) + chi/Cv2_);
68 tmp<volScalarField> SpalartAllmaras::fv3
70 const volScalarField& chi,
71 const volScalarField& fv1
74 const volScalarField chiByCv2((1/Cv2_)*chi);
79 *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
80 /pow3(scalar(1) + chiByCv2);
84 tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const
95 dimensionedScalar("SMALL", Stilda.dimensions(), SMALL)
102 r.boundaryField() == 0.0;
104 const volScalarField g(r + Cw2_*(pow6(r) - r));
106 return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
110 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
112 SpalartAllmaras::SpalartAllmaras
114 const volVectorField& U,
115 const surfaceScalarField& phi,
116 transportModel& transport,
117 const word& turbulenceModelName,
118 const word& modelName
121 RASModel(modelName, U, phi, transport, turbulenceModelName),
125 dimensioned<scalar>::lookupOrAddToDict
134 dimensioned<scalar>::lookupOrAddToDict
144 dimensioned<scalar>::lookupOrAddToDict
153 dimensioned<scalar>::lookupOrAddToDict
160 Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
163 dimensioned<scalar>::lookupOrAddToDict
172 dimensioned<scalar>::lookupOrAddToDict
181 dimensioned<scalar>::lookupOrAddToDict
190 dimensioned<scalar>::lookupOrAddToDict
230 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
232 tmp<volScalarField> SpalartAllmaras::DnuTildaEff() const
234 return tmp<volScalarField>
236 new volScalarField("DnuTildaEff", (nuTilda_ + nu())/sigmaNut_)
241 tmp<volScalarField> SpalartAllmaras::k() const
243 WarningIn("tmp<volScalarField> SpalartAllmaras::k() const")
244 << "Turbulence kinetic energy not defined for Spalart-Allmaras model. "
245 << "Returning zero field" << endl;
247 return tmp<volScalarField>
258 dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0)
264 tmp<volScalarField> SpalartAllmaras::epsilon() const
266 WarningIn("tmp<volScalarField> SpalartAllmaras::epsilon() const")
267 << "Turbulence kinetic energy dissipation rate not defined for "
268 << "Spalart-Allmaras model. Returning zero field"
271 return tmp<volScalarField>
282 dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0)
288 tmp<volSymmTensorField> SpalartAllmaras::R() const
290 return tmp<volSymmTensorField>
292 new volSymmTensorField
302 ((2.0/3.0)*I)*k() - nut()*twoSymm(fvc::grad(U_))
308 tmp<volSymmTensorField> SpalartAllmaras::devReff() const
310 return tmp<volSymmTensorField>
312 new volSymmTensorField
322 -nuEff()*dev(twoSymm(fvc::grad(U_)))
328 tmp<fvVectorMatrix> SpalartAllmaras::divDevReff(volVectorField& U) const
330 const volScalarField nuEff_(nuEff());
334 - fvm::laplacian(nuEff_, U)
335 - fvc::div(nuEff_*dev(T(fvc::grad(U))))
340 bool SpalartAllmaras::read()
342 if (RASModel::read())
344 sigmaNut_.readIfPresent(coeffDict());
345 kappa_.readIfPresent(coeffDict());
347 Cb1_.readIfPresent(coeffDict());
348 Cb2_.readIfPresent(coeffDict());
349 Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
350 Cw2_.readIfPresent(coeffDict());
351 Cw3_.readIfPresent(coeffDict());
352 Cv1_.readIfPresent(coeffDict());
353 Cv2_.readIfPresent(coeffDict());
364 void SpalartAllmaras::correct()
373 if (mesh_.changing())
378 const volScalarField chi(this->chi());
379 const volScalarField fv1(this->fv1(chi));
381 const volScalarField Stilda
383 fv3(chi, fv1)*::sqrt(2.0)*mag(skew(fvc::grad(U_)))
384 + fv2(chi, fv1)*nuTilda_/sqr(kappa_*d_)
387 tmp<fvScalarMatrix> nuTildaEqn
390 + fvm::div(phi_, nuTilda_)
391 - fvm::Sp(fvc::div(phi_), nuTilda_)
392 - fvm::laplacian(DnuTildaEff(), nuTilda_)
393 - Cb2_/sigmaNut_*magSqr(fvc::grad(nuTilda_))
396 - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_/sqr(d_), nuTilda_)
399 nuTildaEqn().relax();
401 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
402 nuTilda_.correctBoundaryConditions();
404 nut_.internalField() = fv1*nuTilda_.internalField();
405 nut_.correctBoundaryConditions();
409 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
411 } // End namespace RASModels
412 } // End namespace incompressible
413 } // End namespace Foam
415 // ************************************************************************* //