alphatJayatillekeWallFunctionFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace compressible
35 {
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 scalar alphatJayatillekeWallFunctionFvPatchScalarField::maxExp_ = 50.0;
40 scalar alphatJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01;
41 label alphatJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10;
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 scalar alphatJayatillekeWallFunctionFvPatchScalarField::Psmooth
46 (
47  const scalar Prat
48 ) const
49 {
50  return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat));
51 }
52 
53 
54 scalar alphatJayatillekeWallFunctionFvPatchScalarField::yPlusTherm
55 (
56  const nutWallFunctionFvPatchScalarField& nutw,
57  const scalar P,
58  const scalar Prat
59 ) const
60 {
61  scalar ypt = 11.0;
62 
63  for (int i=0; i<maxIters_; i++)
64  {
65  scalar f = ypt - (log(nutw.E()*ypt)/nutw.kappa() + P)/Prat;
66  scalar df = 1.0 - 1.0/(ypt*nutw.kappa()*Prat);
67  scalar yptNew = ypt - f/df;
68 
69  if (yptNew < vSmall)
70  {
71  return 0;
72  }
73  else if (mag(yptNew - ypt) < tolerance_)
74  {
75  return yptNew;
76  }
77  else
78  {
79  ypt = yptNew;
80  }
81  }
82 
83  return ypt;
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 
91 (
92  const fvPatch& p,
94 )
95 :
96  fixedValueFvPatchScalarField(p, iF),
97  Prt_(0.85)
98 {}
99 
100 
103 (
105  const fvPatch& p,
107  const fvPatchFieldMapper& mapper
108 )
109 :
110  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
111  Prt_(ptf.Prt_)
112 {}
113 
114 
117 (
118  const fvPatch& p,
120  const dictionary& dict
121 )
122 :
123  fixedValueFvPatchScalarField(p, iF, dict),
124  Prt_(dict.lookupOrDefault<scalar>("Prt", 0.85))
125 {}
126 
127 
130 (
132 )
133 :
134  fixedValueFvPatchScalarField(awfpsf),
135  Prt_(awfpsf.Prt_)
136 {}
137 
138 
141 (
144 )
145 :
146  fixedValueFvPatchScalarField(awfpsf, iF),
147  Prt_(awfpsf.Prt_)
148 {}
149 
150 
151 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 
154 {
155  if (updated())
156  {
157  return;
158  }
159 
160  const label patchi = patch().index();
161 
162  // Retrieve turbulence properties from model
163  const compressible::turbulenceModel& turbModel =
164  db().lookupObject<compressible::turbulenceModel>
165  (
167  (
168  compressible::turbulenceModel::propertiesName,
169  internalField().group()
170  )
171  );
172 
174  nutWallFunctionFvPatchScalarField::nutw(turbModel, patchi);
175 
176  const scalar Cmu25 = pow025(nutw.Cmu());
177 
178  const scalarField& y = turbModel.y()[patchi];
179 
180  const tmp<scalarField> tmuw = turbModel.mu(patchi);
181  const scalarField& muw = tmuw();
182 
183  const tmp<scalarField> talphaw = turbModel.alpha(patchi);
184  const scalarField& alphaw = talphaw();
185 
186  scalarField& alphatw = *this;
187 
188  const tmp<volScalarField> tk = turbModel.k();
189  const volScalarField& k = tk();
190 
191  const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi];
192  const scalarField magUp(mag(Uw.patchInternalField() - Uw));
193  const scalarField magGradUw(mag(Uw.snGrad()));
194 
195  const scalarField& rhow = turbModel.rho().boundaryField()[patchi];
196  const fvPatchScalarField& hew =
197  turbModel.transport().he().boundaryField()[patchi];
198 
199  // Heat flux [W/m^2] - lagging alphatw
200  const scalarField qDot
201  (
202  turbModel.transport().alphaEff(alphatw, patchi)*hew.snGrad()
203  );
204 
205  // Populate boundary values
206  forAll(alphatw, facei)
207  {
208  label celli = patch().faceCells()[facei];
209 
210  scalar uTau = Cmu25*sqrt(k[celli]);
211 
212  scalar yPlus = uTau*y[facei]/(muw[facei]/rhow[facei]);
213 
214  // Molecular Prandtl number
215  scalar Pr = muw[facei]/alphaw[facei];
216 
217  // Molecular-to-turbulent Prandtl number ratio
218  scalar Prat = Pr/Prt_;
219 
220  // Thermal sublayer thickness
221  scalar P = Psmooth(Prat);
222  scalar yPlusTherm = this->yPlusTherm(nutw, P, Prat);
223 
224  // Evaluate new effective thermal diffusivity
225  scalar alphaEff = 0.0;
226  if (yPlus < yPlusTherm)
227  {
228  const scalar A = qDot[facei]*rhow[facei]*uTau*y[facei];
229 
230  const scalar B = qDot[facei]*Pr*yPlus;
231 
232  const scalar C = Pr*0.5*rhow[facei]*uTau*sqr(magUp[facei]);
233 
234  alphaEff = A/(B + C + vSmall);
235  }
236  else
237  {
238  const scalar A = qDot[facei]*rhow[facei]*uTau*y[facei];
239 
240  const scalar B =
241  qDot[facei]*Prt_*(1.0/nutw.kappa()*log(nutw.E()*yPlus) + P);
242 
243  const scalar magUc =
244  uTau/nutw.kappa()*log(nutw.E()*yPlusTherm) - mag(Uw[facei]);
245 
246  const scalar C =
247  0.5*rhow[facei]*uTau
248  *(Prt_*sqr(magUp[facei]) + (Pr - Prt_)*sqr(magUc));
249 
250  alphaEff = A/(B + C + vSmall);
251  }
252 
253  // Update turbulent thermal diffusivity
254  alphatw[facei] = max(0.0, alphaEff - alphaw[facei]);
255 
256  if (debug)
257  {
258  Info<< " uTau = " << uTau << nl
259  << " Pr = " << Pr << nl
260  << " Prt = " << Prt_ << nl
261  << " qDot = " << qDot[facei] << nl
262  << " yPlus = " << yPlus << nl
263  << " yPlusTherm = " << yPlusTherm << nl
264  << " alphaEff = " << alphaEff << nl
265  << " alphaw = " << alphaw[facei] << nl
266  << " alphatw = " << alphatw[facei] << nl
267  << endl;
268  }
269  }
270 
272 }
273 
274 
276 {
278  writeEntry(os, "Prt", Prt_);
279  writeEntry(os, "value", *this);
280 }
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
286 (
289 );
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 } // End namespace compressible
294 } // End namespace Foam
295 
296 // ************************************************************************* //
const char *const group
Group name for atomic constants.
Graphite solid properties.
Definition: C.H:48
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:186
dimensionedScalar log(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
This boundary condition provides a thermal wall function for turbulent thermal diffusivity (usuallyal...
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
dimensionedScalar pow025(const dimensionedScalar &ds)
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
label k
Boltzmann constant.
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:280
Macros for easy insertion into run-time selection tables.
scalar magUp
virtual tmp< volScalarField > alphaEff() const
Effective thermal turbulent diffusivity of mixture [kg/m/s].
scalar uTau
alphatJayatillekeWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
scalar y
This boundary condition provides a turbulent kinematic viscosity condition when using wall functions...
dimensionedScalar exp(const dimensionedScalar &ds)
static word groupName(Name name, const word &group)
Foam::fvPatchFieldMapper.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:265
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:194
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label patchi
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
scalar yPlus
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:229
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
static const nutWallFunctionFvPatchScalarField & nutw(const turbulenceModel &turbModel, const label patchi)
Return the nut patchField for the given wall patch.
virtual tmp< volScalarField > alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
makePatchTypeField(fvPatchScalarField, thermalBaffleFvPatchScalarField)
Namespace for OpenFOAM.