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 "alphaSgsJayatillekeWallFunctionFvPatchScalarField.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace compressible
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxExp_ = 50.0;
45 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01;
46 label alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10;
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType()
52 if (!patch().isWall())
56 "alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType()"
58 << "Patch type for patch " << patch().name() << " must be wall\n"
59 << "Current patch type is " << patch().type() << nl
65 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::Psmooth
70 return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat));
74 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::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 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
109 alphaSgsJayatillekeWallFunctionFvPatchScalarField
112 const DimensionedField<scalar, volMesh>& iF
115 fixedValueFvPatchScalarField(p, iF),
124 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
125 alphaSgsJayatillekeWallFunctionFvPatchScalarField
127 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& ptf,
129 const DimensionedField<scalar, volMesh>& iF,
130 const fvPatchFieldMapper& mapper
133 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
140 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
141 alphaSgsJayatillekeWallFunctionFvPatchScalarField
144 const DimensionedField<scalar, volMesh>& iF,
145 const dictionary& dict
148 fixedValueFvPatchScalarField(p, iF, dict),
149 Prt_(dict.lookupOrDefault<scalar>("Prt", 0.85)),
150 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
151 E_(dict.lookupOrDefault<scalar>("E", 9.8))
157 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
158 alphaSgsJayatillekeWallFunctionFvPatchScalarField
160 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf
163 fixedValueFvPatchScalarField(awfpsf),
165 kappa_(awfpsf.kappa_),
172 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
173 alphaSgsJayatillekeWallFunctionFvPatchScalarField
175 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf,
176 const DimensionedField<scalar, volMesh>& iF
179 fixedValueFvPatchScalarField(awfpsf, iF),
181 kappa_(awfpsf.kappa_),
188 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
190 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::evaluate
192 const Pstream::commsTypes
195 const LESModel& lesModel = db().lookupObject<LESModel>("LESProperties");
198 const label patchI = patch().index();
200 const scalarField& muw = lesModel.mu().boundaryField()[patchI];
201 const scalarField muSgsw = lesModel.muSgs()().boundaryField()[patchI];
203 const scalarField& alphaw = lesModel.alpha().boundaryField()[patchI];
204 scalarField& alphaSgsw = *this;
206 const fvPatchVectorField& Uw = lesModel.U().boundaryField()[patchI];
207 const scalarField magUp = mag(Uw.patchInternalField() - Uw);
208 const scalarField magGradUw = mag(Uw.snGrad());
210 const scalarField& rhow = lesModel.rho().boundaryField()[patchI];
211 const fvPatchScalarField& hw =
212 patch().lookupPatchField<volScalarField, scalar>("h");
214 const scalarField& ry = patch().deltaCoeffs();
216 // Heat flux [W/m2] - lagging alphaSgsw
217 const scalarField qDot = (alphaw + alphaSgsw)*hw.snGrad();
219 // Populate boundary values
220 forAll(alphaSgsw, faceI)
222 // Calculate uTau using Newton-Raphson iteration
224 sqrt((muSgsw[faceI] + muw[faceI])/rhow[faceI]*magGradUw[faceI]);
226 if (uTau > ROOTVSMALL)
233 scalar kUu = min(kappa_*magUp[faceI]/uTau, maxExp_);
234 scalar fkUu = exp(kUu) - 1.0 - kUu*(1.0 + 0.5*kUu);
237 - uTau/(ry[faceI]*muw[faceI]/rhow[faceI])
239 + 1.0/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
242 - 1.0/(ry[faceI]*muw[faceI]/rhow[faceI])
243 - magUp[faceI]/sqr(uTau)
244 - 1.0/E_*kUu*fkUu/uTau;
246 scalar uTauNew = uTau - f/df;
247 err = mag((uTau - uTauNew)/uTau);
250 } while (uTau>VSMALL && err>tolerance_ && ++iter<maxIters_);
252 scalar yPlus = uTau/ry[faceI]/(muw[faceI]/rhow[faceI]);
254 // Molecular Prandtl number
255 scalar Pr = muw[faceI]/alphaw[faceI];
257 // Molecular-to-turbulenbt Prandtl number ratio
258 scalar Prat = Pr/Prt_;
260 // Thermal sublayer thickness
261 scalar P = Psmooth(Prat);
262 scalar yPlusTherm = this->yPlusTherm(P, Prat);
264 // Evaluate new effective thermal diffusivity
265 scalar alphaEff = 0.0;
266 if (yPlus < yPlusTherm)
268 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
269 scalar B = qDot[faceI]*Pr*yPlus;
270 scalar C = Pr*0.5*rhow[faceI]*uTau*sqr(magUp[faceI]);
271 alphaEff = A/(B + C + VSMALL);
275 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
276 scalar B = qDot[faceI]*Prt_*(1.0/kappa_*log(E_*yPlus) + P);
277 scalar magUc = uTau/kappa_*log(E_*yPlusTherm) - mag(Uw[faceI]);
280 *(Prt_*sqr(magUp[faceI]) + (Pr - Prt_)*sqr(magUc));
281 alphaEff = A/(B + C + VSMALL);
284 // Update turbulent thermal diffusivity
285 alphaSgsw[faceI] = max(0.0, alphaEff - alphaw[faceI]);
289 Info<< " uTau = " << uTau << nl
290 << " Pr = " << Pr << nl
291 << " Prt = " << Prt_ << nl
292 << " qDot = " << qDot[faceI] << nl
293 << " yPlus = " << yPlus << nl
294 << " yPlusTherm = " << yPlusTherm << nl
295 << " alphaEff = " << alphaEff << nl
296 << " alphaw = " << alphaw[faceI] << nl
297 << " alphaSgsw = " << alphaSgsw[faceI] << nl
303 alphaSgsw[faceI] = 0.0;
309 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
311 fvPatchField<scalar>::write(os);
312 os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
313 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
314 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
315 writeEntry("value", os);
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 alphaSgsJayatillekeWallFunctionFvPatchScalarField
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329 } // End namespace LESModels
330 } // End namespace compressible
331 } // End namespace Foam
333 // ************************************************************************* //