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

alphaSgsJayatillekeWallFunctionFvPatchScalarField.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) 2008-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 "alphaSgsJayatillekeWallFunctionFvPatchScalarField.H"
00028 #include "LESModel.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "addToRunTimeSelectionTable.H"
00032 #include "wallFvPatch.H"
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 namespace compressible
00039 {
00040 namespace LESModels
00041 {
00042 
00043 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00044 
00045 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxExp_ = 50.0;
00046 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01;
00047 label alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10;
00048 
00049 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00050 
00051 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType()
00052 {
00053     if (!isA<wallFvPatch>(patch()))
00054     {
00055         FatalErrorIn
00056         (
00057             "alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType()"
00058         )
00059             << "Patch type for patch " << patch().name() << " must be wall\n"
00060             << "Current patch type is " << patch().type() << nl
00061             << exit(FatalError);
00062     }
00063 }
00064 
00065 
00066 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::Psmooth
00067 (
00068     const scalar Prat
00069 ) const
00070 {
00071     return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat));
00072 }
00073 
00074 
00075 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::yPlusTherm
00076 (
00077     const scalar P,
00078     const scalar Prat
00079 ) const
00080 {
00081     scalar ypt = 11.0;
00082 
00083     for (int i=0; i<maxIters_; i++)
00084     {
00085         scalar f = ypt - (log(E_*ypt)/kappa_ + P)/Prat;
00086         scalar df = 1.0 - 1.0/(ypt*kappa_*Prat);
00087         scalar yptNew = ypt - f/df;
00088 
00089         if (yptNew < VSMALL)
00090         {
00091             return 0;
00092         }
00093         else if (mag(yptNew - ypt) < tolerance_)
00094         {
00095             return yptNew;
00096         }
00097         else
00098         {
00099             ypt = yptNew;
00100         }
00101      }
00102 
00103     return ypt;
00104 }
00105 
00106 
00107 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00108 
00109 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
00110 alphaSgsJayatillekeWallFunctionFvPatchScalarField
00111 (
00112     const fvPatch& p,
00113     const DimensionedField<scalar, volMesh>& iF
00114 )
00115 :
00116     fixedValueFvPatchScalarField(p, iF),
00117     Prt_(0.85),
00118     kappa_(0.41),
00119     E_(9.8)
00120 {
00121     checkType();
00122 }
00123 
00124 
00125 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
00126 alphaSgsJayatillekeWallFunctionFvPatchScalarField
00127 (
00128     const alphaSgsJayatillekeWallFunctionFvPatchScalarField& ptf,
00129     const fvPatch& p,
00130     const DimensionedField<scalar, volMesh>& iF,
00131     const fvPatchFieldMapper& mapper
00132 )
00133 :
00134     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00135     Prt_(ptf.Prt_),
00136     kappa_(ptf.kappa_),
00137     E_(ptf.E_)
00138 {}
00139 
00140 
00141 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
00142 alphaSgsJayatillekeWallFunctionFvPatchScalarField
00143 (
00144     const fvPatch& p,
00145     const DimensionedField<scalar, volMesh>& iF,
00146     const dictionary& dict
00147 )
00148 :
00149     fixedValueFvPatchScalarField(p, iF, dict),
00150     Prt_(dict.lookupOrDefault<scalar>("Prt", 0.85)),
00151     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00152     E_(dict.lookupOrDefault<scalar>("E", 9.8))
00153 {
00154     checkType();
00155 }
00156 
00157 
00158 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
00159 alphaSgsJayatillekeWallFunctionFvPatchScalarField
00160 (
00161     const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf
00162 )
00163 :
00164     fixedValueFvPatchScalarField(awfpsf),
00165     Prt_(awfpsf.Prt_),
00166     kappa_(awfpsf.kappa_),
00167     E_(awfpsf.E_)
00168 {
00169     checkType();
00170 }
00171 
00172 
00173 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
00174 alphaSgsJayatillekeWallFunctionFvPatchScalarField
00175 (
00176     const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf,
00177     const DimensionedField<scalar, volMesh>& iF
00178 )
00179 :
00180     fixedValueFvPatchScalarField(awfpsf, iF),
00181     Prt_(awfpsf.Prt_),
00182     kappa_(awfpsf.kappa_),
00183     E_(awfpsf.E_)
00184 {
00185     checkType();
00186 }
00187 
00188 
00189 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00190 
00191 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::evaluate
00192 (
00193     const Pstream::commsTypes
00194 )
00195 {
00196     const LESModel& lesModel = db().lookupObject<LESModel>("LESProperties");
00197 
00198     // Field data
00199     const label patchI = patch().index();
00200 
00201     const scalarField& muw = lesModel.mu().boundaryField()[patchI];
00202     const scalarField muSgsw = lesModel.muSgs()().boundaryField()[patchI];
00203 
00204     const scalarField& alphaw = lesModel.alpha().boundaryField()[patchI];
00205     scalarField& alphaSgsw = *this;
00206 
00207     const fvPatchVectorField& Uw = lesModel.U().boundaryField()[patchI];
00208     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
00209     const scalarField magGradUw = mag(Uw.snGrad());
00210 
00211     const scalarField& rhow = lesModel.rho().boundaryField()[patchI];
00212     const fvPatchScalarField& hw =
00213         patch().lookupPatchField<volScalarField, scalar>("h");
00214 
00215     const scalarField& ry = patch().deltaCoeffs();
00216 
00217     // Heat flux [W/m2] - lagging alphaSgsw
00218     const scalarField qDot = (alphaw + alphaSgsw)*hw.snGrad();
00219 
00220     // Populate boundary values
00221     forAll(alphaSgsw, faceI)
00222     {
00223         // Calculate uTau using Newton-Raphson iteration
00224         scalar uTau =
00225             sqrt((muSgsw[faceI] + muw[faceI])/rhow[faceI]*magGradUw[faceI]);
00226 
00227         if (uTau > ROOTVSMALL)
00228         {
00229             label iter = 0;
00230             scalar err = GREAT;
00231 
00232             do
00233             {
00234                 scalar kUu = min(kappa_*magUp[faceI]/uTau, maxExp_);
00235                 scalar fkUu = exp(kUu) - 1.0 - kUu*(1.0 + 0.5*kUu);
00236 
00237                 scalar f =
00238                     - uTau/(ry[faceI]*muw[faceI]/rhow[faceI])
00239                     + magUp[faceI]/uTau
00240                     + 1.0/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
00241 
00242                 scalar df =
00243                     - 1.0/(ry[faceI]*muw[faceI]/rhow[faceI])
00244                     - magUp[faceI]/sqr(uTau)
00245                     - 1.0/E_*kUu*fkUu/uTau;
00246 
00247                 scalar uTauNew = uTau - f/df;
00248                 err = mag((uTau - uTauNew)/uTau);
00249                 uTau = uTauNew;
00250 
00251             } while (uTau>VSMALL && err>tolerance_ && ++iter<maxIters_);
00252 
00253             scalar yPlus = uTau/ry[faceI]/(muw[faceI]/rhow[faceI]);
00254 
00255             // Molecular Prandtl number
00256             scalar Pr = muw[faceI]/alphaw[faceI];
00257 
00258             // Molecular-to-turbulenbt Prandtl number ratio
00259             scalar Prat = Pr/Prt_;
00260 
00261             // Thermal sublayer thickness
00262             scalar P = Psmooth(Prat);
00263             scalar yPlusTherm = this->yPlusTherm(P, Prat);
00264 
00265             // Evaluate new effective thermal diffusivity
00266             scalar alphaEff = 0.0;
00267             if (yPlus < yPlusTherm)
00268             {
00269                 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
00270                 scalar B = qDot[faceI]*Pr*yPlus;
00271                 scalar C = Pr*0.5*rhow[faceI]*uTau*sqr(magUp[faceI]);
00272                 alphaEff = A/(B + C + VSMALL);
00273             }
00274             else
00275             {
00276                 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
00277                 scalar B = qDot[faceI]*Prt_*(1.0/kappa_*log(E_*yPlus) + P);
00278                 scalar magUc = uTau/kappa_*log(E_*yPlusTherm) - mag(Uw[faceI]);
00279                 scalar C =
00280                     0.5*rhow[faceI]*uTau
00281                    *(Prt_*sqr(magUp[faceI]) + (Pr - Prt_)*sqr(magUc));
00282                 alphaEff = A/(B + C + VSMALL);
00283             }
00284 
00285             // Update turbulent thermal diffusivity
00286             alphaSgsw[faceI] = max(0.0, alphaEff - alphaw[faceI]);
00287 
00288             if (debug)
00289             {
00290                 Info<< "    uTau           = " << uTau << nl
00291                     << "    Pr             = " << Pr << nl
00292                     << "    Prt            = " << Prt_ << nl
00293                     << "    qDot           = " << qDot[faceI] << nl
00294                     << "    yPlus          = " << yPlus << nl
00295                     << "    yPlusTherm     = " << yPlusTherm << nl
00296                     << "    alphaEff       = " << alphaEff << nl
00297                     << "    alphaw         = " << alphaw[faceI] << nl
00298                     << "    alphaSgsw      = " << alphaSgsw[faceI] << nl
00299                     << endl;
00300             }
00301         }
00302         else
00303         {
00304             alphaSgsw[faceI] = 0.0;
00305         }
00306     }
00307 }
00308 
00309 
00310 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
00311 {
00312     fvPatchField<scalar>::write(os);
00313     os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
00314     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00315     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00316     writeEntry("value", os);
00317 }
00318 
00319 
00320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00321 
00322 makePatchTypeField
00323 (
00324     fvPatchScalarField,
00325     alphaSgsJayatillekeWallFunctionFvPatchScalarField
00326 );
00327 
00328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00329 
00330 } // End namespace LESModels
00331 } // End namespace compressible
00332 } // End namespace Foam
00333 
00334 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd