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 compressible
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) + rho_*sqr(k_)/(mu()*epsilon_)/50.0));
00051 }
00052 
00053 
00054 tmp<volScalarField> LaunderSharmaKE::f2() const
00055 {
00056     return
00057         scalar(1)
00058       - 0.3*exp(-min(sqr(rho_*sqr(k_)/(mu()*epsilon_)), scalar(50.0)));
00059 }
00060 
00061 
00062 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00063 
00064 LaunderSharmaKE::LaunderSharmaKE
00065 (
00066     const volScalarField& rho,
00067     const volVectorField& U,
00068     const surfaceScalarField& phi,
00069     const basicThermo& thermophysicalModel
00070 )
00071 :
00072     RASModel(typeName, rho, U, phi, thermophysicalModel),
00073 
00074     Cmu_
00075     (
00076         dimensioned<scalar>::lookupOrAddToDict
00077         (
00078             "Cmu",
00079             coeffDict_,
00080             0.09
00081         )
00082     ),
00083     C1_
00084     (
00085         dimensioned<scalar>::lookupOrAddToDict
00086         (
00087             "C1",
00088             coeffDict_,
00089             1.44
00090         )
00091     ),
00092     C2_
00093     (
00094         dimensioned<scalar>::lookupOrAddToDict
00095         (
00096             "C2",
00097             coeffDict_,
00098             1.92
00099         )
00100     ),
00101     C3_
00102     (
00103         dimensioned<scalar>::lookupOrAddToDict
00104         (
00105             "C3",
00106             coeffDict_,
00107             -0.33
00108         )
00109     ),
00110     sigmak_
00111     (
00112         dimensioned<scalar>::lookupOrAddToDict
00113         (
00114             "sigmak",
00115             coeffDict_,
00116             1.0
00117         )
00118     ),
00119     sigmaEps_
00120     (
00121         dimensioned<scalar>::lookupOrAddToDict
00122         (
00123             "sigmaEps",
00124             coeffDict_,
00125             1.3
00126         )
00127     ),
00128     Prt_
00129     (
00130         dimensioned<scalar>::lookupOrAddToDict
00131         (
00132             "Prt",
00133             coeffDict_,
00134             1.0
00135         )
00136     ),
00137 
00138     k_
00139     (
00140         IOobject
00141         (
00142             "k",
00143             runTime_.timeName(),
00144             mesh_,
00145             IOobject::NO_READ,
00146             IOobject::AUTO_WRITE
00147         ),
00148         autoCreateK("k", mesh_)
00149     ),
00150 
00151     epsilon_
00152     (
00153         IOobject
00154         (
00155             "epsilon",
00156             runTime_.timeName(),
00157             mesh_,
00158             IOobject::NO_READ,
00159             IOobject::AUTO_WRITE
00160         ),
00161         autoCreateEpsilon("epsilon", mesh_)
00162     ),
00163 
00164     mut_
00165     (
00166         IOobject
00167         (
00168             "mut",
00169             runTime_.timeName(),
00170             mesh_,
00171             IOobject::NO_READ,
00172             IOobject::NO_WRITE
00173         ),
00174         autoCreateMut("mut", mesh_)
00175     ),
00176 
00177     alphat_
00178     (
00179         IOobject
00180         (
00181             "alphat",
00182             runTime_.timeName(),
00183             mesh_,
00184             IOobject::NO_READ,
00185             IOobject::AUTO_WRITE
00186         ),
00187         autoCreateAlphat("alphat", mesh_)
00188     )
00189 {
00190     mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
00191     mut_.correctBoundaryConditions();
00192 
00193     alphat_ = mut_/Prt_;
00194     alphat_.correctBoundaryConditions();
00195 
00196     printCoeffs();
00197 }
00198 
00199 
00200 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00201 
00202 tmp<volSymmTensorField> LaunderSharmaKE::R() const
00203 {
00204     return tmp<volSymmTensorField>
00205     (
00206         new volSymmTensorField
00207         (
00208             IOobject
00209             (
00210                 "R",
00211                 runTime_.timeName(),
00212                 mesh_,
00213                 IOobject::NO_READ,
00214                 IOobject::NO_WRITE
00215             ),
00216             ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
00217             k_.boundaryField().types()
00218         )
00219     );
00220 }
00221 
00222 
00223 tmp<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
00224 {
00225     return tmp<volSymmTensorField>
00226     (
00227         new volSymmTensorField
00228         (
00229             IOobject
00230             (
00231                 "devRhoReff",
00232                 runTime_.timeName(),
00233                 mesh_,
00234                 IOobject::NO_READ,
00235                 IOobject::NO_WRITE
00236             ),
00237            -muEff()*dev(twoSymm(fvc::grad(U_)))
00238         )
00239     );
00240 }
00241 
00242 
00243 tmp<fvVectorMatrix> LaunderSharmaKE::divDevRhoReff(volVectorField& U) const
00244 {
00245     return
00246     (
00247       - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
00248     );
00249 }
00250 
00251 
00252 bool LaunderSharmaKE::read()
00253 {
00254     if (RASModel::read())
00255     {
00256         Cmu_.readIfPresent(coeffDict());
00257         C1_.readIfPresent(coeffDict());
00258         C2_.readIfPresent(coeffDict());
00259         C3_.readIfPresent(coeffDict());
00260         sigmak_.readIfPresent(coeffDict());
00261         sigmaEps_.readIfPresent(coeffDict());
00262         Prt_.readIfPresent(coeffDict());
00263 
00264         return true;
00265     }
00266     else
00267     {
00268         return false;
00269     }
00270 }
00271 
00272 
00273 void LaunderSharmaKE::correct()
00274 {
00275     if (!turbulence_)
00276     {
00277         // Re-calculate viscosity
00278         mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
00279         mut_.correctBoundaryConditions();
00280 
00281         // Re-calculate thermal diffusivity
00282         alphat_ = mut_/Prt_;
00283         alphat_.correctBoundaryConditions();
00284 
00285         return;
00286     }
00287 
00288     RASModel::correct();
00289 
00290     // Calculate parameters and coefficients for Launder-Sharma low-Reynolds
00291     // number model
00292 
00293     volScalarField E = 2.0*mu()*mut_*fvc::magSqrGradGrad(U_)/rho_;
00294     volScalarField D = 2.0*mu()*magSqr(fvc::grad(sqrt(k_)))/rho_;
00295 
00296     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
00297 
00298     if (mesh_.moving())
00299     {
00300         divU += fvc::div(mesh_.phi());
00301     }
00302 
00303     tmp<volTensorField> tgradU = fvc::grad(U_);
00304     volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
00305     tgradU.clear();
00306 
00307     // Update espsilon and G at the wall
00308     epsilon_.boundaryField().updateCoeffs();
00309 
00310     // Dissipation equation
00311 
00312     tmp<fvScalarMatrix> epsEqn
00313     (
00314         fvm::ddt(rho_, epsilon_)
00315       + fvm::div(phi_, epsilon_)
00316       - fvm::laplacian(DepsilonEff(), epsilon_)
00317      ==
00318         C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_)
00319       - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_)
00320     //+ 0.75*1.5*flameKproduction*epsilon_/k_
00321       + E
00322     );
00323 
00324     epsEqn().relax();
00325 
00326     epsEqn().boundaryManipulate(epsilon_.boundaryField());
00327 
00328     solve(epsEqn);
00329     bound(epsilon_, epsilon0_);
00330 
00331 
00332     // Turbulent kinetic energy equation
00333 
00334     tmp<fvScalarMatrix> kEqn
00335     (
00336         fvm::ddt(rho_, k_)
00337       + fvm::div(phi_, k_)
00338       - fvm::laplacian(DkEff(), k_)
00339      ==
00340         G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
00341       - fvm::Sp(rho_*(epsilon_ + D)/k_, k_)
00342     //+ flameKproduction
00343     );
00344 
00345     kEqn().relax();
00346     solve(kEqn);
00347     bound(k_, k0_);
00348 
00349 
00350     // Re-calculate viscosity
00351     mut_ = Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
00352     mut_.correctBoundaryConditions();
00353 
00354     // Re-calculate thermal diffusivity
00355     alphat_ = mut_/Prt_;
00356     alphat_.correctBoundaryConditions();
00357 }
00358 
00359 
00360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00361 
00362 } // End namespace RASModels
00363 } // End namespace compressible
00364 } // End namespace Foam
00365 
00366 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd