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 compressible
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),
71 GName_("RASModel::G"),
83 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
85 const omegaWallFunctionFvPatchScalarField& ptf,
87 const DimensionedField<scalar, volMesh>& iF,
88 const fvPatchFieldMapper& mapper
91 fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
93 rhoName_(ptf.rhoName_),
97 mutName_(ptf.mutName_),
107 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
110 const DimensionedField<scalar, volMesh>& iF,
111 const dictionary& dict
114 fixedInternalValueFvPatchField<scalar>(p, iF, dict),
115 UName_(dict.lookupOrDefault<word>("U", "U")),
116 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
117 kName_(dict.lookupOrDefault<word>("k", "k")),
118 GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
119 muName_(dict.lookupOrDefault<word>("mu", "mu")),
120 mutName_(dict.lookupOrDefault<word>("mut", "mut")),
121 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
122 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
123 E_(dict.lookupOrDefault<scalar>("E", 9.8)),
124 beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
130 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
132 const omegaWallFunctionFvPatchScalarField& owfpsf
135 fixedInternalValueFvPatchField<scalar>(owfpsf),
136 UName_(owfpsf.UName_),
137 rhoName_(owfpsf.rhoName_),
138 kName_(owfpsf.kName_),
139 GName_(owfpsf.GName_),
140 muName_(owfpsf.muName_),
141 mutName_(owfpsf.mutName_),
143 kappa_(owfpsf.kappa_),
145 beta1_(owfpsf.beta1_)
151 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
153 const omegaWallFunctionFvPatchScalarField& owfpsf,
154 const DimensionedField<scalar, volMesh>& iF
157 fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
158 UName_(owfpsf.UName_),
159 rhoName_(owfpsf.rhoName_),
160 kName_(owfpsf.kName_),
161 GName_(owfpsf.GName_),
162 muName_(owfpsf.muName_),
163 mutName_(owfpsf.mutName_),
165 kappa_(owfpsf.kappa_),
167 beta1_(owfpsf.beta1_)
173 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
175 void omegaWallFunctionFvPatchScalarField::updateCoeffs()
182 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
183 const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
184 const scalarField& y = rasModel.y()[patch().index()];
186 const scalar Cmu25 = pow(Cmu_, 0.25);
188 volScalarField& G = const_cast<volScalarField&>
189 (db().lookupObject<volScalarField>(GName_));
191 volScalarField& omega = const_cast<volScalarField&>
192 (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
194 const scalarField& k = db().lookupObject<volScalarField>(kName_);
196 const scalarField& rhow =
197 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
199 const scalarField& muw =
200 patch().lookupPatchField<volScalarField, scalar>(muName_);
202 const scalarField& mutw =
203 patch().lookupPatchField<volScalarField, scalar>(mutName_);
205 const fvPatchVectorField& Uw =
206 patch().lookupPatchField<volVectorField, vector>(UName_);
208 const scalarField magGradUw = mag(Uw.snGrad());
213 label faceCellI = patch().faceCells()[faceI];
216 Cmu25*y[faceI]*sqrt(k[faceCellI])
217 /(muw[faceI]/rhow[faceI]);
219 scalar omegaVis = 6.0*(muw[faceI]/rhow[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 (mutw[faceI] + muw[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, "rho", "rho", rhoName_);
250 writeEntryIfDifferent<word>(os, "k", "k", kName_);
251 writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
252 writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
253 writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
254 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
255 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
256 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
257 os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
258 writeEntry("value", os);
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 omegaWallFunctionFvPatchScalarField
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 } // End namespace RASModels
273 } // End namespace compressible
274 } // End namespace Foam
276 // ************************************************************************* //