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 incompressible
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     nuName_("nu"),
00072     nutName_("nut"),
00073     Cmu_(0.09),
00074     kappa_(0.41),
00075     E_(9.8)
00076 {
00077     checkType();
00078 }
00079 
00080 
00081 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00082 (
00083     const epsilonWallFunctionFvPatchScalarField& ptf,
00084     const fvPatch& p,
00085     const DimensionedField<scalar, volMesh>& iF,
00086     const fvPatchFieldMapper& mapper
00087 )
00088 :
00089     fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
00090     UName_(ptf.UName_),
00091     kName_(ptf.kName_),
00092     GName_(ptf.GName_),
00093     nuName_(ptf.nuName_),
00094     nutName_(ptf.nutName_),
00095     Cmu_(ptf.Cmu_),
00096     kappa_(ptf.kappa_),
00097     E_(ptf.E_)
00098 {
00099     checkType();
00100 }
00101 
00102 
00103 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00104 (
00105     const fvPatch& p,
00106     const DimensionedField<scalar, volMesh>& iF,
00107     const dictionary& dict
00108 )
00109 :
00110     fixedInternalValueFvPatchField<scalar>(p, iF, dict),
00111     UName_(dict.lookupOrDefault<word>("U", "U")),
00112     kName_(dict.lookupOrDefault<word>("k", "k")),
00113     GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
00114     nuName_(dict.lookupOrDefault<word>("nu", "nu")),
00115     nutName_(dict.lookupOrDefault<word>("nut", "nut")),
00116     Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
00117     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00118     E_(dict.lookupOrDefault<scalar>("E", 9.8))
00119 {
00120     checkType();
00121 }
00122 
00123 
00124 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00125 (
00126     const epsilonWallFunctionFvPatchScalarField& ewfpsf
00127 )
00128 :
00129     fixedInternalValueFvPatchField<scalar>(ewfpsf),
00130     UName_(ewfpsf.UName_),
00131     kName_(ewfpsf.kName_),
00132     GName_(ewfpsf.GName_),
00133     nuName_(ewfpsf.nuName_),
00134     nutName_(ewfpsf.nutName_),
00135     Cmu_(ewfpsf.Cmu_),
00136     kappa_(ewfpsf.kappa_),
00137     E_(ewfpsf.E_)
00138 {
00139     checkType();
00140 }
00141 
00142 
00143 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00144 (
00145     const epsilonWallFunctionFvPatchScalarField& ewfpsf,
00146     const DimensionedField<scalar, volMesh>& iF
00147 )
00148 :
00149     fixedInternalValueFvPatchField<scalar>(ewfpsf, iF),
00150     UName_(ewfpsf.UName_),
00151     kName_(ewfpsf.kName_),
00152     GName_(ewfpsf.GName_),
00153     nuName_(ewfpsf.nuName_),
00154     nutName_(ewfpsf.nutName_),
00155     Cmu_(ewfpsf.Cmu_),
00156     kappa_(ewfpsf.kappa_),
00157     E_(ewfpsf.E_)
00158 {
00159     checkType();
00160 }
00161 
00162 
00163 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00164 
00165 void epsilonWallFunctionFvPatchScalarField::updateCoeffs()
00166 {
00167     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00168     const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
00169     const scalarField& y = rasModel.y()[patch().index()];
00170 
00171     const scalar Cmu25 = pow(Cmu_, 0.25);
00172     const scalar Cmu75 = pow(Cmu_, 0.75);
00173 
00174     volScalarField& G = const_cast<volScalarField&>
00175         (db().lookupObject<volScalarField>(GName_));
00176 
00177     volScalarField& epsilon = const_cast<volScalarField&>
00178         (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
00179 
00180     const volScalarField& k = db().lookupObject<volScalarField>(kName_);
00181 
00182     const scalarField& nuw =
00183         patch().lookupPatchField<volScalarField, scalar>(nuName_);
00184 
00185     const scalarField& nutw =
00186         patch().lookupPatchField<volScalarField, scalar>(nutName_);
00187 
00188     const fvPatchVectorField& Uw =
00189         patch().lookupPatchField<volVectorField, vector>(UName_);
00190 
00191     const scalarField magGradUw = mag(Uw.snGrad());
00192 
00193     // Set epsilon and G
00194     forAll(nutw, faceI)
00195     {
00196         label faceCellI = patch().faceCells()[faceI];
00197 
00198         scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
00199 
00200         epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]);
00201 
00202         if (yPlus > yPlusLam)
00203         {
00204             G[faceCellI] =
00205                 (nutw[faceI] + nuw[faceI])
00206                *magGradUw[faceI]
00207                *Cmu25*sqrt(k[faceCellI])
00208                /(kappa_*y[faceI]);
00209         }
00210         else
00211         {
00212             G[faceCellI] = 0.0;
00213         }
00214     }
00215 
00216     // TODO: perform averaging for cells sharing more than one boundary face
00217 }
00218 
00219 
00220 void epsilonWallFunctionFvPatchScalarField::evaluate
00221 (
00222     const Pstream::commsTypes commsType
00223 )
00224 {
00225     fixedInternalValueFvPatchField<scalar>::evaluate(commsType);
00226 }
00227 
00228 
00229 void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const
00230 {
00231     fixedInternalValueFvPatchField<scalar>::write(os);
00232     writeEntryIfDifferent<word>(os, "U", "U", UName_);
00233     writeEntryIfDifferent<word>(os, "k", "k", kName_);
00234     writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
00235     writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
00236     writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
00237     os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
00238     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00239     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00240     writeEntry("value", os);
00241 }
00242 
00243 
00244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00245 
00246 makePatchTypeField
00247 (
00248     fvPatchScalarField,
00249     epsilonWallFunctionFvPatchScalarField
00250 );
00251 
00252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00253 
00254 } // End namespace RASModels
00255 } // End namespace incompressible
00256 } // End namespace Foam
00257 
00258 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd