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(LESModel, SpalartAllmaras, dictionary);
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 void SpalartAllmaras::updateSubGridScaleFields()
47 nuSgs_.internalField() = fv1()*nuTilda_.internalField();
48 nuSgs_.correctBoundaryConditions();
52 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 tmp<volScalarField> SpalartAllmaras::fv1() const
56 const volScalarField chi3(pow3(nuTilda_/nu()));
57 return chi3/(chi3 + pow3(Cv1_));
61 tmp<volScalarField> SpalartAllmaras::fv2() const
63 return 1/pow3(scalar(1) + nuTilda_/(Cv2_*nu()));
67 tmp<volScalarField> SpalartAllmaras::fv3() const
69 const volScalarField chi(nuTilda_/nu());
70 const volScalarField chiByCv2((1/Cv2_)*chi);
73 (scalar(1) + chi*fv1())
75 *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
76 /pow3(scalar(1) + chiByCv2);
80 tmp<volScalarField> SpalartAllmaras::S(const volTensorField& gradU) const
82 return sqrt(2.0)*mag(skew(gradU));
86 tmp<volScalarField> SpalartAllmaras::STilda
88 const volScalarField& S,
89 const volScalarField& dTilda
92 return fv3()*S + fv2()*nuTilda_/sqr(kappa_*dTilda);
96 tmp<volScalarField> SpalartAllmaras::r
98 const volScalarField& visc,
99 const volScalarField& S,
100 const volScalarField& dTilda
110 dimensionedScalar("SMALL", S.dimensions(), SMALL)
116 dimensionSet(0, 2 , -1, 0, 0),
125 tmp<volScalarField> SpalartAllmaras::fw
127 const volScalarField& S,
128 const volScalarField& dTilda
131 const volScalarField r(this->r(nuTilda_, S, dTilda));
132 const volScalarField g(r + Cw2_*(pow6(r) - r));
134 return g*pow((1 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
138 tmp<volScalarField> SpalartAllmaras::dTilda(const volScalarField&) const
140 return min(CDES_*delta(), y_);
144 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
146 SpalartAllmaras::SpalartAllmaras
148 const volVectorField& U,
149 const surfaceScalarField& phi,
150 transportModel& transport,
151 const word& turbulenceModelName,
152 const word& modelName
155 LESModel(modelName, U, phi, transport, turbulenceModelName),
159 dimensioned<scalar>::lookupOrAddToDict
168 dimensioned<scalar>::lookupOrAddToDict
177 dimensioned<scalar>::lookupOrAddToDict
186 dimensioned<scalar>::lookupOrAddToDict
195 dimensioned<scalar>::lookupOrAddToDict
204 dimensioned<scalar>::lookupOrAddToDict
213 dimensioned<scalar>::lookupOrAddToDict
222 dimensioned<scalar>::lookupOrAddToDict
229 Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
232 dimensioned<scalar>::lookupOrAddToDict
241 dimensioned<scalar>::lookupOrAddToDict
277 updateSubGridScaleFields();
281 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
283 void SpalartAllmaras::correct(const tmp<volTensorField>& gradU)
285 LESModel::correct(gradU);
287 if (mesh_.changing())
290 y_.boundaryField() = max(y_.boundaryField(), VSMALL);
293 const volScalarField S(this->S(gradU));
294 const volScalarField dTilda(this->dTilda(S));
295 const volScalarField STilda(this->STilda(S, dTilda));
297 tmp<fvScalarMatrix> nuTildaEqn
300 + fvm::div(phi(), nuTilda_)
303 (nuTilda_ + nu())/sigmaNut_,
305 "laplacian(DnuTildaEff,nuTilda)"
307 - Cb2_/sigmaNut_*magSqr(fvc::grad(nuTilda_))
310 - fvm::Sp(Cw1_*fw(STilda, dTilda)*nuTilda_/sqr(dTilda), nuTilda_)
313 nuTildaEqn().relax();
314 nuTildaEqn().solve();
316 bound(nuTilda_, dimensionedScalar("zero", nuTilda_.dimensions(), 0.0));
317 nuTilda_.correctBoundaryConditions();
319 updateSubGridScaleFields();
323 tmp<volScalarField> SpalartAllmaras::k() const
325 return sqr(nuSgs()/ck_/dTilda(S(fvc::grad(U()))));
329 tmp<volScalarField> SpalartAllmaras::epsilon() const
331 return 2*nuEff()*magSqr(symm(fvc::grad(U())));
335 tmp<volSymmTensorField> SpalartAllmaras::B() const
337 return ((2.0/3.0)*I)*k() - nuSgs()*twoSymm(fvc::grad(U()));
341 tmp<volSymmTensorField> SpalartAllmaras::devBeff() const
343 return -nuEff()*dev(twoSymm(fvc::grad(U())));
347 tmp<fvVectorMatrix> SpalartAllmaras::divDevBeff(volVectorField& U) const
351 - fvm::laplacian(nuEff(), U) - fvc::div(nuEff()*dev(T(fvc::grad(U))))
356 bool SpalartAllmaras::read()
358 if (LESModel::read())
360 sigmaNut_.readIfPresent(coeffDict());
361 kappa_.readIfPresent(*this);
362 Cb1_.readIfPresent(coeffDict());
363 Cb2_.readIfPresent(coeffDict());
364 Cv1_.readIfPresent(coeffDict());
365 Cv2_.readIfPresent(coeffDict());
366 CDES_.readIfPresent(coeffDict());
367 ck_.readIfPresent(coeffDict());
368 Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
369 Cw2_.readIfPresent(coeffDict());
370 Cw3_.readIfPresent(coeffDict());
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 } // End namespace LESModels
384 } // End namespace incompressible
385 } // End namespace Foam
387 // ************************************************************************* //