FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

omegaWallFunctionFvPatchScalarField.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "omegaWallFunctionFvPatchScalarField.H"
00027 #include <compressibleRASModels/RASModel.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 #include <finiteVolume/wallFvPatch.H>
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 namespace compressible
00038 {
00039 namespace RASModels
00040 {
00041 
00042 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00043 
00044 void omegaWallFunctionFvPatchScalarField::checkType()
00045 {
00046     if (!isA<wallFvPatch>(patch()))
00047     {
00048         FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
00049             << "Invalid wall function specification" << nl
00050             << "    Patch type for patch " << patch().name()
00051             << " must be wall" << nl
00052             << "    Current patch type is " << patch().type() << nl << endl
00053             << abort(FatalError);
00054     }
00055 }
00056 
00057 
00058 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00059 
00060 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00061 (
00062     const fvPatch& p,
00063     const DimensionedField<scalar, volMesh>& iF
00064 )
00065 :
00066     fixedInternalValueFvPatchField<scalar>(p, iF),
00067     UName_("U"),
00068     rhoName_("rho"),
00069     kName_("k"),
00070     GName_("RASModel::G"),
00071     muName_("mu"),
00072     mutName_("mut"),
00073     Cmu_(0.09),
00074     kappa_(0.41),
00075     E_(9.8),
00076     beta1_(0.075)
00077 {
00078     checkType();
00079 }
00080 
00081 
00082 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00083 (
00084     const omegaWallFunctionFvPatchScalarField& 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     rhoName_(ptf.rhoName_),
00093     kName_(ptf.kName_),
00094     GName_(ptf.GName_),
00095     muName_(ptf.muName_),
00096     mutName_(ptf.mutName_),
00097     Cmu_(ptf.Cmu_),
00098     kappa_(ptf.kappa_),
00099     E_(ptf.E_),
00100     beta1_(ptf.beta1_)
00101 {
00102     checkType();
00103 }
00104 
00105 
00106 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00107 (
00108     const fvPatch& p,
00109     const DimensionedField<scalar, volMesh>& iF,
00110     const dictionary& dict
00111 )
00112 :
00113     fixedInternalValueFvPatchField<scalar>(p, iF, dict),
00114     UName_(dict.lookupOrDefault<word>("U", "U")),
00115     rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
00116     kName_(dict.lookupOrDefault<word>("k", "k")),
00117     GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
00118     muName_(dict.lookupOrDefault<word>("mu", "mu")),
00119     mutName_(dict.lookupOrDefault<word>("mut", "mut")),
00120     Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
00121     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00122     E_(dict.lookupOrDefault<scalar>("E", 9.8)),
00123     beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
00124 {
00125     checkType();
00126 }
00127 
00128 
00129 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00130 (
00131     const omegaWallFunctionFvPatchScalarField& owfpsf
00132 )
00133 :
00134     fixedInternalValueFvPatchField<scalar>(owfpsf),
00135     UName_(owfpsf.UName_),
00136     rhoName_(owfpsf.rhoName_),
00137     kName_(owfpsf.kName_),
00138     GName_(owfpsf.GName_),
00139     muName_(owfpsf.muName_),
00140     mutName_(owfpsf.mutName_),
00141     Cmu_(owfpsf.Cmu_),
00142     kappa_(owfpsf.kappa_),
00143     E_(owfpsf.E_),
00144     beta1_(owfpsf.beta1_)
00145 {
00146     checkType();
00147 }
00148 
00149 
00150 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00151 (
00152     const omegaWallFunctionFvPatchScalarField& owfpsf,
00153     const DimensionedField<scalar, volMesh>& iF
00154 )
00155 :
00156     fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
00157     UName_(owfpsf.UName_),
00158     rhoName_(owfpsf.rhoName_),
00159     kName_(owfpsf.kName_),
00160     GName_(owfpsf.GName_),
00161     muName_(owfpsf.muName_),
00162     mutName_(owfpsf.mutName_),
00163     Cmu_(owfpsf.Cmu_),
00164     kappa_(owfpsf.kappa_),
00165     E_(owfpsf.E_),
00166     beta1_(owfpsf.beta1_)
00167 {
00168     checkType();
00169 }
00170 
00171 
00172 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00173 
00174 void omegaWallFunctionFvPatchScalarField::updateCoeffs()
00175 {
00176     if (updated())
00177     {
00178         return;
00179     }
00180 
00181     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00182     const scalarField& y = rasModel.y()[patch().index()];
00183 
00184     const scalar Cmu25 = pow(Cmu_, 0.25);
00185 
00186     volScalarField& G = const_cast<volScalarField&>
00187         (db().lookupObject<volScalarField>(GName_));
00188 
00189     volScalarField& omega = const_cast<volScalarField&>
00190         (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
00191 
00192     const scalarField& k = db().lookupObject<volScalarField>(kName_);
00193 
00194     const scalarField& rhow =
00195         patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00196 
00197     const scalarField& muw =
00198         patch().lookupPatchField<volScalarField, scalar>(muName_);
00199 
00200     const scalarField& mutw =
00201         patch().lookupPatchField<volScalarField, scalar>(mutName_);
00202 
00203     const fvPatchVectorField& Uw =
00204         patch().lookupPatchField<volVectorField, vector>(UName_);
00205 
00206     const scalarField magGradUw = mag(Uw.snGrad());
00207 
00208     // Set omega and G
00209     forAll(mutw, faceI)
00210     {
00211         label faceCellI = patch().faceCells()[faceI];
00212 
00213         scalar omegaVis = 6.0*(muw[faceI]/rhow[faceI])/(beta1_*sqr(y[faceI]));
00214         scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
00215         omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
00216 
00217         G[faceCellI] =
00218             (mutw[faceI] + muw[faceI])
00219            *magGradUw[faceI]
00220            *Cmu25*sqrt(k[faceCellI])
00221            /(kappa_*y[faceI]);
00222     }
00223 
00224     // TODO: perform averaging for cells sharing more than one boundary face
00225 
00226     fixedInternalValueFvPatchField<scalar>::updateCoeffs();
00227 }
00228 
00229 
00230 void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
00231 {
00232     fixedInternalValueFvPatchField<scalar>::write(os);
00233     writeEntryIfDifferent<word>(os, "U", "U", UName_);
00234     writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
00235     writeEntryIfDifferent<word>(os, "k", "k", kName_);
00236     writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
00237     writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
00238     writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
00239     os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
00240     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00241     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00242     os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
00243     writeEntry("value", os);
00244 }
00245 
00246 
00247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00248 
00249 makePatchTypeField
00250 (
00251     fvPatchScalarField,
00252     omegaWallFunctionFvPatchScalarField
00253 );
00254 
00255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00256 
00257 } // End namespace RASModels
00258 } // End namespace compressible
00259 } // End namespace Foam
00260 
00261 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines