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

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