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 "alphaSgsJayatillekeWallFunctionFvPatchScalarField.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "wallFvPatch.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 namespace compressible
43 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
45 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxExp_ = 50.0;
46 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01;
47 label alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10;
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType()
53 if (!isA<wallFvPatch>(patch()))
57 "alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType()"
59 << "Patch type for patch " << patch().name() << " must be wall\n"
60 << "Current patch type is " << patch().type() << nl
66 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::Psmooth
71 return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat));
75 scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::yPlusTherm
83 for (int i=0; i<maxIters_; i++)
85 scalar f = ypt - (log(E_*ypt)/kappa_ + P)/Prat;
86 scalar df = 1.0 - 1.0/(ypt*kappa_*Prat);
87 scalar yptNew = ypt - f/df;
93 else if (mag(yptNew - ypt) < tolerance_)
107 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
109 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
110 alphaSgsJayatillekeWallFunctionFvPatchScalarField
113 const DimensionedField<scalar, volMesh>& iF
116 fixedValueFvPatchScalarField(p, iF),
125 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
126 alphaSgsJayatillekeWallFunctionFvPatchScalarField
128 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& ptf,
130 const DimensionedField<scalar, volMesh>& iF,
131 const fvPatchFieldMapper& mapper
134 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
141 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
142 alphaSgsJayatillekeWallFunctionFvPatchScalarField
145 const DimensionedField<scalar, volMesh>& iF,
146 const dictionary& dict
149 fixedValueFvPatchScalarField(p, iF, dict),
150 Prt_(dict.lookupOrDefault<scalar>("Prt", 0.85)),
151 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
152 E_(dict.lookupOrDefault<scalar>("E", 9.8))
158 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
159 alphaSgsJayatillekeWallFunctionFvPatchScalarField
161 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf
164 fixedValueFvPatchScalarField(awfpsf),
166 kappa_(awfpsf.kappa_),
173 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
174 alphaSgsJayatillekeWallFunctionFvPatchScalarField
176 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf,
177 const DimensionedField<scalar, volMesh>& iF
180 fixedValueFvPatchScalarField(awfpsf, iF),
182 kappa_(awfpsf.kappa_),
189 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
191 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::evaluate
193 const Pstream::commsTypes
196 const LESModel& lesModel = db().lookupObject<LESModel>("LESProperties");
199 const label patchI = patch().index();
201 const scalarField& muw = lesModel.mu().boundaryField()[patchI];
202 const scalarField muSgsw = lesModel.muSgs()().boundaryField()[patchI];
204 const scalarField& alphaw = lesModel.alpha().boundaryField()[patchI];
205 scalarField& alphaSgsw = *this;
207 const fvPatchVectorField& Uw = lesModel.U().boundaryField()[patchI];
208 const scalarField magUp = mag(Uw.patchInternalField() - Uw);
209 const scalarField magGradUw = mag(Uw.snGrad());
211 const scalarField& rhow = lesModel.rho().boundaryField()[patchI];
212 const fvPatchScalarField& hw =
213 patch().lookupPatchField<volScalarField, scalar>("h");
215 const scalarField& ry = patch().deltaCoeffs();
217 // Heat flux [W/m2] - lagging alphaSgsw
218 const scalarField qDot = (alphaw + alphaSgsw)*hw.snGrad();
220 // Populate boundary values
221 forAll(alphaSgsw, faceI)
223 // Calculate uTau using Newton-Raphson iteration
225 sqrt((muSgsw[faceI] + muw[faceI])/rhow[faceI]*magGradUw[faceI]);
227 if (uTau > ROOTVSMALL)
234 scalar kUu = min(kappa_*magUp[faceI]/uTau, maxExp_);
235 scalar fkUu = exp(kUu) - 1.0 - kUu*(1.0 + 0.5*kUu);
238 - uTau/(ry[faceI]*muw[faceI]/rhow[faceI])
240 + 1.0/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
243 - 1.0/(ry[faceI]*muw[faceI]/rhow[faceI])
244 - magUp[faceI]/sqr(uTau)
245 - 1.0/E_*kUu*fkUu/uTau;
247 scalar uTauNew = uTau - f/df;
248 err = mag((uTau - uTauNew)/uTau);
251 } while (uTau>VSMALL && err>tolerance_ && ++iter<maxIters_);
253 scalar yPlus = uTau/ry[faceI]/(muw[faceI]/rhow[faceI]);
255 // Molecular Prandtl number
256 scalar Pr = muw[faceI]/alphaw[faceI];
258 // Molecular-to-turbulenbt Prandtl number ratio
259 scalar Prat = Pr/Prt_;
261 // Thermal sublayer thickness
262 scalar P = Psmooth(Prat);
263 scalar yPlusTherm = this->yPlusTherm(P, Prat);
265 // Evaluate new effective thermal diffusivity
266 scalar alphaEff = 0.0;
267 if (yPlus < yPlusTherm)
269 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
270 scalar B = qDot[faceI]*Pr*yPlus;
271 scalar C = Pr*0.5*rhow[faceI]*uTau*sqr(magUp[faceI]);
272 alphaEff = A/(B + C + VSMALL);
276 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
277 scalar B = qDot[faceI]*Prt_*(1.0/kappa_*log(E_*yPlus) + P);
278 scalar magUc = uTau/kappa_*log(E_*yPlusTherm) - mag(Uw[faceI]);
281 *(Prt_*sqr(magUp[faceI]) + (Pr - Prt_)*sqr(magUc));
282 alphaEff = A/(B + C + VSMALL);
285 // Update turbulent thermal diffusivity
286 alphaSgsw[faceI] = max(0.0, alphaEff - alphaw[faceI]);
290 Info<< " uTau = " << uTau << nl
291 << " Pr = " << Pr << nl
292 << " Prt = " << Prt_ << nl
293 << " qDot = " << qDot[faceI] << nl
294 << " yPlus = " << yPlus << nl
295 << " yPlusTherm = " << yPlusTherm << nl
296 << " alphaEff = " << alphaEff << nl
297 << " alphaw = " << alphaw[faceI] << nl
298 << " alphaSgsw = " << alphaSgsw[faceI] << nl
304 alphaSgsw[faceI] = 0.0;
310 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
312 fvPatchField<scalar>::write(os);
313 os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
314 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
315 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
316 writeEntry("value", os);
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325 alphaSgsJayatillekeWallFunctionFvPatchScalarField
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 } // End namespace LESModels
331 } // End namespace compressible
332 } // End namespace Foam
334 // ************************************************************************* //