alphatJayatillekeWallFunctionFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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 
27 #include "turbulenceModel.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "wallFvPatch.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace incompressible
38 {
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 scalar alphatJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01;
43 label alphatJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10;
44 
45 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
46 
48 {
49  if (!isA<wallFvPatch>(patch()))
50  {
52  << "Invalid wall function specification" << nl
53  << " Patch type for patch " << patch().name()
54  << " must be wall" << nl
55  << " Current patch type is " << patch().type() << nl << endl
56  << abort(FatalError);
57  }
58 }
59 
60 
62 (
63  const scalar Prat
64 ) const
65 {
66  return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat));
67 }
68 
69 
71 (
72  const scalar P,
73  const scalar Prat
74 ) const
75 {
76  scalar ypt = 11.0;
77 
78  for (int i=0; i<maxIters_; i++)
79  {
80  scalar f = ypt - (log(E_*ypt)/kappa_ + P)/Prat;
81  scalar df = 1.0 - 1.0/(ypt*kappa_*Prat);
82  scalar yptNew = ypt - f/df;
83 
84  if (yptNew < VSMALL)
85  {
86  return 0;
87  }
88  else if (mag(yptNew - ypt) < tolerance_)
89  {
90  return yptNew;
91  }
92  else
93  {
94  ypt = yptNew;
95  }
96  }
97 
98  return ypt;
99 }
100 
101 
102 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
103 
106 (
107  const fvPatch& p,
109 )
110 :
111  fixedValueFvPatchScalarField(p, iF),
112  Prt_(0.85),
113  Cmu_(0.09),
114  kappa_(0.41),
115  E_(9.8)
116 {
117  checkType();
118 }
119 
120 
123 (
125  const fvPatch& p,
127  const fvPatchFieldMapper& mapper
128 )
129 :
130  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
131  Prt_(ptf.Prt_),
132  Cmu_(ptf.Cmu_),
133  kappa_(ptf.kappa_),
134  E_(ptf.E_)
135 {
136  checkType();
137 }
138 
139 
142 (
143  const fvPatch& p,
145  const dictionary& dict
146 )
147 :
148  fixedValueFvPatchScalarField(p, iF, dict),
149  Prt_(readScalar(dict.lookup("Prt"))), // force read to avoid ambiguity
150  Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
151  kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
152  E_(dict.lookupOrDefault<scalar>("E", 9.8))
153 {
154  checkType();
155 }
156 
157 
160 (
162 )
163 :
164  fixedValueFvPatchScalarField(wfpsf),
165  Prt_(wfpsf.Prt_),
166  Cmu_(wfpsf.Cmu_),
167  kappa_(wfpsf.kappa_),
168  E_(wfpsf.E_)
169 {
170  checkType();
171 }
172 
173 
176 (
179 )
180 :
181  fixedValueFvPatchScalarField(wfpsf, iF),
182  Prt_(wfpsf.Prt_),
183  Cmu_(wfpsf.Cmu_),
184  kappa_(wfpsf.kappa_),
185  E_(wfpsf.E_)
186 {
187  checkType();
188 }
189 
190 
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
192 
194 {
195  if (updated())
196  {
197  return;
198  }
199 
200  const label patchi = patch().index();
201 
202  // Retrieve turbulence properties from model
203 
204  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
205  (
207  (
209  internalField().group()
210  )
211  );
212 
213  const scalar Cmu25 = pow(Cmu_, 0.25);
214  const scalarField& y = turbModel.y()[patchi];
215  const tmp<volScalarField> tnu = turbModel.nu();
216  const volScalarField& nu = tnu();
217  const scalarField& nuw = nu.boundaryField()[patchi];
218  const tmp<volScalarField> tk = turbModel.k();
219  const volScalarField& k = tk();
220 
221  const IOdictionary& transportProperties =
222  db().lookupObject<IOdictionary>("transportProperties");
223 
224  // Molecular Prandtl number
225  const scalar Pr
226  (
228  (
229  "Pr",
230  dimless,
231  transportProperties.lookup("Pr")
232  ).value()
233  );
234 
235  // Populate boundary values
236  scalarField& alphatw = *this;
237  forAll(alphatw, facei)
238  {
239  label faceCelli = patch().faceCells()[facei];
240 
241  // y+
242  scalar yPlus = Cmu25*sqrt(k[faceCelli])*y[facei]/nuw[facei];
243 
244  // Molecular-to-turbulent Prandtl number ratio
245  scalar Prat = Pr/Prt_;
246 
247  // Thermal sublayer thickness
248  scalar P = Psmooth(Prat);
249  scalar yPlusTherm = this->yPlusTherm(P, Prat);
250 
251  // Update turbulent thermal conductivity
252  if (yPlus > yPlusTherm)
253  {
254  scalar nu = nuw[facei];
255  scalar kt = nu*(yPlus/(Prt_*(log(E_*yPlus)/kappa_ + P)) - 1/Pr);
256  alphatw[facei] = max(0.0, kt);
257  }
258  else
259  {
260  alphatw[facei] = 0.0;
261  }
262  }
263 
265 }
266 
267 
269 {
271  os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
272  os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
273  os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
274  os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
275  writeEntry("value", os);
276 }
277 
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
282 (
285 );
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 } // End namespace incompressible
290 } // End namespace Foam
291 
292 // ************************************************************************* //
const char *const group
Group name for atomic constants.
dimensionedScalar Pr("Pr", dimless, laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
dimensionedScalar log(const dimensionedScalar &ds)
tmp< volScalarField > nu() const
Return the laminar viscosity.
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
alphatJayatillekeWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
label k
Boltzmann constant.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Macros for easy insertion into run-time selection tables.
virtual tmp< volScalarField > k() const =0
Return the turbulence kinetic energy.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Templated abstract base class for single-phase incompressible turbulence models.
scalar y
dimensionedScalar exp(const dimensionedScalar &ds)
const Boundary & boundaryField() const
Return const-reference to the boundary field.
static const word propertiesName
Default name of the turbulence properties dictionary.
static word groupName(Name name, const word &group)
This boundary condition provides a kinematic turbulent thermal conductivity for using wall functions...
Foam::fvPatchFieldMapper.
makePatchTypeField(fvPatchScalarField, alphatJayatillekeWallFunctionFvPatchScalarField)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
errorManip< error > abort(error &err)
Definition: errorManip.H:131
scalar yPlusTherm(const scalar P, const scalar Prat) const
Calculate y+ at the edge of the thermal laminar sublayer.
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:262
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
labelList f(nPoints)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label patchi
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
scalar yPlus
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:312
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensioned< scalar > mag(const dimensioned< Type > &)
A class for managing temporary objects.
Definition: PtrList.H:54
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
volScalarField & nu
const nearWallDist & y() const
Return the near wall distances.
Namespace for OpenFOAM.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:363
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451