1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace incompressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(SpalartAllmaras, 0);
43 addToRunTimeSelectionTable(LESModel, SpalartAllmaras, dictionary);
46 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 tmp<volScalarField> SpalartAllmaras::fv1() const
50 volScalarField chi3 = pow3(nuTilda_/nu());
51 return chi3/(chi3 + pow3(Cv1_));
55 tmp<volScalarField> SpalartAllmaras::fv2() const
57 volScalarField chi = nuTilda_/nu();
58 return 1.0/pow3(scalar(1) + chi/Cv2_);
62 tmp<volScalarField> SpalartAllmaras::fv3() const
64 volScalarField chi = nuTilda_/nu();
65 volScalarField chiByCv2 = (1/Cv2_)*chi;
68 (scalar(1) + chi*fv1())
70 *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
71 /pow3(scalar(1) + chiByCv2);
75 tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const
77 volScalarField r = min
81 max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL))
86 r.boundaryField() == 0.0;
88 volScalarField g = r + Cw2_*(pow6(r) - r);
90 return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
94 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
96 SpalartAllmaras::SpalartAllmaras
98 const volVectorField& U,
99 const surfaceScalarField& phi,
100 transportModel& transport
103 LESModel(typeName, U, phi, transport),
108 dimensioned<scalar>::lookupOrAddToDict
117 dimensioned<scalar>::lookupOrAddToDict
126 dimensioned<scalar>::lookupOrAddToDict
135 dimensioned<scalar>::lookupOrAddToDict
144 dimensioned<scalar>::lookupOrAddToDict
153 dimensioned<scalar>::lookupOrAddToDict
162 dimensioned<scalar>::lookupOrAddToDict
171 dimensioned<scalar>::lookupOrAddToDict
178 Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)),
181 dimensioned<scalar>::lookupOrAddToDict
190 dimensioned<scalar>::lookupOrAddToDict
211 dTilda_(min(CDES_*delta(), wallDist(mesh_).y())),
230 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
232 void SpalartAllmaras::correct(const tmp<volTensorField>& gradU)
234 LESModel::correct(gradU);
236 if (mesh_.changing())
238 dTilda_ = min(CDES_*delta(), wallDist(mesh_).y());
241 volScalarField Stilda =
242 fv3()*::sqrt(2.0)*mag(skew(gradU)) + fv2()*nuTilda_/sqr(kappa_*dTilda_);
247 + fvm::div(phi(), nuTilda_)
250 alphaNut_*(nuTilda_ + nu()),
252 "laplacian(DnuTildaEff,nuTilda)"
254 - alphaNut_*Cb2_*magSqr(fvc::grad(nuTilda_))
257 - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_/sqr(dTilda_), nuTilda_)
260 bound(nuTilda_, dimensionedScalar("zero", nuTilda_.dimensions(), 0.0));
261 nuTilda_.correctBoundaryConditions();
263 nuSgs_.internalField() = fv1()*nuTilda_.internalField();
264 nuSgs_.correctBoundaryConditions();
268 tmp<volScalarField> SpalartAllmaras::epsilon() const
270 return 2*nuEff()*magSqr(symm(fvc::grad(U())));
274 tmp<volSymmTensorField> SpalartAllmaras::B() const
276 return ((2.0/3.0)*I)*k() - nuSgs()*twoSymm(fvc::grad(U()));
280 tmp<volSymmTensorField> SpalartAllmaras::devBeff() const
282 return -nuEff()*dev(twoSymm(fvc::grad(U())));
286 tmp<fvVectorMatrix> SpalartAllmaras::divDevBeff(volVectorField& U) const
290 - fvm::laplacian(nuEff(), U) - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
295 bool SpalartAllmaras::read()
297 if (LESModel::read())
299 alphaNut_.readIfPresent(coeffDict());
300 Cb1_.readIfPresent(coeffDict());
301 Cb2_.readIfPresent(coeffDict());
302 Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_);
303 Cw2_.readIfPresent(coeffDict());
304 Cw3_.readIfPresent(coeffDict());
305 Cv1_.readIfPresent(coeffDict());
306 Cv2_.readIfPresent(coeffDict());
307 CDES_.readIfPresent(coeffDict());
308 ck_.readIfPresent(coeffDict());
309 kappa_.readIfPresent(*this);
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
322 } // End namespace LESModels
323 } // End namespace incompressible
324 } // End namespace Foam
326 // ************************************************************************* //