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

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