1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "alphaSgsJayatillekeWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "addToRunTimeSelectionTable.H"
31 #include "wallFvPatch.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 (!isA<wallFvPatch>(patch()))
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),
126 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
127 alphaSgsJayatillekeWallFunctionFvPatchScalarField
129 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& ptf,
131 const DimensionedField<scalar, volMesh>& iF,
132 const fvPatchFieldMapper& mapper
135 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
144 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
145 alphaSgsJayatillekeWallFunctionFvPatchScalarField
148 const DimensionedField<scalar, volMesh>& iF,
149 const dictionary& dict
152 fixedValueFvPatchScalarField(p, iF, dict),
153 Prt_(dict.lookupOrDefault<scalar>("Prt", 0.85)),
154 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
155 E_(dict.lookupOrDefault<scalar>("E", 9.8)),
156 hsName_(dict.lookupOrDefault<word>("hs", "hs"))
162 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
163 alphaSgsJayatillekeWallFunctionFvPatchScalarField
165 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf
168 fixedValueFvPatchScalarField(awfpsf),
170 kappa_(awfpsf.kappa_),
172 hsName_(awfpsf.hsName_)
178 alphaSgsJayatillekeWallFunctionFvPatchScalarField::
179 alphaSgsJayatillekeWallFunctionFvPatchScalarField
181 const alphaSgsJayatillekeWallFunctionFvPatchScalarField& awfpsf,
182 const DimensionedField<scalar, volMesh>& iF
185 fixedValueFvPatchScalarField(awfpsf, iF),
187 kappa_(awfpsf.kappa_),
189 hsName_(awfpsf.hsName_)
195 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
197 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::evaluate
199 const Pstream::commsTypes
202 const LESModel& lesModel = db().lookupObject<LESModel>("LESProperties");
205 const label patchI = patch().index();
207 const scalarField& muw = lesModel.mu().boundaryField()[patchI];
208 const scalarField muSgsw(lesModel.muSgs()().boundaryField()[patchI]);
210 const scalarField& alphaw = lesModel.alpha().boundaryField()[patchI];
211 scalarField& alphaSgsw = *this;
213 const fvPatchVectorField& Uw = lesModel.U().boundaryField()[patchI];
214 const scalarField magUp(mag(Uw.patchInternalField() - Uw));
215 const scalarField magGradUw(mag(Uw.snGrad()));
217 const scalarField& rhow = lesModel.rho().boundaryField()[patchI];
218 const fvPatchScalarField& hw =
219 patch().lookupPatchField<volScalarField, scalar>(hsName_);
221 const scalarField& ry = patch().deltaCoeffs();
223 // Heat flux [W/m2] - lagging alphaSgsw
224 const scalarField qDot((alphaw + alphaSgsw)*hw.snGrad());
226 // Populate boundary values
227 forAll(alphaSgsw, faceI)
229 // Calculate uTau using Newton-Raphson iteration
231 sqrt((muSgsw[faceI] + muw[faceI])/rhow[faceI]*magGradUw[faceI]);
233 if (uTau > ROOTVSMALL)
240 scalar kUu = min(kappa_*magUp[faceI]/uTau, maxExp_);
241 scalar fkUu = exp(kUu) - 1.0 - kUu*(1.0 + 0.5*kUu);
244 - uTau/(ry[faceI]*muw[faceI]/rhow[faceI])
246 + 1.0/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
249 - 1.0/(ry[faceI]*muw[faceI]/rhow[faceI])
250 - magUp[faceI]/sqr(uTau)
251 - 1.0/E_*kUu*fkUu/uTau;
253 scalar uTauNew = uTau - f/df;
254 err = mag((uTau - uTauNew)/uTau);
257 } while (uTau>VSMALL && err>tolerance_ && ++iter<maxIters_);
259 scalar yPlus = uTau/ry[faceI]/(muw[faceI]/rhow[faceI]);
261 // Molecular Prandtl number
262 scalar Pr = muw[faceI]/alphaw[faceI];
264 // Molecular-to-turbulenbt Prandtl number ratio
265 scalar Prat = Pr/Prt_;
267 // Thermal sublayer thickness
268 scalar P = Psmooth(Prat);
269 scalar yPlusTherm = this->yPlusTherm(P, Prat);
271 // Evaluate new effective thermal diffusivity
272 scalar alphaEff = 0.0;
273 if (yPlus < yPlusTherm)
275 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
276 scalar B = qDot[faceI]*Pr*yPlus;
277 scalar C = Pr*0.5*rhow[faceI]*uTau*sqr(magUp[faceI]);
278 alphaEff = A/(B + C + VSMALL);
282 scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI];
283 scalar B = qDot[faceI]*Prt_*(1.0/kappa_*log(E_*yPlus) + P);
284 scalar magUc = uTau/kappa_*log(E_*yPlusTherm) - mag(Uw[faceI]);
287 *(Prt_*sqr(magUp[faceI]) + (Pr - Prt_)*sqr(magUc));
288 alphaEff = A/(B + C + VSMALL);
291 // Update turbulent thermal diffusivity
292 alphaSgsw[faceI] = max(0.0, alphaEff - alphaw[faceI]);
296 Info<< " uTau = " << uTau << nl
297 << " Pr = " << Pr << nl
298 << " Prt = " << Prt_ << nl
299 << " qDot = " << qDot[faceI] << nl
300 << " yPlus = " << yPlus << nl
301 << " yPlusTherm = " << yPlusTherm << nl
302 << " alphaEff = " << alphaEff << nl
303 << " alphaw = " << alphaw[faceI] << nl
304 << " alphaSgsw = " << alphaSgsw[faceI] << nl
310 alphaSgsw[faceI] = 0.0;
316 void alphaSgsJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
318 fvPatchField<scalar>::write(os);
319 os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
320 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
321 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
322 os.writeKeyword("hs") << hsName_ << token::END_STATEMENT << nl;
323 writeEntry("value", os);
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 alphaSgsJayatillekeWallFunctionFvPatchScalarField
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 } // End namespace LESModels
338 } // End namespace compressible
339 } // End namespace Foam
341 // ************************************************************************* //