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