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

kEpsilon.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 "kEpsilon.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(kEpsilon, 0);
00044 addToRunTimeSelectionTable(RASModel, kEpsilon, dictionary);
00045 
00046 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00047 
00048 kEpsilon::kEpsilon
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.09
00065         )
00066     ),
00067     C1_
00068     (
00069         dimensioned<scalar>::lookupOrAddToDict
00070         (
00071             "C1",
00072             coeffDict_,
00073             1.44
00074         )
00075     ),
00076     C2_
00077     (
00078         dimensioned<scalar>::lookupOrAddToDict
00079         (
00080             "C2",
00081             coeffDict_,
00082             1.92
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             1.0
00101         )
00102     ),
00103     sigmaEps_
00104     (
00105         dimensioned<scalar>::lookupOrAddToDict
00106         (
00107             "sigmaEps",
00108             coeffDict_,
00109             1.3
00110         )
00111     ),
00112     Prt_
00113     (
00114         dimensioned<scalar>::lookupOrAddToDict
00115         (
00116             "Prt",
00117             coeffDict_,
00118             1.0
00119         )
00120     ),
00121 
00122     k_
00123     (
00124         IOobject
00125         (
00126             "k",
00127             runTime_.timeName(),
00128             mesh_,
00129             IOobject::NO_READ,
00130             IOobject::AUTO_WRITE
00131         ),
00132         autoCreateK("k", mesh_)
00133     ),
00134     epsilon_
00135     (
00136         IOobject
00137         (
00138             "epsilon",
00139             runTime_.timeName(),
00140             mesh_,
00141             IOobject::NO_READ,
00142             IOobject::AUTO_WRITE
00143         ),
00144         autoCreateEpsilon("epsilon", mesh_)
00145     ),
00146     mut_
00147     (
00148         IOobject
00149         (
00150             "mut",
00151             runTime_.timeName(),
00152             mesh_,
00153             IOobject::NO_READ,
00154             IOobject::AUTO_WRITE
00155         ),
00156         autoCreateMut("mut", mesh_)
00157     ),
00158     alphat_
00159     (
00160         IOobject
00161         (
00162             "alphat",
00163             runTime_.timeName(),
00164             mesh_,
00165             IOobject::NO_READ,
00166             IOobject::AUTO_WRITE
00167         ),
00168         autoCreateAlphat("alphat", mesh_)
00169     )
00170 {
00171     mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
00172     mut_.correctBoundaryConditions();
00173 
00174     alphat_ = mut_/Prt_;
00175     alphat_.correctBoundaryConditions();
00176 
00177     printCoeffs();
00178 }
00179 
00180 
00181 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00182 
00183 tmp<volSymmTensorField> kEpsilon::R() const
00184 {
00185     return tmp<volSymmTensorField>
00186     (
00187         new volSymmTensorField
00188         (
00189             IOobject
00190             (
00191                 "R",
00192                 runTime_.timeName(),
00193                 mesh_,
00194                 IOobject::NO_READ,
00195                 IOobject::NO_WRITE
00196             ),
00197             ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
00198             k_.boundaryField().types()
00199         )
00200     );
00201 }
00202 
00203 
00204 tmp<volSymmTensorField> kEpsilon::devRhoReff() const
00205 {
00206     return tmp<volSymmTensorField>
00207     (
00208         new volSymmTensorField
00209         (
00210             IOobject
00211             (
00212                 "devRhoReff",
00213                 runTime_.timeName(),
00214                 mesh_,
00215                 IOobject::NO_READ,
00216                 IOobject::NO_WRITE
00217             ),
00218            -muEff()*dev(twoSymm(fvc::grad(U_)))
00219         )
00220     );
00221 }
00222 
00223 
00224 tmp<fvVectorMatrix> kEpsilon::divDevRhoReff(volVectorField& U) const
00225 {
00226     return
00227     (
00228       - fvm::laplacian(muEff(), U)
00229       - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
00230     );
00231 }
00232 
00233 
00234 bool kEpsilon::read()
00235 {
00236     if (RASModel::read())
00237     {
00238         Cmu_.readIfPresent(coeffDict());
00239         C1_.readIfPresent(coeffDict());
00240         C2_.readIfPresent(coeffDict());
00241         C3_.readIfPresent(coeffDict());
00242         sigmak_.readIfPresent(coeffDict());
00243         sigmaEps_.readIfPresent(coeffDict());
00244         Prt_.readIfPresent(coeffDict());
00245 
00246         return true;
00247     }
00248     else
00249     {
00250         return false;
00251     }
00252 }
00253 
00254 
00255 void kEpsilon::correct()
00256 {
00257     if (!turbulence_)
00258     {
00259         // Re-calculate viscosity
00260         mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
00261         mut_.correctBoundaryConditions();
00262 
00263         // Re-calculate thermal diffusivity
00264         alphat_ = mut_/Prt_;
00265         alphat_.correctBoundaryConditions();
00266 
00267         return;
00268     }
00269 
00270     RASModel::correct();
00271 
00272     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
00273 
00274     if (mesh_.moving())
00275     {
00276         divU += fvc::div(mesh_.phi());
00277     }
00278 
00279     tmp<volTensorField> tgradU = fvc::grad(U_);
00280     volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
00281     tgradU.clear();
00282 
00283     // Update espsilon and G at the wall
00284     epsilon_.boundaryField().updateCoeffs();
00285 
00286     // Dissipation equation
00287     tmp<fvScalarMatrix> epsEqn
00288     (
00289         fvm::ddt(rho_, epsilon_)
00290       + fvm::div(phi_, epsilon_)
00291       - fvm::laplacian(DepsilonEff(), epsilon_)
00292      ==
00293         C1_*G*epsilon_/k_
00294       - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_)
00295       - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
00296     );
00297 
00298     epsEqn().relax();
00299 
00300     epsEqn().boundaryManipulate(epsilon_.boundaryField());
00301 
00302     solve(epsEqn);
00303     bound(epsilon_, epsilon0_);
00304 
00305 
00306     // Turbulent kinetic energy equation
00307 
00308     tmp<fvScalarMatrix> kEqn
00309     (
00310         fvm::ddt(rho_, k_)
00311       + fvm::div(phi_, k_)
00312       - fvm::laplacian(DkEff(), k_)
00313      ==
00314         G
00315       - fvm::SuSp((2.0/3.0)*rho_*divU, k_)
00316       - fvm::Sp(rho_*epsilon_/k_, k_)
00317     );
00318 
00319     kEqn().relax();
00320     solve(kEqn);
00321     bound(k_, k0_);
00322 
00323 
00324     // Re-calculate viscosity
00325     mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
00326     mut_.correctBoundaryConditions();
00327 
00328     // Re-calculate thermal diffusivity
00329     alphat_ = mut_/Prt_;
00330     alphat_.correctBoundaryConditions();
00331 }
00332 
00333 
00334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00335 
00336 } // End namespace RASModels
00337 } // End namespace compressible
00338 } // End namespace Foam
00339 
00340 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd