1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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"
30 #include "backwardsCompatibilityWallFunctions.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace compressible
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(SpalartAllmaras, 0);
44 addToRunTimeSelectionTable(RASModel, SpalartAllmaras, dictionary);
46 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 tmp<volScalarField> SpalartAllmaras::chi() const
50 return rho_*nuTilda_/mu();
54 tmp<volScalarField> SpalartAllmaras::fv1(const volScalarField& chi) const
56 volScalarField chi3 = pow3(chi);
57 return chi3/(chi3 + pow3(Cv1_));
61 tmp<volScalarField> SpalartAllmaras::fv2
63 const volScalarField& chi,
64 const volScalarField& 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 volScalarField& rho,
111 const volVectorField& U,
112 const surfaceScalarField& phi,
113 const basicThermo& thermophysicalModel
116 RASModel(typeName, rho, U, phi, thermophysicalModel),
120 dimensioned<scalar>::lookupOrAddToDict
129 dimensioned<scalar>::lookupOrAddToDict
138 dimensioned<scalar>::lookupOrAddToDict
148 dimensioned<scalar>::lookupOrAddToDict
157 dimensioned<scalar>::lookupOrAddToDict
164 Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
167 dimensioned<scalar>::lookupOrAddToDict
176 dimensioned<scalar>::lookupOrAddToDict
185 dimensioned<scalar>::lookupOrAddToDict
194 dimensioned<scalar>::lookupOrAddToDict
238 autoCreateAlphat("alphat", mesh_)
244 alphat_.correctBoundaryConditions();
250 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
252 tmp<volSymmTensorField> SpalartAllmaras::R() const
254 return tmp<volSymmTensorField>
256 new volSymmTensorField
266 ((2.0/3.0)*I)*k() - (mut_/rho_)*dev(twoSymm(fvc::grad(U_)))
272 tmp<volSymmTensorField> SpalartAllmaras::devRhoReff() const
274 return tmp<volSymmTensorField>
276 new volSymmTensorField
286 -muEff()*dev(twoSymm(fvc::grad(U_)))
292 tmp<fvVectorMatrix> SpalartAllmaras::divDevRhoReff(volVectorField& U) const
294 volScalarField muEff_ = muEff();
298 - fvm::laplacian(muEff_, U)
299 - fvc::div(muEff_*dev2(fvc::grad(U)().T()))
304 bool SpalartAllmaras::read()
306 if (RASModel::read())
308 sigmaNut_.readIfPresent(coeffDict());
309 kappa_.readIfPresent(coeffDict());
310 Prt_.readIfPresent(coeffDict());
312 Cb1_.readIfPresent(coeffDict());
313 Cb2_.readIfPresent(coeffDict());
314 Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
315 Cw2_.readIfPresent(coeffDict());
316 Cw3_.readIfPresent(coeffDict());
317 Cv1_.readIfPresent(coeffDict());
318 Cv2_.readIfPresent(coeffDict());
329 void SpalartAllmaras::correct()
333 // Re-calculate viscosity
334 mut_ = rho_*nuTilda_*fv1(chi());
335 mut_.correctBoundaryConditions();
337 // Re-calculate thermal diffusivity
339 alphat_.correctBoundaryConditions();
346 if (mesh_.changing())
351 volScalarField chi = this->chi();
352 volScalarField fv1 = this->fv1(chi);
354 volScalarField Stilda =
355 fv3(chi, fv1)*::sqrt(2.0)*mag(skew(fvc::grad(U_)))
356 + fv2(chi, fv1)*nuTilda_/sqr(kappa_*d_);
358 tmp<fvScalarMatrix> nuTildaEqn
360 fvm::ddt(rho_, nuTilda_)
361 + fvm::div(phi_, nuTilda_)
362 - fvm::laplacian(DnuTildaEff(), nuTilda_)
363 - Cb2_/sigmaNut_*rho_*magSqr(fvc::grad(nuTilda_))
365 Cb1_*rho_*Stilda*nuTilda_
366 - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_*rho_/sqr(d_), nuTilda_)
369 nuTildaEqn().relax();
371 bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0));
372 nuTilda_.correctBoundaryConditions();
374 // Re-calculate viscosity
375 mut_.internalField() = fv1*nuTilda_.internalField()*rho_.internalField();
376 mut_.correctBoundaryConditions();
378 // Re-calculate thermal diffusivity
380 alphat_.correctBoundaryConditions();
384 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
386 } // End namespace RASModels
387 } // End namespace compressible
388 } // End namespace Foam
390 // ************************************************************************* //