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