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 compressible
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 volScalarField& rho,
00092     const volVectorField& U,
00093     const surfaceScalarField& phi,
00094     const basicThermo& thermophysicalModel
00095 )
00096 :
00097     RASModel(typeName, rho, U, phi, thermophysicalModel),
00098 
00099     Cmu_
00100     (
00101         dimensioned<scalar>::lookupOrAddToDict
00102         (
00103             "Cmu",
00104             coeffDict_,
00105             0.09
00106         )
00107     ),
00108     A0_
00109     (
00110         dimensioned<scalar>::lookupOrAddToDict
00111         (
00112             "A0",
00113             coeffDict_,
00114             4.0
00115         )
00116     ),
00117     C2_
00118     (
00119         dimensioned<scalar>::lookupOrAddToDict
00120         (
00121             "C2",
00122             coeffDict_,
00123             1.9
00124         )
00125     ),
00126     sigmak_
00127     (
00128         dimensioned<scalar>::lookupOrAddToDict
00129         (
00130             "sigmak",
00131             coeffDict_,
00132             1.0
00133         )
00134     ),
00135     sigmaEps_
00136     (
00137         dimensioned<scalar>::lookupOrAddToDict
00138         (
00139             "sigmaEps",
00140             coeffDict_,
00141             1.2
00142         )
00143     ),
00144     Prt_
00145     (
00146         dimensioned<scalar>::lookupOrAddToDict
00147         (
00148             "Prt",
00149             coeffDict_,
00150             1.0
00151         )
00152     ),
00153 
00154     k_
00155     (
00156         IOobject
00157         (
00158             "k",
00159             runTime_.timeName(),
00160             mesh_,
00161             IOobject::NO_READ,
00162             IOobject::AUTO_WRITE
00163         ),
00164         autoCreateK("k", mesh_)
00165     ),
00166     epsilon_
00167     (
00168         IOobject
00169         (
00170             "epsilon",
00171             runTime_.timeName(),
00172             mesh_,
00173             IOobject::NO_READ,
00174             IOobject::AUTO_WRITE
00175         ),
00176         autoCreateEpsilon("epsilon", mesh_)
00177     ),
00178     mut_
00179     (
00180         IOobject
00181         (
00182             "mut",
00183             runTime_.timeName(),
00184             mesh_,
00185             IOobject::NO_READ,
00186             IOobject::AUTO_WRITE
00187         ),
00188         autoCreateMut("mut", mesh_)
00189     ),
00190     alphat_
00191     (
00192         IOobject
00193         (
00194             "alphat",
00195             runTime_.timeName(),
00196             mesh_,
00197             IOobject::NO_READ,
00198             IOobject::AUTO_WRITE
00199         ),
00200         autoCreateAlphat("alphat", mesh_)
00201     )
00202 {
00203     bound(k_, k0_);
00204     bound(epsilon_, epsilon0_);
00205 
00206     mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
00207     mut_.correctBoundaryConditions();
00208 
00209     alphat_ = mut_/Prt_;
00210     alphat_.correctBoundaryConditions();
00211 
00212     printCoeffs();
00213 }
00214 
00215 
00216 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00217 
00218 tmp<volSymmTensorField> realizableKE::R() const
00219 {
00220     return tmp<volSymmTensorField>
00221     (
00222         new volSymmTensorField
00223         (
00224             IOobject
00225             (
00226                 "R",
00227                 runTime_.timeName(),
00228                 mesh_,
00229                 IOobject::NO_READ,
00230                 IOobject::NO_WRITE
00231             ),
00232             ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
00233             k_.boundaryField().types()
00234         )
00235     );
00236 }
00237 
00238 
00239 tmp<volSymmTensorField> realizableKE::devRhoReff() const
00240 {
00241     return tmp<volSymmTensorField>
00242     (
00243         new volSymmTensorField
00244         (
00245             IOobject
00246             (
00247                 "devRhoReff",
00248                 runTime_.timeName(),
00249                 mesh_,
00250                 IOobject::NO_READ,
00251                 IOobject::NO_WRITE
00252             ),
00253            -muEff()*dev(twoSymm(fvc::grad(U_)))
00254         )
00255     );
00256 }
00257 
00258 
00259 tmp<fvVectorMatrix> realizableKE::divDevRhoReff(volVectorField& U) const
00260 {
00261     return
00262     (
00263       - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
00264     );
00265 }
00266 
00267 
00268 bool realizableKE::read()
00269 {
00270     if (RASModel::read())
00271     {
00272         Cmu_.readIfPresent(coeffDict());
00273         A0_.readIfPresent(coeffDict());
00274         C2_.readIfPresent(coeffDict());
00275         sigmak_.readIfPresent(coeffDict());
00276         sigmaEps_.readIfPresent(coeffDict());
00277         Prt_.readIfPresent(coeffDict());
00278 
00279         return true;
00280     }
00281     else
00282     {
00283         return false;
00284     }
00285 }
00286 
00287 
00288 void realizableKE::correct()
00289 {
00290     if (!turbulence_)
00291     {
00292         // Re-calculate viscosity
00293         mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
00294         mut_.correctBoundaryConditions();
00295 
00296         // Re-calculate thermal diffusivity
00297         alphat_ = mut_/Prt_;
00298         alphat_.correctBoundaryConditions();
00299 
00300         return;
00301     }
00302 
00303     RASModel::correct();
00304 
00305     volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));
00306 
00307     if (mesh_.moving())
00308     {
00309         divU += fvc::div(mesh_.phi());
00310     }
00311 
00312     volTensorField gradU = fvc::grad(U_);
00313     volScalarField S2 = 2*magSqr(dev(symm(gradU)));
00314     volScalarField magS = sqrt(S2);
00315 
00316     volScalarField eta = magS*k_/epsilon_;
00317     volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
00318 
00319     volScalarField G("RASModel::G", mut_*(gradU && dev(twoSymm(gradU))));
00320 
00321     // Update espsilon and G at the wall
00322     epsilon_.boundaryField().updateCoeffs();
00323 
00324     // Dissipation equation
00325     tmp<fvScalarMatrix> epsEqn
00326     (
00327         fvm::ddt(rho_, epsilon_)
00328       + fvm::div(phi_, epsilon_)
00329       - fvm::laplacian(DepsilonEff(), epsilon_)
00330      ==
00331         C1*rho_*magS*epsilon_
00332       - fvm::Sp
00333         (
00334             C2_*rho_*epsilon_/(k_ + sqrt((mu()/rho_)*epsilon_)),
00335             epsilon_
00336         )
00337     );
00338 
00339     epsEqn().relax();
00340 
00341     epsEqn().boundaryManipulate(epsilon_.boundaryField());
00342 
00343     solve(epsEqn);
00344     bound(epsilon_, epsilon0_);
00345 
00346 
00347     // Turbulent kinetic energy equation
00348 
00349     tmp<fvScalarMatrix> kEqn
00350     (
00351         fvm::ddt(rho_, k_)
00352       + fvm::div(phi_, k_)
00353       - fvm::laplacian(DkEff(), k_)
00354      ==
00355         G - fvm::SuSp(2.0/3.0*rho_*divU, k_)
00356       - fvm::Sp(rho_*(epsilon_)/k_, k_)
00357     );
00358 
00359     kEqn().relax();
00360     solve(kEqn);
00361     bound(k_, k0_);
00362 
00363     // Re-calculate viscosity
00364     mut_ = rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
00365     mut_.correctBoundaryConditions();
00366 
00367     // Re-calculate thermal diffusivity
00368     alphat_ = mut_/Prt_;
00369     alphat_.correctBoundaryConditions();
00370 }
00371 
00372 
00373 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00374 
00375 } // End namespace RASModels
00376 } // End namespace compressible
00377 } // End namespace Foam
00378 
00379 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd