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

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