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

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