OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

SpalartAllmaras.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "SpalartAllmaras.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "wallDist.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 namespace compressible
00036 {
00037 namespace LESModels
00038 {
00039 
00040 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00041 
00042 defineTypeNameAndDebug(SpalartAllmaras, 0);
00043 addToRunTimeSelectionTable(LESModel, SpalartAllmaras, dictionary);
00044 
00045 
00046 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
00047 
00048 void SpalartAllmaras::updateSubGridScaleFields()
00049 {
00050     muSgs_.internalField() = rho()*fv1()*nuTilda_.internalField();
00051     muSgs_.correctBoundaryConditions();
00052 
00053     alphaSgs_ = muSgs_/Prt_;
00054     alphaSgs_.correctBoundaryConditions();
00055 }
00056 
00057 
00058 tmp<volScalarField> SpalartAllmaras::fv1() const
00059 {
00060     volScalarField chi3 = pow3(rho()*nuTilda_/mu());
00061     return chi3/(chi3 + pow3(Cv1_));
00062 }
00063 
00064 
00065 tmp<volScalarField> SpalartAllmaras::fv2() const
00066 {
00067     return 1.0/pow3(scalar(1) + rho()*nuTilda_/(mu()*Cv2_));
00068 }
00069 
00070 
00071 tmp<volScalarField> SpalartAllmaras::fv3() const
00072 {
00073     volScalarField chi = rho()*nuTilda_/mu();
00074     volScalarField chiByCv2 = (1/Cv2_)*chi;
00075 
00076     return
00077         (scalar(1) + chi*fv1())
00078        *(1/Cv2_)
00079        *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
00080        /pow3(scalar(1) + chiByCv2);
00081 }
00082 
00083 
00084 tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const
00085 {
00086     volScalarField r = min
00087     (
00088         nuTilda_
00089        /(
00090            max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL))
00091           *sqr(kappa_*dTilda_)
00092         ),
00093         scalar(10.0)
00094     );
00095     r.boundaryField() == 0.0;
00096 
00097     volScalarField g = r + Cw2_*(pow6(r) - r);
00098 
00099     return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
00100 }
00101 
00102 
00103 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00104 
00105 SpalartAllmaras::SpalartAllmaras
00106 (
00107     const volScalarField& rho,
00108     const volVectorField& U,
00109     const surfaceScalarField& phi,
00110     const basicThermo& thermoPhysicalModel
00111 )
00112 :
00113     LESModel(typeName, rho, U, phi, thermoPhysicalModel),
00114 
00115     sigmaNut_
00116     (
00117         dimensioned<scalar>::lookupOrAddToDict
00118         (
00119             "sigmaNut",
00120             coeffDict_,
00121             0.66666
00122         )
00123     ),
00124     Prt_
00125     (
00126         dimensioned<scalar>::lookupOrAddToDict
00127         (
00128             "Prt",
00129             coeffDict_,
00130             1.0
00131         )
00132     ),
00133 
00134     Cb1_
00135     (
00136         dimensioned<scalar>::lookupOrAddToDict
00137         (
00138             "Cb1",
00139             coeffDict_,
00140             0.1355
00141         )
00142     ),
00143     Cb2_
00144     (
00145         dimensioned<scalar>::lookupOrAddToDict
00146         (
00147             "Cb2",
00148             coeffDict_,
00149             0.622
00150         )
00151     ),
00152     Cv1_
00153     (
00154         dimensioned<scalar>::lookupOrAddToDict
00155         (
00156             "Cv1",
00157             coeffDict_,
00158             7.1
00159         )
00160     ),
00161     Cv2_
00162     (
00163         dimensioned<scalar>::lookupOrAddToDict
00164         (
00165             "Cv2",
00166             coeffDict_,
00167             5.0
00168         )
00169     ),
00170     CDES_
00171     (
00172         dimensioned<scalar>::lookupOrAddToDict
00173         (
00174             "CDES",
00175             coeffDict_,
00176             0.65
00177         )
00178     ),
00179     ck_
00180     (
00181         dimensioned<scalar>::lookupOrAddToDict
00182         (
00183             "ck",
00184             coeffDict_,
00185             0.07
00186         )
00187     ),
00188     kappa_
00189     (
00190         dimensioned<scalar>::lookupOrAddToDict
00191         (
00192             "kappa",
00193             *this,
00194             0.41
00195         )
00196     ),
00197     Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
00198     Cw2_
00199     (
00200         dimensioned<scalar>::lookupOrAddToDict
00201         (
00202             "Cw2",
00203             coeffDict_,
00204             0.3
00205         )
00206     ),
00207     Cw3_
00208     (
00209         dimensioned<scalar>::lookupOrAddToDict
00210         (
00211             "Cw3",
00212             coeffDict_,
00213             2.0
00214         )
00215     ),
00216 
00217     nuTilda_
00218     (
00219         IOobject
00220         (
00221             "nuTilda",
00222             runTime_.timeName(),
00223             mesh_,
00224             IOobject::MUST_READ,
00225             IOobject::AUTO_WRITE
00226         ),
00227         mesh_
00228     ),
00229 
00230     dTilda_(min(CDES_*delta(), wallDist(mesh_).y())),
00231     muSgs_
00232     (
00233         IOobject
00234         (
00235             "muSgs",
00236             runTime_.timeName(),
00237             mesh_,
00238             IOobject::MUST_READ,
00239             IOobject::AUTO_WRITE
00240         ),
00241         mesh_
00242     ),
00243 
00244     alphaSgs_
00245     (
00246         IOobject
00247         (
00248             "alphaSgs",
00249             runTime_.timeName(),
00250             mesh_,
00251             IOobject::MUST_READ,
00252             IOobject::AUTO_WRITE
00253         ),
00254         mesh_
00255     )
00256 {
00257     updateSubGridScaleFields();
00258 
00259     printCoeffs();
00260 }
00261 
00262 
00263 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00264 
00265 tmp<volSymmTensorField> SpalartAllmaras::B() const
00266 {
00267     return ((2.0/3.0)*I)*k() - (muSgs_/rho())*dev(twoSymm(fvc::grad(U())));
00268 }
00269 
00270 
00271 tmp<volSymmTensorField> SpalartAllmaras::devRhoBeff() const
00272 {
00273     return -muEff()*dev(twoSymm(fvc::grad(U())));
00274 }
00275 
00276 
00277 tmp<volScalarField> SpalartAllmaras::epsilon() const
00278 {
00279     return 2*muEff()/rho()*magSqr(symm(fvc::grad(U())));
00280 }
00281 
00282 
00283 tmp<fvVectorMatrix> SpalartAllmaras::divDevRhoBeff(volVectorField& U) const
00284 {
00285     return
00286     (
00287       - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
00288     );
00289 }
00290 
00291 
00292 void SpalartAllmaras::correct(const tmp<volTensorField>& tgradU)
00293 {
00294     const volTensorField& gradU = tgradU();
00295     LESModel::correct(gradU);
00296 
00297     if (mesh_.changing())
00298     {
00299         dTilda_ = min(CDES_*delta(), wallDist(mesh_).y());
00300     }
00301 
00302     volScalarField Stilda =
00303         fv3()*::sqrt(2.0)*mag(skew(gradU)) + fv2()*nuTilda_/sqr(kappa_*dTilda_);
00304 
00305     solve
00306     (
00307         fvm::ddt(rho(), nuTilda_)
00308       + fvm::div(phi(), nuTilda_)
00309       - fvm::laplacian
00310         (
00311             (nuTilda_*rho() + mu())/sigmaNut_,
00312             nuTilda_,
00313             "laplacian(DnuTildaEff,nuTilda)"
00314         )
00315       - rho()*Cb2_/sigmaNut_*magSqr(fvc::grad(nuTilda_))
00316      ==
00317         rho()*Cb1_*Stilda*nuTilda_
00318       - fvm::Sp(rho()*Cw1_*fw(Stilda)*nuTilda_/sqr(dTilda_), nuTilda_)
00319     );
00320 
00321     bound(nuTilda_, dimensionedScalar("zero", nuTilda_.dimensions(), 0.0));
00322     nuTilda_.correctBoundaryConditions();
00323 
00324     updateSubGridScaleFields();
00325 }
00326 
00327 
00328 bool SpalartAllmaras::read()
00329 {
00330     if (LESModel::read())
00331     {
00332         sigmaNut_.readIfPresent(coeffDict());
00333         Prt_.readIfPresent(coeffDict());
00334         Cb1_.readIfPresent(coeffDict());
00335         Cb2_.readIfPresent(coeffDict());
00336         Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
00337         Cw2_.readIfPresent(coeffDict());
00338         Cw3_.readIfPresent(coeffDict());
00339         Cv1_.readIfPresent(coeffDict());
00340         Cv2_.readIfPresent(coeffDict());
00341         CDES_.readIfPresent(coeffDict());
00342         ck_.readIfPresent(coeffDict());
00343         kappa_.readIfPresent(*this);
00344 
00345         return true;
00346     }
00347     else
00348     {
00349         return false;
00350     }
00351 }
00352 
00353 
00354 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00355 
00356 } // End namespace LESModels
00357 } // End namespace compressible
00358 } // End namespace Foam
00359 
00360 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd