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

RNGkEpsilon.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 "RNGkEpsilon.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(RNGkEpsilon, 0);
00044 addToRunTimeSelectionTable(RASModel, RNGkEpsilon, dictionary);
00045 
00046 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00047 
00048 RNGkEpsilon::RNGkEpsilon
00049 (
00050     const volScalarField& rho,
00051     const volVectorField& U,
00052     const surfaceScalarField& phi,
00053     const basicThermo& thermophysicalModel
00054 )
00055 :
00056     RASModel(typeName, rho, U, phi, thermophysicalModel),
00057 
00058     Cmu_
00059     (
00060         dimensioned<scalar>::lookupOrAddToDict
00061         (
00062             "Cmu",
00063             coeffDict_,
00064             0.0845
00065         )
00066     ),
00067     C1_
00068     (
00069         dimensioned<scalar>::lookupOrAddToDict
00070         (
00071             "C1",
00072             coeffDict_,
00073             1.42
00074         )
00075     ),
00076     C2_
00077     (
00078         dimensioned<scalar>::lookupOrAddToDict
00079         (
00080             "C2",
00081             coeffDict_,
00082             1.68
00083         )
00084     ),
00085     C3_
00086     (
00087         dimensioned<scalar>::lookupOrAddToDict
00088         (
00089             "C3",
00090             coeffDict_,
00091             -0.33
00092         )
00093     ),
00094     sigmak_
00095     (
00096         dimensioned<scalar>::lookupOrAddToDict
00097         (
00098             "sigmak",
00099             coeffDict_,
00100             0.71942
00101         )
00102     ),
00103     sigmaEps_
00104     (
00105         dimensioned<scalar>::lookupOrAddToDict
00106         (
00107             "sigmaEps",
00108             coeffDict_,
00109             0.71942
00110         )
00111     ),
00112     Prt_
00113     (
00114         dimensioned<scalar>::lookupOrAddToDict
00115         (
00116             "Prt",
00117             coeffDict_,
00118             1.0
00119         )
00120     ),
00121     eta0_
00122     (
00123         dimensioned<scalar>::lookupOrAddToDict
00124         (
00125             "eta0",
00126             coeffDict_,
00127             4.38
00128         )
00129     ),
00130     beta_
00131     (
00132         dimensioned<scalar>::lookupOrAddToDict
00133         (
00134             "beta",
00135             coeffDict_,
00136             0.012
00137         )
00138     ),
00139 
00140     k_
00141     (
00142         IOobject
00143         (
00144             "k",
00145             runTime_.timeName(),
00146             mesh_,
00147             IOobject::NO_READ,
00148             IOobject::AUTO_WRITE
00149         ),
00150         autoCreateK("k", mesh_)
00151     ),
00152     epsilon_
00153     (
00154         IOobject
00155         (
00156             "epsilon",
00157             runTime_.timeName(),
00158             mesh_,
00159             IOobject::NO_READ,
00160             IOobject::AUTO_WRITE
00161         ),
00162         autoCreateEpsilon("epsilon", mesh_)
00163     ),
00164     mut_
00165     (
00166         IOobject
00167         (
00168             "mut",
00169             runTime_.timeName(),
00170             mesh_,
00171             IOobject::NO_READ,
00172             IOobject::AUTO_WRITE
00173         ),
00174         autoCreateMut("mut", mesh_)
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_ = Cmu_*rho_*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> RNGkEpsilon::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> RNGkEpsilon::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> RNGkEpsilon::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 RNGkEpsilon::read()
00252 {
00253     if (RASModel::read())
00254     {
00255         Cmu_.readIfPresent(coeffDict());
00256         C1_.readIfPresent(coeffDict());
00257         C2_.readIfPresent(coeffDict());
00258         C3_.readIfPresent(coeffDict());
00259         Prt_.readIfPresent(coeffDict());
00260         sigmaEps_.readIfPresent(coeffDict());
00261         Prt_.readIfPresent(coeffDict());
00262         eta0_.readIfPresent(coeffDict());
00263         beta_.readIfPresent(coeffDict());
00264 
00265         return true;
00266     }
00267     else
00268     {
00269         return false;
00270     }
00271 }
00272 
00273 
00274 void RNGkEpsilon::correct()
00275 {
00276     if (!turbulence_)
00277     {
00278         // Re-calculate viscosity
00279         mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
00280         mut_.correctBoundaryConditions();
00281 
00282         // Re-calculate thermal diffusivity
00283         alphat_ = mut_/Prt_;
00284         alphat_.correctBoundaryConditions();
00285 
00286         return;
00287     }
00288 
00289     RASModel::correct();
00290 
00291     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
00292 
00293     if (mesh_.moving())
00294     {
00295         divU += fvc::div(mesh_.phi());
00296     }
00297 
00298     tmp<volTensorField> tgradU = fvc::grad(U_);
00299     volScalarField S2 = (tgradU() && dev(twoSymm(tgradU())));
00300     tgradU.clear();
00301 
00302     volScalarField G("RASModel::G", mut_*S2);
00303 
00304     volScalarField eta = sqrt(mag(S2))*k_/epsilon_;
00305     volScalarField eta3 = eta*sqr(eta);
00306 
00307     volScalarField R =
00308         ((eta*(-eta/eta0_ + scalar(1)))/(beta_*eta3 + scalar(1)));
00309 
00310     // Update espsilon and G at the wall
00311     epsilon_.boundaryField().updateCoeffs();
00312 
00313     // Dissipation equation
00314     tmp<fvScalarMatrix> epsEqn
00315     (
00316         fvm::ddt(rho_, epsilon_)
00317       + fvm::div(phi_, epsilon_)
00318       - fvm::laplacian(DepsilonEff(), epsilon_)
00319       ==
00320         (C1_ - R)*G*epsilon_/k_
00321       - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_)
00322       - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
00323     );
00324 
00325     epsEqn().relax();
00326 
00327     epsEqn().boundaryManipulate(epsilon_.boundaryField());
00328 
00329     solve(epsEqn);
00330     bound(epsilon_, epsilon0_);
00331 
00332 
00333     // Turbulent kinetic energy equation
00334 
00335     tmp<fvScalarMatrix> kEqn
00336     (
00337         fvm::ddt(rho_, k_)
00338       + fvm::div(phi_, k_)
00339       - fvm::laplacian(DkEff(), k_)
00340       ==
00341         G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
00342       - fvm::Sp(rho_*(epsilon_)/k_, k_)
00343     );
00344 
00345     kEqn().relax();
00346     solve(kEqn);
00347     bound(k_, k0_);
00348 
00349 
00350     // Re-calculate viscosity
00351     mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
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