FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "LaunderSharmaKE.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 
00029 #include <compressibleRASModels/backwardsCompatibilityWallFunctions.H>
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 namespace compressible
00036 {
00037 namespace RASModels
00038 {
00039 
00040 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00041 
00042 defineTypeNameAndDebug(LaunderSharmaKE, 0);
00043 addToRunTimeSelectionTable(RASModel, LaunderSharmaKE, dictionary);
00044 
00045 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
00046 
00047 tmp<volScalarField> LaunderSharmaKE::fMu() const
00048 {
00049     return exp(-3.4/sqr(scalar(1) + rho_*sqr(k_)/(mu()*epsilon_)/50.0));
00050 }
00051 
00052 
00053 tmp<volScalarField> LaunderSharmaKE::f2() const
00054 {
00055     return
00056         scalar(1)
00057       - 0.3*exp(-min(sqr(rho_*sqr(k_)/(mu()*epsilon_)), scalar(50.0)));
00058 }
00059 
00060 
00061 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00062 
00063 LaunderSharmaKE::LaunderSharmaKE
00064 (
00065     const volScalarField& rho,
00066     const volVectorField& U,
00067     const surfaceScalarField& phi,
00068     const basicThermo& thermophysicalModel
00069 )
00070 :
00071     RASModel(typeName, rho, U, phi, thermophysicalModel),
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     C3_
00101     (
00102         dimensioned<scalar>::lookupOrAddToDict
00103         (
00104             "C3",
00105             coeffDict_,
00106             -0.33
00107         )
00108     ),
00109     sigmak_
00110     (
00111         dimensioned<scalar>::lookupOrAddToDict
00112         (
00113             "sigmak",
00114             coeffDict_,
00115             1.0
00116         )
00117     ),
00118     sigmaEps_
00119     (
00120         dimensioned<scalar>::lookupOrAddToDict
00121         (
00122             "sigmaEps",
00123             coeffDict_,
00124             1.3
00125         )
00126     ),
00127     Prt_
00128     (
00129         dimensioned<scalar>::lookupOrAddToDict
00130         (
00131             "Prt",
00132             coeffDict_,
00133             1.0
00134         )
00135     ),
00136 
00137     k_
00138     (
00139         IOobject
00140         (
00141             "k",
00142             runTime_.timeName(),
00143             mesh_,
00144             IOobject::MUST_READ,
00145             IOobject::AUTO_WRITE
00146         ),
00147         mesh_
00148     ),
00149 
00150     epsilon_
00151     (
00152         IOobject
00153         (
00154             "epsilon",
00155             runTime_.timeName(),
00156             mesh_,
00157             IOobject::MUST_READ,
00158             IOobject::AUTO_WRITE
00159         ),
00160         mesh_
00161     ),
00162 
00163     mut_
00164     (
00165         IOobject
00166         (
00167             "mut",
00168             runTime_.timeName(),
00169             mesh_,
00170             IOobject::NO_READ,
00171             IOobject::AUTO_WRITE
00172         ),
00173         autoCreateLowReMut("mut", mesh_)
00174     ),
00175 
00176     alphat_
00177     (
00178         IOobject
00179         (
00180             "alphat",
00181             runTime_.timeName(),
00182             mesh_,
00183             IOobject::NO_READ,
00184             IOobject::AUTO_WRITE
00185         ),
00186         autoCreateAlphat("alphat", mesh_)
00187     )
00188 {
00189     mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
00190     mut_.correctBoundaryConditions();
00191 
00192     alphat_ = mut_/Prt_;
00193     alphat_.correctBoundaryConditions();
00194 
00195     printCoeffs();
00196 }
00197 
00198 
00199 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00200 
00201 tmp<volSymmTensorField> LaunderSharmaKE::R() const
00202 {
00203     return tmp<volSymmTensorField>
00204     (
00205         new volSymmTensorField
00206         (
00207             IOobject
00208             (
00209                 "R",
00210                 runTime_.timeName(),
00211                 mesh_,
00212                 IOobject::NO_READ,
00213                 IOobject::NO_WRITE
00214             ),
00215             ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
00216             k_.boundaryField().types()
00217         )
00218     );
00219 }
00220 
00221 
00222 tmp<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
00223 {
00224     return tmp<volSymmTensorField>
00225     (
00226         new volSymmTensorField
00227         (
00228             IOobject
00229             (
00230                 "devRhoReff",
00231                 runTime_.timeName(),
00232                 mesh_,
00233                 IOobject::NO_READ,
00234                 IOobject::NO_WRITE
00235             ),
00236            -muEff()*dev(twoSymm(fvc::grad(U_)))
00237         )
00238     );
00239 }
00240 
00241 
00242 tmp<fvVectorMatrix> LaunderSharmaKE::divDevRhoReff(volVectorField& U) const
00243 {
00244     return
00245     (
00246       - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
00247     );
00248 }
00249 
00250 
00251 bool LaunderSharmaKE::read()
00252 {
00253     if (RASModel::read())
00254     {
00255         Cmu_.readIfPresent(coeffDict());
00256         C1_.readIfPresent(coeffDict());
00257         C2_.readIfPresent(coeffDict());
00258         C3_.readIfPresent(coeffDict());
00259         sigmak_.readIfPresent(coeffDict());
00260         sigmaEps_.readIfPresent(coeffDict());
00261         Prt_.readIfPresent(coeffDict());
00262 
00263         return true;
00264     }
00265     else
00266     {
00267         return false;
00268     }
00269 }
00270 
00271 
00272 void LaunderSharmaKE::correct()
00273 {
00274     if (!turbulence_)
00275     {
00276         // Re-calculate viscosity
00277         mut_ == rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_);
00278 
00279         // Re-calculate thermal diffusivity
00280         alphat_ = mut_/Prt_;
00281         alphat_.correctBoundaryConditions();
00282 
00283         return;
00284     }
00285 
00286     RASModel::correct();
00287 
00288     // Calculate parameters and coefficients for Launder-Sharma low-Reynolds
00289     // number model
00290 
00291     volScalarField E = 2.0*mu()*mut_*fvc::magSqrGradGrad(U_)/rho_;
00292     volScalarField D = 2.0*mu()*magSqr(fvc::grad(sqrt(k_)))/rho_;
00293 
00294     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
00295 
00296     if (mesh_.moving())
00297     {
00298         divU += fvc::div(mesh_.phi());
00299     }
00300 
00301     tmp<volTensorField> tgradU = fvc::grad(U_);
00302     volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
00303     tgradU.clear();
00304 
00305 
00306     // Dissipation equation
00307 
00308     tmp<fvScalarMatrix> epsEqn
00309     (
00310         fvm::ddt(rho_, epsilon_)
00311       + fvm::div(phi_, epsilon_)
00312       - fvm::laplacian(DepsilonEff(), epsilon_)
00313      ==
00314         C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_)
00315       - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_)
00316     //+ 0.75*1.5*flameKproduction*epsilon_/k_
00317       + E
00318     );
00319 
00320     epsEqn().relax();
00321     solve(epsEqn);
00322     bound(epsilon_, epsilon0_);
00323 
00324 
00325     // Turbulent kinetic energy equation
00326 
00327     tmp<fvScalarMatrix> kEqn
00328     (
00329         fvm::ddt(rho_, k_)
00330       + fvm::div(phi_, k_)
00331       - fvm::laplacian(DkEff(), k_)
00332      ==
00333         G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
00334       - fvm::Sp(rho_*(epsilon_ + D)/k_, k_)
00335     //+ flameKproduction
00336     );
00337 
00338     kEqn().relax();
00339     solve(kEqn);
00340     bound(k_, k0_);
00341 
00342 
00343     // Re-calculate viscosity
00344     mut_ == Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
00345 
00346 
00347     // Re-calculate thermal diffusivity
00348     alphat_ = mut_/Prt_;
00349     alphat_.correctBoundaryConditions();
00350 }
00351 
00352 
00353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00354 
00355 } // End namespace RASModels
00356 } // End namespace compressible
00357 } // End namespace Foam
00358 
00359 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines