1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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 volScalarField chi3 = pow3(chi);
54 return chi3/(chi3 + pow3(Cv1_));
58 tmp<volScalarField> SpalartAllmaras::fv2
60 const volScalarField& chi,
61 const volScalarField& fv1
64 // Model adjustment, Eric Paterson: boundedness of
65 // turbulent viscosity. HJ, 24/Aug/2010
66 return 1.0 - chi/(1.0 + chi*fv1);
67 //return 1.0/pow3(scalar(1) + chi/Cv2);
71 tmp<volScalarField> SpalartAllmaras::fv3
73 const volScalarField& chi,
74 const volScalarField& fv1
77 volScalarField chiByCv2 = (1/Cv2_)*chi;
82 *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
83 /pow3(scalar(1) + chiByCv2);
87 tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const
89 volScalarField r = min
93 max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL))
98 r.boundaryField() == 0.0;
100 volScalarField g = r + Cw2_*(pow6(r) - r);
102 return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
106 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
108 SpalartAllmaras::SpalartAllmaras
110 const volVectorField& U,
111 const surfaceScalarField& phi,
112 transportModel& lamTransportModel
115 RASModel(typeName, U, phi, lamTransportModel),
119 dimensionedScalar::lookupOrAddToDict
128 dimensionedScalar::lookupOrAddToDict
138 dimensionedScalar::lookupOrAddToDict
147 dimensionedScalar::lookupOrAddToDict
154 Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
157 dimensionedScalar::lookupOrAddToDict
166 dimensionedScalar::lookupOrAddToDict
175 dimensionedScalar::lookupOrAddToDict
184 dimensionedScalar::lookupOrAddToDict
224 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
226 tmp<volScalarField> SpalartAllmaras::DnuTildaEff() const
228 return tmp<volScalarField>
230 new volScalarField("DnuTildaEff", nuTilda_/sigmaNut_ + nu())
235 tmp<volScalarField> SpalartAllmaras::k() const
237 return tmp<volScalarField>
248 dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0)
254 tmp<volScalarField> SpalartAllmaras::epsilon() const
256 return tmp<volScalarField>
267 dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0)
273 tmp<volSymmTensorField> SpalartAllmaras::R() const
275 return tmp<volSymmTensorField>
277 new volSymmTensorField
287 ((2.0/3.0)*I)*k() - nut()*twoSymm(fvc::grad(U_))
293 tmp<volSymmTensorField> SpalartAllmaras::devReff() const
295 return tmp<volSymmTensorField>
297 new volSymmTensorField
307 -nuEff()*dev(twoSymm(fvc::grad(U_)))
313 tmp<fvVectorMatrix> SpalartAllmaras::divDevReff(volVectorField& U) const
315 volScalarField nuEff_ = nuEff();
319 - fvm::laplacian(nuEff_, U)
320 - fvc::div(nuEff_*dev(fvc::grad(U)().T()))
325 bool SpalartAllmaras::read()
327 if (RASModel::read())
329 sigmaNut_.readIfPresent(coeffDict());
331 Cb1_.readIfPresent(coeffDict());
332 Cb2_.readIfPresent(coeffDict());
333 Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
334 Cw2_.readIfPresent(coeffDict());
335 Cw3_.readIfPresent(coeffDict());
336 Cv1_.readIfPresent(coeffDict());
337 Cv2_.readIfPresent(coeffDict());
348 void SpalartAllmaras::correct()
350 if (mesh_.changing())
352 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
362 if (mesh_.changing())
367 volScalarField chi = this->chi();
368 volScalarField fv1 = this->fv1(chi);
370 volScalarField Stilda =
371 // fv3(chi, fv1)*::sqrt(2.0)*mag(skew(fvc::grad(U_)))
372 sqrt(2.0)*mag(skew(fvc::grad(U_)))
373 + fv2(chi, fv1)*nuTilda_/sqr(kappa_*d_);
375 tmp<fvScalarMatrix> nuTildaEqn
378 + fvm::div(phi_, nuTilda_)
379 + fvm::SuSp(-fvc::div(phi_), nuTilda_)
380 - fvm::laplacian(DnuTildaEff(), nuTilda_)
381 - Cb2_/sigmaNut_*magSqr(fvc::grad(nuTilda_))
384 - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_/sqr(d_), nuTilda_)
387 nuTildaEqn().relax();
389 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
390 nuTilda_.correctBoundaryConditions();
392 nut_.internalField() = fv1*nuTilda_.internalField();
393 nut_ = min(nut_, nuRatio()*nu());
394 nut_.correctBoundaryConditions();
398 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
400 } // End namespace RASModels
401 } // End namespace incompressible
402 } // End namespace Foam
404 // ************************************************************************* //