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

LRR.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 "LRR.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "wallFvPatch.H"
00030 
00031 #include "backwardsCompatibilityWallFunctions.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 namespace incompressible
00038 {
00039 namespace RASModels
00040 {
00041 
00042 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00043 
00044 defineTypeNameAndDebug(LRR, 0);
00045 addToRunTimeSelectionTable(RASModel, LRR, dictionary);
00046 
00047 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00048 
00049 LRR::LRR
00050 (
00051     const volVectorField& U,
00052     const surfaceScalarField& phi,
00053     transportModel& lamTransportModel
00054 )
00055 :
00056     RASModel(typeName, U, phi, lamTransportModel),
00057 
00058     Cmu_
00059     (
00060         dimensioned<scalar>::lookupOrAddToDict
00061         (
00062             "Cmu",
00063             coeffDict_,
00064             0.09
00065         )
00066     ),
00067     Clrr1_
00068     (
00069         dimensioned<scalar>::lookupOrAddToDict
00070         (
00071             "Clrr1",
00072             coeffDict_,
00073             1.8
00074         )
00075     ),
00076     Clrr2_
00077     (
00078         dimensioned<scalar>::lookupOrAddToDict
00079         (
00080             "Clrr2",
00081             coeffDict_,
00082             0.6
00083         )
00084     ),
00085     C1_
00086     (
00087         dimensioned<scalar>::lookupOrAddToDict
00088         (
00089             "C1",
00090             coeffDict_,
00091             1.44
00092         )
00093     ),
00094     C2_
00095     (
00096         dimensioned<scalar>::lookupOrAddToDict
00097         (
00098             "C2",
00099             coeffDict_,
00100             1.92
00101         )
00102     ),
00103     Cs_
00104     (
00105         dimensioned<scalar>::lookupOrAddToDict
00106         (
00107             "Cs",
00108             coeffDict_,
00109             0.25
00110         )
00111     ),
00112     Ceps_
00113     (
00114         dimensioned<scalar>::lookupOrAddToDict
00115         (
00116             "Ceps",
00117             coeffDict_,
00118             0.15
00119         )
00120     ),
00121     sigmaEps_
00122     (
00123         dimensioned<scalar>::lookupOrAddToDict
00124         (
00125             "sigmaEps",
00126             coeffDict_,
00127             1.3
00128         )
00129     ),
00130     couplingFactor_
00131     (
00132         dimensioned<scalar>::lookupOrAddToDict
00133         (
00134             "couplingFactor",
00135             coeffDict_,
00136             0.0
00137         )
00138     ),
00139 
00140     R_
00141     (
00142         IOobject
00143         (
00144             "R",
00145             runTime_.timeName(),
00146             mesh_,
00147             IOobject::NO_READ,
00148             IOobject::AUTO_WRITE
00149         ),
00150         autoCreateR("R", mesh_)
00151     ),
00152     k_
00153     (
00154         IOobject
00155         (
00156             "k",
00157             runTime_.timeName(),
00158             mesh_,
00159             IOobject::NO_READ,
00160             IOobject::AUTO_WRITE
00161         ),
00162         autoCreateK("k", mesh_)
00163     ),
00164     epsilon_
00165     (
00166         IOobject
00167         (
00168             "epsilon",
00169             runTime_.timeName(),
00170             mesh_,
00171             IOobject::NO_READ,
00172             IOobject::AUTO_WRITE
00173         ),
00174         autoCreateEpsilon("epsilon", mesh_)
00175     ),
00176     nut_
00177     (
00178         IOobject
00179         (
00180             "nut",
00181             runTime_.timeName(),
00182             mesh_,
00183             IOobject::NO_READ,
00184             IOobject::AUTO_WRITE
00185         ),
00186         autoCreateNut("nut", mesh_)
00187     )
00188 {
00189     nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
00190     nut_.correctBoundaryConditions();
00191 
00192     if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
00193     {
00194         FatalErrorIn
00195         (
00196             "LRR::LRR"
00197             "(const volVectorField& U, const surfaceScalarField& phi,"
00198             "transportModel& lamTransportModel)"
00199         )   << "couplingFactor = " << couplingFactor_
00200             << " is not in range 0 - 1" << nl
00201             << exit(FatalError);
00202     }
00203 
00204     printCoeffs();
00205 }
00206 
00207 
00208 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00209 
00210 tmp<volSymmTensorField> LRR::devReff() const
00211 {
00212     return tmp<volSymmTensorField>
00213     (
00214         new volSymmTensorField
00215         (
00216             IOobject
00217             (
00218                 "devRhoReff",
00219                 runTime_.timeName(),
00220                 mesh_,
00221                 IOobject::NO_READ,
00222                 IOobject::NO_WRITE
00223             ),
00224             R_ - nu()*dev(twoSymm(fvc::grad(U_)))
00225         )
00226     );
00227 }
00228 
00229 
00230 tmp<fvVectorMatrix> LRR::divDevReff(volVectorField& U) const
00231 {
00232     if (couplingFactor_.value() > 0.0)
00233     {
00234         return
00235         (
00236             fvc::div(R_ + couplingFactor_*nut_*fvc::grad(U), "div(R)")
00237           + fvc::laplacian
00238             (
00239                  (1.0 - couplingFactor_)*nut_,
00240                  U,
00241                  "laplacian(nuEff,U)"
00242             )
00243           - fvm::laplacian(nuEff(), U)
00244         );
00245     }
00246     else
00247     {
00248         return
00249         (
00250             fvc::div(R_)
00251           + fvc::laplacian(nut_, U, "laplacian(nuEff,U)")
00252           - fvm::laplacian(nuEff(), U)
00253         );
00254     }
00255 }
00256 
00257 
00258 bool LRR::read()
00259 {
00260     if (RASModel::read())
00261     {
00262         Cmu_.readIfPresent(coeffDict());
00263         Clrr1_.readIfPresent(coeffDict());
00264         Clrr2_.readIfPresent(coeffDict());
00265         C1_.readIfPresent(coeffDict());
00266         C2_.readIfPresent(coeffDict());
00267         Cs_.readIfPresent(coeffDict());
00268         Ceps_.readIfPresent(coeffDict());
00269         sigmaEps_.readIfPresent(coeffDict());
00270 
00271         couplingFactor_.readIfPresent(coeffDict());
00272 
00273         if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
00274         {
00275             FatalErrorIn("LRR::read()")
00276                 << "couplingFactor = " << couplingFactor_
00277                 << " is not in range 0 - 1"
00278                 << exit(FatalError);
00279         }
00280 
00281         return true;
00282     }
00283     else
00284     {
00285         return false;
00286     }
00287 }
00288 
00289 
00290 void LRR::correct()
00291 {
00292     RASModel::correct();
00293 
00294     if (!turbulence_)
00295     {
00296         return;
00297     }
00298 
00299     volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
00300     volScalarField G("RASModel::G", 0.5*mag(tr(P)));
00301 
00302     // Update espsilon and G at the wall
00303     epsilon_.boundaryField().updateCoeffs();
00304 
00305     // Dissipation equation
00306     tmp<fvScalarMatrix> epsEqn
00307     (
00308         fvm::ddt(epsilon_)
00309       + fvm::div(phi_, epsilon_)
00310       - fvm::Sp(fvc::div(phi_), epsilon_)
00311     //- fvm::laplacian(Ceps*(K/epsilon_)*R, epsilon_)
00312       - fvm::laplacian(DepsilonEff(), epsilon_)
00313       ==
00314         C1_*G*epsilon_/k_
00315       - fvm::Sp(C2_*epsilon_/k_, epsilon_)
00316     );
00317 
00318     epsEqn().relax();
00319 
00320     epsEqn().boundaryManipulate(epsilon_.boundaryField());
00321 
00322     solve(epsEqn);
00323     bound(epsilon_, epsilon0_);
00324 
00325 
00326     // Reynolds stress equation
00327 
00328     const fvPatchList& patches = mesh_.boundary();
00329 
00330     forAll(patches, patchi)
00331     {
00332         const fvPatch& curPatch = patches[patchi];
00333 
00334         if (typeid(curPatch) == typeid(wallFvPatch))
00335         {
00336             forAll(curPatch, facei)
00337             {
00338                 label faceCelli = curPatch.faceCells()[facei];
00339                 P[faceCelli]
00340                     *= min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 1.0);
00341             }
00342         }
00343     }
00344 
00345 
00346     tmp<fvSymmTensorMatrix> REqn
00347     (
00348         fvm::ddt(R_)
00349       + fvm::div(phi_, R_)
00350       - fvm::Sp(fvc::div(phi_), R_)
00351     //- fvm::laplacian(Cs*(k_/epsilon_)*R_, R_)
00352       - fvm::laplacian(DREff(), R_)
00353       + fvm::Sp(Clrr1_*epsilon_/k_, R_)
00354       ==
00355         P
00356       - (2.0/3.0*(1 - Clrr1_)*I)*epsilon_
00357       - Clrr2_*dev(P)
00358     );
00359 
00360     REqn().relax();
00361     solve(REqn);
00362 
00363     R_.max
00364     (
00365         dimensionedSymmTensor
00366         (
00367             "zero",
00368             R_.dimensions(),
00369             symmTensor
00370             (
00371                 k0_.value(), -GREAT, -GREAT,
00372                 k0_.value(), -GREAT,
00373                 k0_.value()
00374             )
00375         )
00376     );
00377 
00378     k_ = 0.5*tr(R_);
00379     bound(k_, k0_);
00380 
00381 
00382     // Re-calculate viscosity
00383     nut_ = Cmu_*sqr(k_)/epsilon_;
00384     nut_.correctBoundaryConditions();
00385 
00386 
00387     // Correct wall shear stresses
00388 
00389     forAll(patches, patchi)
00390     {
00391         const fvPatch& curPatch = patches[patchi];
00392 
00393         if (typeid(curPatch) == typeid(wallFvPatch))
00394         {
00395             symmTensorField& Rw = R_.boundaryField()[patchi];
00396 
00397             const scalarField& nutw = nut_.boundaryField()[patchi];
00398 
00399             vectorField snGradU = U_.boundaryField()[patchi].snGrad();
00400 
00401             const vectorField& faceAreas
00402                 = mesh_.Sf().boundaryField()[patchi];
00403 
00404             const scalarField& magFaceAreas
00405                 = mesh_.magSf().boundaryField()[patchi];
00406 
00407             forAll(curPatch, facei)
00408             {
00409                 // Calculate near-wall velocity gradient
00410                 tensor gradUw
00411                     = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
00412 
00413                 // Calculate near-wall shear-stress tensor
00414                 tensor tauw = -nutw[facei]*2*symm(gradUw);
00415 
00416                 // Reset the shear components of the stress tensor
00417                 Rw[facei].xy() = tauw.xy();
00418                 Rw[facei].xz() = tauw.xz();
00419                 Rw[facei].yz() = tauw.yz();
00420             }
00421         }
00422     }
00423 }
00424 
00425 
00426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00427 
00428 } // End namespace RASModels
00429 } // End namespace incompressible
00430 } // End namespace Foam
00431 
00432 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd