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

LaunderSharmaKE.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 "LaunderSharmaKE.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 
00030 #include "backwardsCompatibilityWallFunctions.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 namespace incompressible
00037 {
00038 namespace RASModels
00039 {
00040 
00041 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00042 
00043 defineTypeNameAndDebug(LaunderSharmaKE, 0);
00044 addToRunTimeSelectionTable(RASModel, LaunderSharmaKE, dictionary);
00045 
00046 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
00047 
00048 tmp<volScalarField> LaunderSharmaKE::fMu() const
00049 {
00050     return exp(-3.4/sqr(scalar(1) + sqr(k_)/(nu()*epsilonTilda_)/50.0));
00051 }
00052 
00053 
00054 tmp<volScalarField> LaunderSharmaKE::f2() const
00055 {
00056     return
00057         scalar(1)
00058       - 0.3*exp(-min(sqr(sqr(k_)/(nu()*epsilonTilda_)), scalar(50.0)));
00059 }
00060 
00061 
00062 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00063 
00064 LaunderSharmaKE::LaunderSharmaKE
00065 (
00066     const volVectorField& U,
00067     const surfaceScalarField& phi,
00068     transportModel& lamTransportModel
00069 )
00070 :
00071     RASModel(typeName, U, phi, lamTransportModel),
00072 
00073     Cmu_
00074     (
00075         dimensioned<scalar>::lookupOrAddToDict
00076         (
00077             "Cmu",
00078             coeffDict_,
00079             0.09
00080         )
00081     ),
00082     C1_
00083     (
00084         dimensioned<scalar>::lookupOrAddToDict
00085         (
00086             "C1",
00087             coeffDict_,
00088             1.44
00089         )
00090     ),
00091     C2_
00092     (
00093         dimensioned<scalar>::lookupOrAddToDict
00094         (
00095             "C2",
00096             coeffDict_,
00097             1.92
00098         )
00099     ),
00100     sigmaEps_
00101     (
00102         dimensioned<scalar>::lookupOrAddToDict
00103         (
00104             "sigmaEps",
00105             coeffDict_,
00106             1.3
00107         )
00108     ),
00109 
00110     k_
00111     (
00112         IOobject
00113         (
00114             "k",
00115             runTime_.timeName(),
00116             mesh_,
00117             IOobject::MUST_READ,
00118             IOobject::AUTO_WRITE
00119         ),
00120         mesh_
00121     ),
00122 
00123     epsilonTilda_
00124     (
00125         IOobject
00126         (
00127             "epsilon",
00128             runTime_.timeName(),
00129             mesh_,
00130             IOobject::MUST_READ,
00131             IOobject::AUTO_WRITE
00132         ),
00133         mesh_
00134     ),
00135 
00136     nut_
00137     (
00138         IOobject
00139         (
00140             "nut",
00141             runTime_.timeName(),
00142             mesh_,
00143             IOobject::NO_READ,
00144             IOobject::AUTO_WRITE
00145         ),
00146         autoCreateNut("nut", mesh_)
00147     )
00148 {
00149     nut_ = Cmu_*fMu()*sqr(k_)/(epsilonTilda_ + epsilonSmall_);
00150     nut_.correctBoundaryConditions();
00151 
00152     printCoeffs();
00153 }
00154 
00155 
00156 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00157 
00158 tmp<volSymmTensorField> LaunderSharmaKE::R() const
00159 {
00160     return tmp<volSymmTensorField>
00161     (
00162         new volSymmTensorField
00163         (
00164             IOobject
00165             (
00166                 "R",
00167                 runTime_.timeName(),
00168                 mesh_,
00169                 IOobject::NO_READ,
00170                 IOobject::NO_WRITE
00171             ),
00172             ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
00173             k_.boundaryField().types()
00174         )
00175     );
00176 }
00177 
00178 
00179 tmp<volSymmTensorField> LaunderSharmaKE::devReff() const
00180 {
00181     return tmp<volSymmTensorField>
00182     (
00183         new volSymmTensorField
00184         (
00185             IOobject
00186             (
00187                 "devRhoReff",
00188                 runTime_.timeName(),
00189                 mesh_,
00190                 IOobject::NO_READ,
00191                 IOobject::NO_WRITE
00192             ),
00193            -nuEff()*dev(twoSymm(fvc::grad(U_)))
00194         )
00195     );
00196 }
00197 
00198 
00199 tmp<fvVectorMatrix> LaunderSharmaKE::divDevReff(volVectorField& U) const
00200 {
00201     return
00202     (
00203       - fvm::laplacian(nuEff(), U)
00204       - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
00205     );
00206 }
00207 
00208 
00209 bool LaunderSharmaKE::read()
00210 {
00211     if (RASModel::read())
00212     {
00213         Cmu_.readIfPresent(coeffDict());
00214         C1_.readIfPresent(coeffDict());
00215         C2_.readIfPresent(coeffDict());
00216         sigmaEps_.readIfPresent(coeffDict());
00217 
00218         return true;
00219     }
00220     else
00221     {
00222         return false;
00223     }
00224 }
00225 
00226 
00227 void LaunderSharmaKE::correct()
00228 {
00229     RASModel::correct();
00230 
00231     if (!turbulence_)
00232     {
00233         return;
00234     }
00235 
00236     volScalarField S2 = 2*magSqr(symm(fvc::grad(U_)));
00237 
00238     volScalarField G = nut_*S2;
00239 
00240     volScalarField E = 2.0*nu()*nut_*fvc::magSqrGradGrad(U_);
00241     volScalarField D = 2.0*nu()*magSqr(fvc::grad(sqrt(k_)));
00242 
00243 
00244     // Dissipation rate equation
00245 
00246     tmp<fvScalarMatrix> epsEqn
00247     (
00248         fvm::ddt(epsilonTilda_)
00249       + fvm::div(phi_, epsilonTilda_)
00250       - fvm::laplacian(DepsilonEff(), epsilonTilda_)
00251      ==
00252         C1_*G*epsilonTilda_/k_
00253       - fvm::Sp(C2_*f2()*epsilonTilda_/k_, epsilonTilda_)
00254       + E
00255     );
00256 
00257     epsEqn().relax();
00258     solve(epsEqn);
00259     bound(epsilonTilda_, epsilon0_);
00260 
00261 
00262     // Turbulent kinetic energy equation
00263 
00264     tmp<fvScalarMatrix> kEqn
00265     (
00266         fvm::ddt(k_)
00267       + fvm::div(phi_, k_)
00268       - fvm::laplacian(DkEff(), k_)
00269      ==
00270         G - fvm::Sp((epsilonTilda_ + D)/k_, k_)
00271     );
00272 
00273     kEqn().relax();
00274     solve(kEqn);
00275     bound(k_, k0_);
00276 
00277 
00278     // Re-calculate viscosity
00279     nut_ = Cmu_*fMu()*sqr(k_)/epsilonTilda_;
00280     nut_.correctBoundaryConditions();
00281 }
00282 
00283 
00284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00285 
00286 } // End namespace RASModels
00287 } // End namespace incompressible
00288 } // End namespace Foam
00289 
00290 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd