Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 ENERCON GmbH
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "atmAlphatkWallFunctionFvPatchScalarField.H"
#include "turbulenceModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "wallFvPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
scalar atmAlphatkWallFunctionFvPatchScalarField::tolerance_ = 0.01;
label atmAlphatkWallFunctionFvPatchScalarField::maxIters_ = 10;
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void atmAlphatkWallFunctionFvPatchScalarField::checkType()
{
if (!isA<wallFvPatch>(patch()))
{
FatalErrorInFunction
<< "Invalid wall function specification" << nl
<< " Patch type for patch " << patch().name()
<< " must be wall" << nl
<< " Current patch type is " << patch().type() << nl << endl
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
atmAlphatkWallFunctionFvPatchScalarField::
atmAlphatkWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
Pr_(db().time(), "Pr"),
Prt_(nullptr),
z0_(nullptr)
{
checkType();
}
atmAlphatkWallFunctionFvPatchScalarField::
atmAlphatkWallFunctionFvPatchScalarField
(
const atmAlphatkWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
Pr_(ptf.Pr_),
Prt_(ptf.Prt_.clone(p.patch())),
z0_(ptf.z0_.clone(p.patch()))
{
checkType();
}
atmAlphatkWallFunctionFvPatchScalarField::
atmAlphatkWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Cmu_
(
dict.getCheckOrDefault<scalar>
(
"Cmu",
0.09,
scalarMinMax::ge(SMALL)
)
),
kappa_
(
dict.getCheckOrDefault<scalar>
(
"kappa",
0.41,
scalarMinMax::ge(SMALL)
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
)
),
Pr_(TimeFunction1<scalar>(db().time(), "Pr", dict)),
Prt_(PatchFunction1<scalar>::New(p.patch(), "Prt", dict)),
z0_(PatchFunction1<scalar>::New(p.patch(), "z0", dict))
{
checkType();
}
atmAlphatkWallFunctionFvPatchScalarField::
atmAlphatkWallFunctionFvPatchScalarField
(
const atmAlphatkWallFunctionFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
Pr_(wfpsf.Pr_),
Prt_(wfpsf.Prt_.clone(this->patch().patch())),
z0_(wfpsf.z0_.clone(this->patch().patch()))
{
checkType();
}
atmAlphatkWallFunctionFvPatchScalarField::
atmAlphatkWallFunctionFvPatchScalarField
(
const atmAlphatkWallFunctionFvPatchScalarField& wfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
Pr_(wfpsf.Pr_),
Prt_(wfpsf.Prt_.clone(this->patch().patch())),
z0_(wfpsf.z0_.clone(this->patch().patch()))
{
checkType();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void atmAlphatkWallFunctionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const label patchi = patch().index();
// Retrieve turbulence properties from model
const auto& turbModel =
db().lookupObject<turbulenceModel>
IOobject::groupName
(
turbulenceModel::propertiesName,
internalField().group()
)
);
const scalarField& y = turbModel.y()[patchi];
const tmp<scalarField> tnuw = turbModel.nu(patchi);
const scalarField& nuw = tnuw();
const tmp<volScalarField> tk = turbModel.k();
const volScalarField& k = tk();
const scalar Cmu25 = pow025(Cmu_);
const scalar t = db().time().timeOutputValue();
const scalar Pr = Pr_.value(t);
#ifdef FULLDEBUG
if (Pr < VSMALL)
{
FatalErrorInFunction
<< "Pr cannot be negative or zero. "
<< "Please check input Pr = " << Pr
<< exit(FatalError);
}
#endif
const scalarField Prt(Prt_->value(t));
const scalarField z0(z0_->value(t));
#ifdef FULLDEBUG
forAll(Prt, i)
{
if (Prt[i] < VSMALL || z0[i] < VSMALL)
{
FatalErrorInFunction
<< "Elements of input surface fields can only be positive. "
<< "Please check input fields z0 and Prt."
<< exit(FatalError);
}
}
#endif
const labelUList& faceCells = patch().faceCells();
scalarField& alphatw = *this;
forAll(alphatw, facei)
{
const label celli = faceCells[facei];
const scalar uStar = Cmu25*Foam::sqrt(k[celli]);
const scalar Edash = (y[facei] + z0[facei])/(z0[facei] + 1e-4);
// Update turbulent thermal conductivity
alphatw[facei] =
uStar*kappa_*y[facei]/(Prt[facei]*log(max(Edash, 1 + 1e-4)))
+ nuw[facei]/Pr;
}
// lower bound values to avoid unrealistic
// negative temperatures on the ground
alphatw = max(alphatw, scalar(0.01));
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
fixedValueFvPatchField<scalar>::updateCoeffs();
}
void atmAlphatkWallFunctionFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchScalarField::autoMap(m);
Prt_->autoMap(m);
z0_->autoMap(m);
}
void atmAlphatkWallFunctionFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
fixedValueFvPatchScalarField::rmap(ptf, addr);
const atmAlphatkWallFunctionFvPatchScalarField& nrwfpsf =
refCast<const atmAlphatkWallFunctionFvPatchScalarField>(ptf);
z0_->rmap(nrwfpsf.z0_(), addr);
Prt_->rmap(nrwfpsf.Prt_(), addr);
}
void atmAlphatkWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
os.writeEntry("Cmu", Cmu_);
os.writeEntry("kappa", kappa_);
Pr_.writeData(os);
Prt_->writeData(os);
z0_->writeData(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchScalarField,
atmAlphatkWallFunctionFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //