1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
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"
32 #include "wallFvPatch.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 namespace incompressible
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 void omegaWallFunctionFvPatchScalarField::checkType()
47 if (!isA<wallFvPatch>(patch()))
49 FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
50 << "Invalid wall function specification" << nl
51 << " Patch type for patch " << patch().name()
52 << " must be wall" << nl
53 << " Current patch type is " << patch().type() << nl << endl
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
64 const DimensionedField<scalar, volMesh>& iF
67 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),
95 nutName_(ptf.nutName_),
105 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
108 const DimensionedField<scalar, volMesh>& iF,
109 const dictionary& dict
112 fixedInternalValueFvPatchField<scalar>(p, iF, dict),
113 UName_(dict.lookupOrDefault<word>("U", "U")),
114 kName_(dict.lookupOrDefault<word>("k", "k")),
115 GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
116 nuName_(dict.lookupOrDefault<word>("nu", "nu")),
117 nutName_(dict.lookupOrDefault<word>("nut", "nut")),
118 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
119 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
120 E_(dict.lookupOrDefault<scalar>("E", 9.8)),
121 beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
127 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
129 const omegaWallFunctionFvPatchScalarField& owfpsf
132 fixedInternalValueFvPatchField<scalar>(owfpsf),
133 UName_(owfpsf.UName_),
134 kName_(owfpsf.kName_),
135 GName_(owfpsf.GName_),
136 nuName_(owfpsf.nuName_),
137 nutName_(owfpsf.nutName_),
139 kappa_(owfpsf.kappa_),
141 beta1_(owfpsf.beta1_)
147 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
149 const omegaWallFunctionFvPatchScalarField& owfpsf,
150 const DimensionedField<scalar, volMesh>& iF
153 fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
154 UName_(owfpsf.UName_),
155 kName_(owfpsf.kName_),
156 GName_(owfpsf.GName_),
157 nuName_(owfpsf.nuName_),
158 nutName_(owfpsf.nutName_),
160 kappa_(owfpsf.kappa_),
162 beta1_(owfpsf.beta1_)
168 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
170 void omegaWallFunctionFvPatchScalarField::updateCoeffs()
177 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
178 const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
179 const scalarField& y = rasModel.y()[patch().index()];
181 const scalar Cmu25 = pow(Cmu_, 0.25);
183 volScalarField& G = const_cast<volScalarField&>
184 (db().lookupObject<volScalarField>(GName_));
186 volScalarField& omega = const_cast<volScalarField&>
187 (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
189 const scalarField& k = db().lookupObject<volScalarField>(kName_);
191 const scalarField& nuw =
192 patch().lookupPatchField<volScalarField, scalar>(nuName_);
194 const scalarField& nutw =
195 patch().lookupPatchField<volScalarField, scalar>(nutName_);
197 const fvPatchVectorField& Uw =
198 patch().lookupPatchField<volVectorField, vector>(UName_);
200 vectorField n = patch().nf();
202 const scalarField magGradUw = mag(Uw.snGrad());
207 label faceCellI = patch().faceCells()[faceI];
209 scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
211 scalar omegaVis = 6.0*nuw[faceI]/(beta1_*sqr(y[faceI]));
213 scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
215 omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
217 if (yPlus > yPlusLam)
220 (nutw[faceI] + nuw[faceI])
222 *Cmu25*sqrt(k[faceCellI])
231 // TODO: perform averaging for cells sharing more than one boundary face
233 fixedInternalValueFvPatchField<scalar>::updateCoeffs();
237 void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
239 fixedInternalValueFvPatchField<scalar>::write(os);
240 writeEntryIfDifferent<word>(os, "U", "U", UName_);
241 writeEntryIfDifferent<word>(os, "k", "k", kName_);
242 writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
243 writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
244 writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
245 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
246 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
247 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
248 os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
249 writeEntry("value", os);
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 omegaWallFunctionFvPatchScalarField
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 } // End namespace RASModels
264 } // End namespace incompressible
265 } // End namespace Foam
267 // ************************************************************************* //