1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "kappatJayatillekeWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "wallFvPatch.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace incompressible
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44 scalar kappatJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01;
45 label kappatJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10;
47 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
49 void kappatJayatillekeWallFunctionFvPatchScalarField::checkType()
51 if (!isA<wallFvPatch>(patch()))
55 "kappatJayatillekeWallFunctionFvPatchScalarField::checkType()"
56 ) << "Invalid wall function specification" << nl
57 << " Patch type for patch " << patch().name()
58 << " must be wall" << nl
59 << " Current patch type is " << patch().type() << nl << endl
65 scalar kappatJayatillekeWallFunctionFvPatchScalarField::Psmooth
70 return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat));
74 scalar kappatJayatillekeWallFunctionFvPatchScalarField::yPlusTherm
82 for (int i=0; i<maxIters_; i++)
84 scalar f = ypt - (log(E_*ypt)/kappa_ + P)/Prat;
85 scalar df = 1.0 - 1.0/(ypt*kappa_*Prat);
86 scalar yptNew = ypt - f/df;
92 else if (mag(yptNew - ypt) < tolerance_)
106 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
108 kappatJayatillekeWallFunctionFvPatchScalarField::
109 kappatJayatillekeWallFunctionFvPatchScalarField
112 const DimensionedField<scalar, volMesh>& iF
115 fixedValueFvPatchScalarField(p, iF),
125 kappatJayatillekeWallFunctionFvPatchScalarField::
126 kappatJayatillekeWallFunctionFvPatchScalarField
128 const kappatJayatillekeWallFunctionFvPatchScalarField& ptf,
130 const DimensionedField<scalar, volMesh>& iF,
131 const fvPatchFieldMapper& mapper
134 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
144 kappatJayatillekeWallFunctionFvPatchScalarField::
145 kappatJayatillekeWallFunctionFvPatchScalarField
148 const DimensionedField<scalar, volMesh>& iF,
149 const dictionary& dict
152 fixedValueFvPatchScalarField(p, iF, dict),
153 Prt_(readScalar(dict.lookup("Prt"))), // force read to avoid ambiguity
154 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
155 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
156 E_(dict.lookupOrDefault<scalar>("E", 9.8))
162 kappatJayatillekeWallFunctionFvPatchScalarField::
163 kappatJayatillekeWallFunctionFvPatchScalarField
165 const kappatJayatillekeWallFunctionFvPatchScalarField& wfpsf
168 fixedValueFvPatchScalarField(wfpsf),
171 kappa_(wfpsf.kappa_),
178 kappatJayatillekeWallFunctionFvPatchScalarField::
179 kappatJayatillekeWallFunctionFvPatchScalarField
181 const kappatJayatillekeWallFunctionFvPatchScalarField& wfpsf,
182 const DimensionedField<scalar, volMesh>& iF
185 fixedValueFvPatchScalarField(wfpsf, iF),
188 kappa_(wfpsf.kappa_),
195 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
197 void kappatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs()
204 const label patchI = patch().index();
206 // Retrieve turbulence properties from model
207 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
208 const scalar Cmu25 = pow(Cmu_, 0.25);
209 const scalarField& y = rasModel.y()[patchI];
210 const scalarField& nuw = rasModel.nu()().boundaryField()[patchI];
211 const tmp<volScalarField> tk = rasModel.k();
212 const volScalarField& k = tk();
214 // Molecular Prandtl number
216 Pr(dimensionedScalar(rasModel.transport().lookup("Pr")).value());
218 // Populate boundary values
219 scalarField& kappatw = *this;
220 forAll(kappatw, faceI)
222 label faceCellI = patch().faceCells()[faceI];
225 scalar yPlus = Cmu25*sqrt(k[faceCellI])*y[faceI]/nuw[faceI];
227 // Molecular-to-turbulent Prandtl number ratio
228 scalar Prat = Pr/Prt_;
230 // Thermal sublayer thickness
231 scalar P = Psmooth(Prat);
232 scalar yPlusTherm = this->yPlusTherm(P, Prat);
234 // Update turbulent thermal conductivity
235 if (yPlus > yPlusTherm)
237 scalar nu = nuw[faceI];
238 scalar kt = nu*(yPlus/(Prt_*(log(E_*yPlus)/kappa_ + P)) - 1/Pr);
239 kappatw[faceI] = max(0.0, kt);
243 kappatw[faceI] = 0.0;
247 fixedValueFvPatchField<scalar>::updateCoeffs();
251 void kappatJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
253 fvPatchField<scalar>::write(os);
254 os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
255 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
256 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
257 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
258 writeEntry("value", os);
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 kappatJayatillekeWallFunctionFvPatchScalarField
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 } // End namespace RASModels
273 } // End namespace incompressible
274 } // End namespace Foam
276 // ************************************************************************* //