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

epsilonWallFunctionFvPatchScalarField.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 "epsilonWallFunctionFvPatchScalarField.H"
00028 #include "RASModel.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 RASModels
00041 {
00042 
00043 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00044 
00045 void epsilonWallFunctionFvPatchScalarField::checkType()
00046 {
00047     if (!isA<wallFvPatch>(patch()))
00048     {
00049         FatalErrorIn("epsilonWallFunctionFvPatchScalarField::checkType()")
00050             << "Invalid wall function specification" << nl
00051             << "    Patch type for patch " << patch().name()
00052             << " must be wall" << nl
00053             << "    Current patch type is " << patch().type() << nl << endl
00054             << abort(FatalError);
00055     }
00056 }
00057 
00058 
00059 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00060 
00061 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00062 (
00063     const fvPatch& p,
00064     const DimensionedField<scalar, volMesh>& iF
00065 )
00066 :
00067     fixedInternalValueFvPatchField<scalar>(p, iF),
00068     UName_("U"),
00069     kName_("k"),
00070     GName_("RASModel::G"),
00071     rhoName_("rho"),
00072     muName_("mu"),
00073     mutName_("mut"),
00074     Cmu_(0.09),
00075     kappa_(0.41),
00076     E_(9.8)
00077 {
00078     checkType();
00079 }
00080 
00081 
00082 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00083 (
00084     const epsilonWallFunctionFvPatchScalarField& ptf,
00085     const fvPatch& p,
00086     const DimensionedField<scalar, volMesh>& iF,
00087     const fvPatchFieldMapper& mapper
00088 )
00089 :
00090     fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
00091     UName_(ptf.UName_),
00092     kName_(ptf.kName_),
00093     GName_(ptf.GName_),
00094     rhoName_(ptf.rhoName_),
00095     muName_(ptf.muName_),
00096     mutName_(ptf.mutName_),
00097     Cmu_(ptf.Cmu_),
00098     kappa_(ptf.kappa_),
00099     E_(ptf.E_)
00100 {
00101     checkType();
00102 }
00103 
00104 
00105 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00106 (
00107     const fvPatch& p,
00108     const DimensionedField<scalar, volMesh>& iF,
00109     const dictionary& dict
00110 )
00111 :
00112     fixedInternalValueFvPatchField<scalar>(p, iF, dict),
00113     UName_(dict.lookupOrDefault<word>("U", "U")),
00114     kName_(dict.lookupOrDefault<word>("k", "k")),
00115     GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
00116     rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
00117     muName_(dict.lookupOrDefault<word>("mu", "mu")),
00118     mutName_(dict.lookupOrDefault<word>("mut", "mut")),
00119     Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
00120     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00121     E_(dict.lookupOrDefault<scalar>("E", 9.8))
00122 {
00123     checkType();
00124 }
00125 
00126 
00127 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00128 (
00129     const epsilonWallFunctionFvPatchScalarField& ewfpsf
00130 )
00131 :
00132     fixedInternalValueFvPatchField<scalar>(ewfpsf),
00133     UName_(ewfpsf.UName_),
00134     kName_(ewfpsf.kName_),
00135     GName_(ewfpsf.GName_),
00136     rhoName_(ewfpsf.rhoName_),
00137     muName_(ewfpsf.muName_),
00138     mutName_(ewfpsf.mutName_),
00139     Cmu_(ewfpsf.Cmu_),
00140     kappa_(ewfpsf.kappa_),
00141     E_(ewfpsf.E_)
00142 {
00143     checkType();
00144 }
00145 
00146 
00147 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00148 (
00149     const epsilonWallFunctionFvPatchScalarField& ewfpsf,
00150     const DimensionedField<scalar, volMesh>& iF
00151 )
00152 :
00153     fixedInternalValueFvPatchField<scalar>(ewfpsf, iF),
00154     UName_(ewfpsf.UName_),
00155     kName_(ewfpsf.kName_),
00156     GName_(ewfpsf.GName_),
00157     rhoName_(ewfpsf.rhoName_),
00158     muName_(ewfpsf.muName_),
00159     mutName_(ewfpsf.mutName_),
00160     Cmu_(ewfpsf.Cmu_),
00161     kappa_(ewfpsf.kappa_),
00162     E_(ewfpsf.E_)
00163 {
00164     checkType();
00165 }
00166 
00167 
00168 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00169 
00170 void epsilonWallFunctionFvPatchScalarField::updateCoeffs()
00171 {
00172     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00173 
00174     const scalar Cmu25 = pow(Cmu_, 0.25);
00175     const scalar Cmu75 = pow(Cmu_, 0.75);
00176     const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
00177 
00178     const scalarField& y = rasModel.y()[patch().index()];
00179 
00180     volScalarField& G = const_cast<volScalarField&>
00181         (db().lookupObject<volScalarField>(GName_));
00182 
00183     volScalarField& epsilon = const_cast<volScalarField&>
00184         (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
00185 
00186     const volScalarField& k = db().lookupObject<volScalarField>(kName_);
00187 
00188     const scalarField& rhow =
00189         patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00190 
00191     const scalarField& muw =
00192         patch().lookupPatchField<volScalarField, scalar>(muName_);
00193 
00194     const scalarField& mutw =
00195         patch().lookupPatchField<volScalarField, scalar>(mutName_);
00196 
00197     const fvPatchVectorField& Uw =
00198         patch().lookupPatchField<volVectorField, vector>(UName_);
00199 
00200     const scalarField magGradUw = mag(Uw.snGrad());
00201 
00202     // Set epsilon and G
00203     forAll(mutw, faceI)
00204     {
00205         label faceCellI = patch().faceCells()[faceI];
00206 
00207         scalar yPlus =
00208             Cmu25*y[faceI]*sqrt(k[faceCellI])
00209            /(muw[faceI]/rhow[faceI]);
00210 
00211         epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]);
00212 
00213         if (yPlus > yPlusLam)
00214         {
00215             G[faceCellI] =
00216                 (mutw[faceI] + muw[faceI])
00217                *magGradUw[faceI]
00218                *Cmu25*sqrt(k[faceCellI])
00219                /(kappa_*y[faceI]);
00220         }
00221         else
00222         {
00223             G[faceCellI] = 0.0;
00224         }
00225     }
00226 
00227     // TODO: perform averaging for cells sharing more than one boundary face
00228 }
00229 
00230 
00231 void epsilonWallFunctionFvPatchScalarField::evaluate
00232 (
00233     const Pstream::commsTypes commsType
00234 )
00235 {
00236     fixedInternalValueFvPatchField<scalar>::evaluate(commsType);
00237 }
00238 
00239 
00240 void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const
00241 {
00242     fixedInternalValueFvPatchField<scalar>::write(os);
00243     writeEntryIfDifferent<word>(os, "U", "U", UName_);
00244     writeEntryIfDifferent<word>(os, "k", "k", kName_);
00245     writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
00246     writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
00247     writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
00248     writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
00249     os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
00250     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00251     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00252     writeEntry("value", os);
00253 }
00254 
00255 
00256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00257 
00258 makePatchTypeField
00259 (
00260     fvPatchScalarField,
00261     epsilonWallFunctionFvPatchScalarField
00262 );
00263 
00264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00265 
00266 } // End namespace RASModels
00267 } // End namespace compressible
00268 } // End namespace Foam
00269 
00270 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd