1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
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 #include "backwardsCompatibilityWallFunctions.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace compressible
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(SpalartAllmaras, 0);
43 addToRunTimeSelectionTable(RASModel, SpalartAllmaras, dictionary);
45 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
47 tmp<volScalarField> SpalartAllmaras::chi() const
49 return rho_*nuTilda_/mu();
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 volScalarField& rho,
110 const volVectorField& U,
111 const surfaceScalarField& phi,
112 const basicThermo& thermophysicalModel
115 RASModel(typeName, rho, U, phi, thermophysicalModel),
119 dimensioned<scalar>::lookupOrAddToDict
128 dimensioned<scalar>::lookupOrAddToDict
137 dimensioned<scalar>::lookupOrAddToDict
147 dimensioned<scalar>::lookupOrAddToDict
156 dimensioned<scalar>::lookupOrAddToDict
163 Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
166 dimensioned<scalar>::lookupOrAddToDict
175 dimensioned<scalar>::lookupOrAddToDict
184 dimensioned<scalar>::lookupOrAddToDict
193 dimensioned<scalar>::lookupOrAddToDict
237 autoCreateAlphat("alphat", mesh_)
243 alphat_.correctBoundaryConditions();
249 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
251 tmp<volSymmTensorField> SpalartAllmaras::R() const
253 return tmp<volSymmTensorField>
255 new volSymmTensorField
265 ((2.0/3.0)*I)*k() - (mut_/rho_)*dev(twoSymm(fvc::grad(U_)))
271 tmp<volSymmTensorField> SpalartAllmaras::devRhoReff() const
273 return tmp<volSymmTensorField>
275 new volSymmTensorField
285 -muEff()*dev(twoSymm(fvc::grad(U_)))
291 tmp<fvVectorMatrix> SpalartAllmaras::divDevRhoReff(volVectorField& U) const
293 volScalarField muEff_ = muEff();
297 - fvm::laplacian(muEff_, U)
298 - fvc::div(muEff_*dev2(fvc::grad(U)().T()))
303 bool SpalartAllmaras::read()
305 if (RASModel::read())
307 sigmaNut_.readIfPresent(coeffDict());
308 kappa_.readIfPresent(coeffDict());
309 Prt_.readIfPresent(coeffDict());
311 Cb1_.readIfPresent(coeffDict());
312 Cb2_.readIfPresent(coeffDict());
313 Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
314 Cw2_.readIfPresent(coeffDict());
315 Cw3_.readIfPresent(coeffDict());
316 Cv1_.readIfPresent(coeffDict());
317 Cv2_.readIfPresent(coeffDict());
328 void SpalartAllmaras::correct()
332 // Re-calculate viscosity
333 mut_ = rho_*nuTilda_*fv1(chi());
334 mut_.correctBoundaryConditions();
336 // Re-calculate thermal diffusivity
338 alphat_.correctBoundaryConditions();
345 if (mesh_.changing())
350 volScalarField chi = this->chi();
351 volScalarField fv1 = this->fv1(chi);
353 volScalarField Stilda =
354 fv3(chi, fv1)*::sqrt(2.0)*mag(skew(fvc::grad(U_)))
355 + fv2(chi, fv1)*nuTilda_/sqr(kappa_*d_);
357 tmp<fvScalarMatrix> nuTildaEqn
359 fvm::ddt(rho_, nuTilda_)
360 + fvm::div(phi_, nuTilda_)
361 - fvm::laplacian(DnuTildaEff(), nuTilda_)
362 - Cb2_/sigmaNut_*rho_*magSqr(fvc::grad(nuTilda_))
364 Cb1_*rho_*Stilda*nuTilda_
365 - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_*rho_/sqr(d_), nuTilda_)
368 nuTildaEqn().relax();
370 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
371 nuTilda_.correctBoundaryConditions();
373 // Re-calculate viscosity
374 mut_.internalField() = fv1*nuTilda_.internalField()*rho_.internalField();
375 mut_.correctBoundaryConditions();
377 // Re-calculate thermal diffusivity
379 alphat_.correctBoundaryConditions();
383 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385 } // End namespace RASModels
386 } // End namespace compressible
387 } // End namespace Foam
389 // ************************************************************************* //