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