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 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 namespace incompressible
00035 {
00036 namespace LESModels
00037 {
00038 
00039 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00040 
00041 defineTypeNameAndDebug(SpalartAllmaras, 0);
00042 addToRunTimeSelectionTable(LESModel, SpalartAllmaras, dictionary);
00043 
00044 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00045 
00046 void SpalartAllmaras::updateSubGridScaleFields()
00047 {
00048     nuSgs_.internalField() = fv1()*nuTilda_.internalField();
00049     nuSgs_.correctBoundaryConditions();
00050 }
00051 
00052 
00053 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00054 
00055 tmp<volScalarField> SpalartAllmaras::fv1() const
00056 {
00057     volScalarField chi3 = pow3(nuTilda_/nu());
00058     return chi3/(chi3 + pow3(Cv1_));
00059 }
00060 
00061 
00062 tmp<volScalarField> SpalartAllmaras::fv2() const
00063 {
00064     return 1/pow3(scalar(1) + nuTilda_/(Cv2_*nu()));
00065 }
00066 
00067 
00068 tmp<volScalarField> SpalartAllmaras::fv3() const
00069 {
00070     volScalarField chi = nuTilda_/nu();
00071     volScalarField chiByCv2 = (1/Cv2_)*chi;
00072 
00073     return
00074         (scalar(1) + chi*fv1())
00075        *(1/Cv2_)
00076        *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2))
00077        /pow3(scalar(1) + chiByCv2);
00078 }
00079 
00080 
00081 tmp<volScalarField> SpalartAllmaras::S(const volTensorField& gradU) const
00082 {
00083     return sqrt(2.0)*mag(skew(gradU));
00084 }
00085 
00086 
00087 tmp<volScalarField> SpalartAllmaras::STilda
00088 (
00089     const volScalarField& S,
00090     const volScalarField& dTilda
00091 ) const
00092 {
00093     return fv3()*S + fv2()*nuTilda_/sqr(kappa_*dTilda);
00094 }
00095 
00096 
00097 tmp<volScalarField> SpalartAllmaras::r
00098 (
00099     const volScalarField& visc,
00100     const volScalarField& S,
00101     const volScalarField& dTilda
00102 ) const
00103 {
00104     return min
00105     (
00106         visc
00107        /(
00108            max
00109            (
00110                S,
00111                dimensionedScalar("SMALL", S.dimensions(), SMALL)
00112            )
00113           *sqr(kappa_*dTilda)
00114          + dimensionedScalar
00115            (
00116                "ROOTVSMALL",
00117                dimensionSet(0, 2 , -1, 0, 0),
00118                ROOTVSMALL
00119            )
00120         ),
00121         scalar(10)
00122     );
00123 }
00124 
00125 
00126 tmp<volScalarField> SpalartAllmaras::fw
00127 (
00128     const volScalarField& S,
00129     const volScalarField& dTilda
00130 ) const
00131 {
00132     volScalarField r = this->r(nuTilda_, S, dTilda);
00133 
00134     volScalarField g = r + Cw2_*(pow6(r) - r);
00135 
00136     return g*pow((1 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0);
00137 }
00138 
00139 
00140 tmp<volScalarField> SpalartAllmaras::dTilda(const volScalarField&) const
00141 {
00142     return min(CDES_*delta(), y_);
00143 }
00144 
00145 
00146 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00147 
00148 SpalartAllmaras::SpalartAllmaras
00149 (
00150     const volVectorField& U,
00151     const surfaceScalarField& phi,
00152     transportModel& transport,
00153     const word& modelName
00154 )
00155 :
00156     LESModel(modelName, U, phi, transport),
00157 
00158     sigmaNut_
00159     (
00160         dimensioned<scalar>::lookupOrAddToDict
00161         (
00162             "sigmaNut",
00163             coeffDict_,
00164             0.66666
00165         )
00166     ),
00167     kappa_
00168     (
00169         dimensioned<scalar>::lookupOrAddToDict
00170         (
00171             "kappa",
00172             coeffDict_,
00173             0.41
00174         )
00175     ),
00176     Cb1_
00177     (
00178         dimensioned<scalar>::lookupOrAddToDict
00179         (
00180             "Cb1",
00181             coeffDict_,
00182             0.1355
00183         )
00184     ),
00185     Cb2_
00186     (
00187         dimensioned<scalar>::lookupOrAddToDict
00188         (
00189             "Cb2",
00190             coeffDict_,
00191             0.622
00192         )
00193     ),
00194     Cv1_
00195     (
00196         dimensioned<scalar>::lookupOrAddToDict
00197         (
00198             "Cv1",
00199             coeffDict_,
00200             7.1
00201         )
00202     ),
00203     Cv2_
00204     (
00205         dimensioned<scalar>::lookupOrAddToDict
00206         (
00207             "Cv2",
00208             coeffDict_,
00209             5.0
00210         )
00211     ),
00212     CDES_
00213     (
00214         dimensioned<scalar>::lookupOrAddToDict
00215         (
00216             "CDES",
00217             coeffDict_,
00218             0.65
00219         )
00220     ),
00221     ck_
00222     (
00223         dimensioned<scalar>::lookupOrAddToDict
00224         (
00225             "ck",
00226             coeffDict_,
00227             0.07
00228         )
00229     ),
00230     Cw1_(Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
00231     Cw2_
00232     (
00233         dimensioned<scalar>::lookupOrAddToDict
00234         (
00235             "Cw2",
00236             coeffDict_,
00237             0.3
00238         )
00239     ),
00240     Cw3_
00241     (
00242         dimensioned<scalar>::lookupOrAddToDict
00243         (
00244             "Cw3",
00245             coeffDict_,
00246             2.0
00247         )
00248     ),
00249 
00250     y_(mesh_),
00251 
00252     nuTilda_
00253     (
00254         IOobject
00255         (
00256             "nuTilda",
00257             runTime_.timeName(),
00258             mesh_,
00259             IOobject::MUST_READ,
00260             IOobject::AUTO_WRITE
00261         ),
00262         mesh_
00263     ),
00264 
00265     nuSgs_
00266     (
00267         IOobject
00268         (
00269             "nuSgs",
00270             runTime_.timeName(),
00271             mesh_,
00272             IOobject::MUST_READ,
00273             IOobject::AUTO_WRITE
00274         ),
00275         mesh_
00276     )
00277 {
00278     updateSubGridScaleFields();
00279 }
00280 
00281 
00282 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00283 
00284 void SpalartAllmaras::correct(const tmp<volTensorField>& gradU)
00285 {
00286     LESModel::correct(gradU);
00287 
00288     if (mesh_.changing())
00289     {
00290         y_.correct();
00291         y_.boundaryField() = max(y_.boundaryField(), VSMALL);
00292     }
00293 
00294     const volScalarField S = this->S(gradU);
00295     const volScalarField dTilda = this->dTilda(S);
00296     const volScalarField STilda = this->STilda(S, dTilda);
00297 
00298     fvScalarMatrix nuTildaEqn
00299     (
00300         fvm::ddt(nuTilda_)
00301       + fvm::div(phi(), nuTilda_)
00302       - fvm::laplacian
00303         (
00304             (nuTilda_ + nu())/sigmaNut_,
00305             nuTilda_,
00306             "laplacian(DnuTildaEff,nuTilda)"
00307         )
00308       - Cb2_/sigmaNut_*magSqr(fvc::grad(nuTilda_))
00309      ==
00310         Cb1_*STilda*nuTilda_
00311       - fvm::Sp(Cw1_*fw(STilda, dTilda)*nuTilda_/sqr(dTilda), nuTilda_)
00312     );
00313 
00314     nuTildaEqn.relax();
00315     nuTildaEqn.solve();
00316 
00317     bound(nuTilda_, dimensionedScalar("zero", nuTilda_.dimensions(), 0.0));
00318     nuTilda_.correctBoundaryConditions();
00319 
00320     updateSubGridScaleFields();
00321 }
00322 
00323 
00324 tmp<volScalarField> SpalartAllmaras::k() const
00325 {
00326     return sqr(nuSgs()/ck_/dTilda(S(fvc::grad(U()))));
00327 }
00328 
00329 
00330 tmp<volScalarField> SpalartAllmaras::epsilon() const
00331 {
00332     return 2*nuEff()*magSqr(symm(fvc::grad(U())));
00333 }
00334 
00335 
00336 tmp<volSymmTensorField> SpalartAllmaras::B() const
00337 {
00338     return ((2.0/3.0)*I)*k() - nuSgs()*twoSymm(fvc::grad(U()));
00339 }
00340 
00341 
00342 tmp<volSymmTensorField> SpalartAllmaras::devBeff() const
00343 {
00344     return -nuEff()*dev(twoSymm(fvc::grad(U())));
00345 }
00346 
00347 
00348 tmp<fvVectorMatrix> SpalartAllmaras::divDevBeff(volVectorField& U) const
00349 {
00350     return
00351     (
00352       - fvm::laplacian(nuEff(), U) - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
00353     );
00354 }
00355 
00356 
00357 bool SpalartAllmaras::read()
00358 {
00359     if (LESModel::read())
00360     {
00361         sigmaNut_.readIfPresent(coeffDict());
00362         kappa_.readIfPresent(*this);
00363         Cb1_.readIfPresent(coeffDict());
00364         Cb2_.readIfPresent(coeffDict());
00365         Cv1_.readIfPresent(coeffDict());
00366         Cv2_.readIfPresent(coeffDict());
00367         CDES_.readIfPresent(coeffDict());
00368         ck_.readIfPresent(coeffDict());
00369         Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_;
00370         Cw2_.readIfPresent(coeffDict());
00371         Cw3_.readIfPresent(coeffDict());
00372 
00373         return true;
00374     }
00375     else
00376     {
00377         return false;
00378     }
00379 }
00380 
00381 
00382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00383 
00384 } // End namespace LESModels
00385 } // End namespace incompressible
00386 } // End namespace Foam
00387 
00388 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd