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(RASModel, SpalartAllmaras, dictionary);
45 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
47 tmp<volScalarField> SpalartAllmaras::chi() const
53 tmp<volScalarField> SpalartAllmaras::fv1(const volScalarField& chi) const
55 volScalarField chi3 = pow3(chi);
56 return chi3/(chi3 + pow3(Cv1_));
60 tmp<volScalarField> SpalartAllmaras::fv2
62 const volScalarField& chi,
63 const volScalarField& fv1
66 return 1.0/pow3(scalar(1) + chi/Cv2_);
70 tmp<volScalarField> SpalartAllmaras::fv3
72 const volScalarField& chi,
73 const volScalarField& fv1
76 volScalarField chiByCv2 = (1/Cv2_)*chi;
81 *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
82 /pow3(scalar(1) + chiByCv2);
86 tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const
88 volScalarField r = min
92 max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL))
97 r.boundaryField() == 0.0;
99 volScalarField g = r + Cw2_*(pow6(r) - r);
101 return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
105 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
107 SpalartAllmaras::SpalartAllmaras
109 const volVectorField& U,
110 const surfaceScalarField& phi,
111 transportModel& lamTransportModel
114 RASModel(typeName, U, phi, lamTransportModel),
118 dimensioned<scalar>::lookupOrAddToDict
128 dimensioned<scalar>::lookupOrAddToDict
137 dimensioned<scalar>::lookupOrAddToDict
144 Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)),
147 dimensioned<scalar>::lookupOrAddToDict
156 dimensioned<scalar>::lookupOrAddToDict
165 dimensioned<scalar>::lookupOrAddToDict
174 dimensioned<scalar>::lookupOrAddToDict
214 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
216 tmp<volScalarField> SpalartAllmaras::DnuTildaEff() const
218 return tmp<volScalarField>
220 new volScalarField("DnuTildaEff", alphaNut_*nuTilda_ + nu())
225 tmp<volScalarField> SpalartAllmaras::k() const
227 return tmp<volScalarField>
238 dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0)
244 tmp<volScalarField> SpalartAllmaras::epsilon() const
246 return tmp<volScalarField>
257 dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0)
263 tmp<volSymmTensorField> SpalartAllmaras::R() const
265 return tmp<volSymmTensorField>
267 new volSymmTensorField
277 ((2.0/3.0)*I)*k() - nut()*twoSymm(fvc::grad(U_))
283 tmp<volSymmTensorField> SpalartAllmaras::devReff() const
285 return tmp<volSymmTensorField>
287 new volSymmTensorField
297 -nuEff()*dev(twoSymm(fvc::grad(U_)))
303 tmp<fvVectorMatrix> SpalartAllmaras::divDevReff(volVectorField& U) const
305 volScalarField nuEff_ = nuEff();
309 - fvm::laplacian(nuEff_, U)
310 - fvc::div(nuEff_*dev(fvc::grad(U)().T()))
315 bool SpalartAllmaras::read()
317 if (RASModel::read())
319 alphaNut_.readIfPresent(coeffDict_);
321 Cb1_.readIfPresent(coeffDict_);
322 Cb2_.readIfPresent(coeffDict_);
323 Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_);
324 Cw2_.readIfPresent(coeffDict_);
325 Cw3_.readIfPresent(coeffDict_);
326 Cv1_.readIfPresent(coeffDict_);
327 Cv2_.readIfPresent(coeffDict_);
338 void SpalartAllmaras::correct()
340 transportModel_.correct();
349 if (mesh_.changing())
354 volScalarField chi = this->chi();
355 volScalarField fv1 = this->fv1(chi);
357 volScalarField Stilda =
358 fv3(chi, fv1)*::sqrt(2.0)*mag(skew(fvc::grad(U_)))
359 + fv2(chi, fv1)*nuTilda_/sqr(kappa_*d_);
361 tmp<fvScalarMatrix> nuTildaEqn
364 + fvm::div(phi_, nuTilda_)
365 - fvm::Sp(fvc::div(phi_), nuTilda_)
366 - fvm::laplacian(DnuTildaEff(), nuTilda_)
367 - alphaNut_*Cb2_*magSqr(fvc::grad(nuTilda_))
370 - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_/sqr(d_), nuTilda_)
373 nuTildaEqn().relax();
375 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
376 nuTilda_.correctBoundaryConditions();
378 nut_.internalField() = fv1*nuTilda_.internalField();
379 nut_.correctBoundaryConditions();
383 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385 } // End namespace RASModels
386 } // End namespace incompressible
387 } // End namespace Foam
389 // ************************************************************************* //