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 incompressible
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),
69 GName_("RASModel::G"),
81 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
83 const omegaWallFunctionFvPatchScalarField& ptf,
85 const DimensionedField<scalar, volMesh>& iF,
86 const fvPatchFieldMapper& mapper
89 fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
94 nutName_(ptf.nutName_),
104 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
107 const DimensionedField<scalar, volMesh>& iF,
108 const dictionary& dict
111 fixedInternalValueFvPatchField<scalar>(p, iF, dict),
112 UName_(dict.lookupOrDefault<word>("U", "U")),
113 kName_(dict.lookupOrDefault<word>("k", "k")),
114 GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
115 nuName_(dict.lookupOrDefault<word>("nu", "nu")),
116 nutName_(dict.lookupOrDefault<word>("nut", "nut")),
117 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
118 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
119 E_(dict.lookupOrDefault<scalar>("E", 9.8)),
120 beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
126 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
128 const omegaWallFunctionFvPatchScalarField& owfpsf
131 fixedInternalValueFvPatchField<scalar>(owfpsf),
132 UName_(owfpsf.UName_),
133 kName_(owfpsf.kName_),
134 GName_(owfpsf.GName_),
135 nuName_(owfpsf.nuName_),
136 nutName_(owfpsf.nutName_),
138 kappa_(owfpsf.kappa_),
140 beta1_(owfpsf.beta1_)
146 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
148 const omegaWallFunctionFvPatchScalarField& owfpsf,
149 const DimensionedField<scalar, volMesh>& iF
152 fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
153 UName_(owfpsf.UName_),
154 kName_(owfpsf.kName_),
155 GName_(owfpsf.GName_),
156 nuName_(owfpsf.nuName_),
157 nutName_(owfpsf.nutName_),
159 kappa_(owfpsf.kappa_),
161 beta1_(owfpsf.beta1_)
167 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
169 void omegaWallFunctionFvPatchScalarField::updateCoeffs()
176 // If G field is not present, execute zero gradient evaluation
178 if (!db().foundObject<volScalarField>(GName_))
180 zeroGradientFvPatchScalarField::evaluate();
185 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
186 const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
187 const scalarField& y = rasModel.y()[patch().index()];
189 const scalar Cmu25 = pow(Cmu_, 0.25);
191 volScalarField& G = const_cast<volScalarField&>
192 (db().lookupObject<volScalarField>(GName_));
194 volScalarField& omega = const_cast<volScalarField&>
195 (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
197 const scalarField& k = db().lookupObject<volScalarField>(kName_);
199 const scalarField& nuw =
200 patch().lookupPatchField<volScalarField, scalar>(nuName_);
202 const scalarField& nutw =
203 patch().lookupPatchField<volScalarField, scalar>(nutName_);
205 const fvPatchVectorField& Uw =
206 patch().lookupPatchField<volVectorField, vector>(UName_);
208 vectorField n = patch().nf();
210 const scalarField magGradUw = mag(Uw.snGrad());
215 label faceCellI = patch().faceCells()[faceI];
217 scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
219 scalar omegaVis = 6.0*nuw[faceI]/(beta1_*sqr(y[faceI]));
221 scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
223 omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
225 if (yPlus > yPlusLam)
228 (nutw[faceI] + nuw[faceI])
230 *Cmu25*sqrt(k[faceCellI])
239 // TODO: perform averaging for cells sharing more than one boundary face
241 fixedInternalValueFvPatchField<scalar>::updateCoeffs();
245 void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
247 fixedInternalValueFvPatchField<scalar>::write(os);
248 writeEntryIfDifferent<word>(os, "U", "U", UName_);
249 writeEntryIfDifferent<word>(os, "k", "k", kName_);
250 writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
251 writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
252 writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
253 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
254 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
255 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
256 os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
257 writeEntry("value", os);
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 omegaWallFunctionFvPatchScalarField
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 } // End namespace RASModels
272 } // End namespace incompressible
273 } // End namespace Foam
275 // ************************************************************************* //