1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "omegaWallFunctionFvPatchScalarField.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace compressible
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 void omegaWallFunctionFvPatchScalarField::checkType()
46 if (!patch().isWall())
48 FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
49 << "Invalid wall function specification" << nl
50 << " Patch type for patch " << patch().name()
51 << " must be wall" << nl
52 << " Current patch type is " << patch().type() << nl << endl
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
63 const DimensionedField<scalar, volMesh>& iF
66 fixedInternalValueFvPatchField<scalar>(p, iF),
70 GName_("RASModel::G"),
82 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
84 const omegaWallFunctionFvPatchScalarField& ptf,
86 const DimensionedField<scalar, volMesh>& iF,
87 const fvPatchFieldMapper& mapper
90 fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
92 rhoName_(ptf.rhoName_),
96 mutName_(ptf.mutName_),
106 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
109 const DimensionedField<scalar, volMesh>& iF,
110 const dictionary& dict
113 fixedInternalValueFvPatchField<scalar>(p, iF, dict),
114 UName_(dict.lookupOrDefault<word>("U", "U")),
115 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
116 kName_(dict.lookupOrDefault<word>("k", "k")),
117 GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
118 muName_(dict.lookupOrDefault<word>("mu", "mu")),
119 mutName_(dict.lookupOrDefault<word>("mut", "mut")),
120 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
121 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
122 E_(dict.lookupOrDefault<scalar>("E", 9.8)),
123 beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
129 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
131 const omegaWallFunctionFvPatchScalarField& owfpsf
134 fixedInternalValueFvPatchField<scalar>(owfpsf),
135 UName_(owfpsf.UName_),
136 rhoName_(owfpsf.rhoName_),
137 kName_(owfpsf.kName_),
138 GName_(owfpsf.GName_),
139 muName_(owfpsf.muName_),
140 mutName_(owfpsf.mutName_),
142 kappa_(owfpsf.kappa_),
144 beta1_(owfpsf.beta1_)
150 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
152 const omegaWallFunctionFvPatchScalarField& owfpsf,
153 const DimensionedField<scalar, volMesh>& iF
156 fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
157 UName_(owfpsf.UName_),
158 rhoName_(owfpsf.rhoName_),
159 kName_(owfpsf.kName_),
160 GName_(owfpsf.GName_),
161 muName_(owfpsf.muName_),
162 mutName_(owfpsf.mutName_),
164 kappa_(owfpsf.kappa_),
166 beta1_(owfpsf.beta1_)
172 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
174 void omegaWallFunctionFvPatchScalarField::updateCoeffs()
181 // If G field is not present, execute zero gradient evaluation
183 if (!db().foundObject<volScalarField>(GName_))
185 zeroGradientFvPatchScalarField::evaluate();
190 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
191 const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
192 const scalarField& y = rasModel.y()[patch().index()];
194 const scalar Cmu25 = pow(Cmu_, 0.25);
196 volScalarField& G = const_cast<volScalarField&>
197 (db().lookupObject<volScalarField>(GName_));
199 volScalarField& omega = const_cast<volScalarField&>
200 (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
202 const scalarField& k = db().lookupObject<volScalarField>(kName_);
204 const scalarField& rhow =
205 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
207 const scalarField& muw =
208 patch().lookupPatchField<volScalarField, scalar>(muName_);
210 const scalarField& mutw =
211 patch().lookupPatchField<volScalarField, scalar>(mutName_);
213 const fvPatchVectorField& Uw =
214 patch().lookupPatchField<volVectorField, vector>(UName_);
216 const scalarField magGradUw = mag(Uw.snGrad());
221 label faceCellI = patch().faceCells()[faceI];
224 Cmu25*y[faceI]*sqrt(k[faceCellI])
225 /(muw[faceI]/rhow[faceI]);
227 scalar omegaVis = 6.0*(muw[faceI]/rhow[faceI])/(beta1_*sqr(y[faceI]));
229 scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
231 omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
233 if (yPlus > yPlusLam)
236 (mutw[faceI] + muw[faceI])
238 *Cmu25*sqrt(k[faceCellI])
247 // TODO: perform averaging for cells sharing more than one boundary face
249 fixedInternalValueFvPatchField<scalar>::updateCoeffs();
253 void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
255 fixedInternalValueFvPatchField<scalar>::write(os);
256 writeEntryIfDifferent<word>(os, "U", "U", UName_);
257 writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
258 writeEntryIfDifferent<word>(os, "k", "k", kName_);
259 writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
260 writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
261 writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
262 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
263 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
264 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
265 os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
266 writeEntry("value", os);
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 omegaWallFunctionFvPatchScalarField
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 } // End namespace RASModels
281 } // End namespace compressible
282 } // End namespace Foam
284 // ************************************************************************* //