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 incompressible
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 volVectorField& U,
00051     const surfaceScalarField& phi,
00052     transportModel& lamTransportModel
00053 )
00054 :
00055     RASModel(typeName, U, phi, lamTransportModel),
00056 
00057     Cmu_
00058     (
00059         dimensioned<scalar>::lookupOrAddToDict
00060         (
00061             "Cmu",
00062             coeffDict_,
00063             0.0845
00064         )
00065     ),
00066     C1_
00067     (
00068         dimensioned<scalar>::lookupOrAddToDict
00069         (
00070             "C1",
00071             coeffDict_,
00072             1.42
00073         )
00074     ),
00075     C2_
00076     (
00077         dimensioned<scalar>::lookupOrAddToDict
00078         (
00079             "C2",
00080             coeffDict_,
00081             1.68
00082         )
00083     ),
00084     sigmak_
00085     (
00086         dimensioned<scalar>::lookupOrAddToDict
00087         (
00088             "sigmak",
00089             coeffDict_,
00090             0.71942
00091         )
00092     ),
00093     sigmaEps_
00094     (
00095         dimensioned<scalar>::lookupOrAddToDict
00096         (
00097             "sigmaEps",
00098             coeffDict_,
00099             0.71942
00100         )
00101     ),
00102     eta0_
00103     (
00104         dimensioned<scalar>::lookupOrAddToDict
00105         (
00106             "eta0",
00107             coeffDict_,
00108             4.38
00109         )
00110     ),
00111     beta_
00112     (
00113         dimensioned<scalar>::lookupOrAddToDict
00114         (
00115             "beta",
00116             coeffDict_,
00117             0.012
00118         )
00119     ),
00120 
00121     k_
00122     (
00123         IOobject
00124         (
00125             "k",
00126             runTime_.timeName(),
00127             mesh_,
00128             IOobject::NO_READ,
00129             IOobject::AUTO_WRITE
00130         ),
00131         autoCreateK("k", mesh_)
00132     ),
00133     epsilon_
00134     (
00135         IOobject
00136         (
00137             "epsilon",
00138             runTime_.timeName(),
00139             mesh_,
00140             IOobject::NO_READ,
00141             IOobject::AUTO_WRITE
00142         ),
00143         autoCreateEpsilon("epsilon", mesh_)
00144     ),
00145     nut_
00146     (
00147         IOobject
00148         (
00149             "nut",
00150             runTime_.timeName(),
00151             mesh_,
00152             IOobject::NO_READ,
00153             IOobject::AUTO_WRITE
00154         ),
00155         autoCreateNut("nut", mesh_)
00156     )
00157 {
00158     nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
00159     nut_.correctBoundaryConditions();
00160 
00161     printCoeffs();
00162 }
00163 
00164 
00165 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00166 
00167 
00168 tmp<volSymmTensorField> RNGkEpsilon::R() const
00169 {
00170     return tmp<volSymmTensorField>
00171     (
00172         new volSymmTensorField
00173         (
00174             IOobject
00175             (
00176                 "R",
00177                 runTime_.timeName(),
00178                 mesh_,
00179                 IOobject::NO_READ,
00180                 IOobject::NO_WRITE
00181             ),
00182             ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)),
00183             k_.boundaryField().types()
00184         )
00185     );
00186 }
00187 
00188 
00189 tmp<volSymmTensorField> RNGkEpsilon::devReff() const
00190 {
00191     return tmp<volSymmTensorField>
00192     (
00193         new volSymmTensorField
00194         (
00195             IOobject
00196             (
00197                 "devRhoReff",
00198                 runTime_.timeName(),
00199                 mesh_,
00200                 IOobject::NO_READ,
00201                 IOobject::NO_WRITE
00202             ),
00203            -nuEff()*dev(twoSymm(fvc::grad(U_)))
00204         )
00205     );
00206 }
00207 
00208 
00209 tmp<fvVectorMatrix> RNGkEpsilon::divDevReff(volVectorField& U) const
00210 {
00211     return
00212     (
00213       - fvm::laplacian(nuEff(), U)
00214       - fvc::div(nuEff()*dev(fvc::grad(U)().T()))
00215     );
00216 }
00217 
00218 
00219 bool RNGkEpsilon::read()
00220 {
00221     if (RASModel::read())
00222     {
00223         Cmu_.readIfPresent(coeffDict());
00224         C1_.readIfPresent(coeffDict());
00225         C2_.readIfPresent(coeffDict());
00226         sigmak_.readIfPresent(coeffDict());
00227         sigmaEps_.readIfPresent(coeffDict());
00228         eta0_.readIfPresent(coeffDict());
00229         beta_.readIfPresent(coeffDict());
00230 
00231         return true;
00232     }
00233     else
00234     {
00235         return false;
00236     }
00237 }
00238 
00239 
00240 void RNGkEpsilon::correct()
00241 {
00242     RASModel::correct();
00243 
00244     if (!turbulence_)
00245     {
00246         return;
00247     }
00248 
00249     volScalarField S2 = 2*magSqr(symm(fvc::grad(U_)));
00250 
00251     volScalarField G("RASModel::G", nut_*S2);
00252 
00253     volScalarField eta = sqrt(S2)*k_/epsilon_;
00254     volScalarField R =
00255         ((eta*(scalar(1) - eta/eta0_))/(scalar(1) + beta_*eta*sqr(eta)));
00256 
00257     // Update espsilon and G at the wall
00258     epsilon_.boundaryField().updateCoeffs();
00259 
00260     // Dissipation equation
00261     tmp<fvScalarMatrix> epsEqn
00262     (
00263         fvm::ddt(epsilon_)
00264       + fvm::div(phi_, epsilon_)
00265       - fvm::laplacian(DepsilonEff(), epsilon_)
00266      ==
00267         (C1_ - R)*G*epsilon_/k_
00268     //- fvm::SuSp(R*G/k_, epsilon_)
00269       - fvm::Sp(C2_*epsilon_/k_, epsilon_)
00270     );
00271 
00272     epsEqn().relax();
00273 
00274     epsEqn().boundaryManipulate(epsilon_.boundaryField());
00275 
00276     solve(epsEqn);
00277     bound(epsilon_, epsilon0_);
00278 
00279 
00280     // Turbulent kinetic energy equation
00281 
00282     tmp<fvScalarMatrix> kEqn
00283     (
00284         fvm::ddt(k_)
00285       + fvm::div(phi_, k_)
00286       - fvm::laplacian(DkEff(), k_)
00287      ==
00288         G - fvm::Sp(epsilon_/k_, k_)
00289     );
00290 
00291     kEqn().relax();
00292     solve(kEqn);
00293     bound(k_, k0_);
00294 
00295 
00296     // Re-calculate viscosity
00297     nut_ = Cmu_*sqr(k_)/epsilon_;
00298     nut_.correctBoundaryConditions();
00299 }
00300 
00301 
00302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00303 
00304 } // End namespace RASModels
00305 } // End namespace incompressible
00306 } // End namespace Foam
00307 
00308 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd