Newer
Older
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
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
47
\\/ M anipulation |
-------------------------------------------------------------------------------
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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "nutRoughWallFunctionFvPatchScalarField.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
scalar nutRoughWallFunctionFvPatchScalarField::fnRough
(
const scalar KsPlus,
) const
{
// Return fn based on non-dimensional roughness height
if (KsPlus < 90.0)
{
return pow
(
(KsPlus - 2.25)/87.75 + Cs*KsPlus,
sin(0.4258*(log(KsPlus) - 0.811))
);
}
else
{
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutRoughWallFunctionFvPatchScalarField::
nutRoughWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Andrew Heather
committed
kName_("k"),
nuName_("nu"),
Ks_(p.size(), 0.0),
Cs_(p.size(), 0.0)
{}
nutRoughWallFunctionFvPatchScalarField::
nutRoughWallFunctionFvPatchScalarField
(
const nutRoughWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Andrew Heather
committed
kName_(ptf.kName_),
nuName_(ptf.nuName_),
Ks_(ptf.Ks_, mapper),
Cs_(ptf.Cs_, mapper)
{}
nutRoughWallFunctionFvPatchScalarField::
nutRoughWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Andrew Heather
committed
kName_(dict.lookupOrDefault<word>("k", "k")),
nuName_(dict.lookupOrDefault<word>("nu", "nu")),
Ks_("Ks", dict, p.size()),
Cs_("Cs", dict, p.size())
{}
nutRoughWallFunctionFvPatchScalarField::
nutRoughWallFunctionFvPatchScalarField
(
const nutRoughWallFunctionFvPatchScalarField& nrwfpsf
)
:
fixedValueFvPatchScalarField(nrwfpsf),
Andrew Heather
committed
kName_(nrwfpsf.kName_),
nuName_(nrwfpsf.nuName_),
Ks_(nrwfpsf.Ks_),
Cs_(nrwfpsf.Cs_)
{}
nutRoughWallFunctionFvPatchScalarField::
nutRoughWallFunctionFvPatchScalarField
(
const nutRoughWallFunctionFvPatchScalarField& nrwfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(nrwfpsf, iF),
Andrew Heather
committed
kName_(nrwfpsf.kName_),
nuName_(nrwfpsf.nuName_),
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
Ks_(nrwfpsf.Ks_),
Cs_(nrwfpsf.Cs_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void nutRoughWallFunctionFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchScalarField::autoMap(m);
Ks_.autoMap(m);
Cs_.autoMap(m);
}
void nutRoughWallFunctionFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
fixedValueFvPatchScalarField::rmap(ptf, addr);
const nutRoughWallFunctionFvPatchScalarField& nrwfpsf =
refCast<const nutRoughWallFunctionFvPatchScalarField>(ptf);
Cs_.rmap(nrwfpsf.Cs_, addr);
Ks_.rmap(nrwfpsf.Ks_, addr);
}
void nutRoughWallFunctionFvPatchScalarField::updateCoeffs()
{
const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
const scalar Cmu = ras.Cmu().value();
const scalar Cmu25 = pow(Cmu, 0.25);
const scalar kappa = ras.kappa().value();
const scalar E = ras.E().value();
const scalarField& y = ras.y()[patch().index()];
Andrew Heather
committed
const scalarField& k = db().lookupObject<volScalarField>(kName_);
const scalarField& nuw =
Andrew Heather
committed
patch().lookupPatchField<volScalarField, scalar>(nuName_);
scalarField& nutw = *this;
forAll(nutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uStar = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uStar*y[faceI]/nuw[faceI];
scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI];
scalar Edash = E;
if (KsPlus > 2.25)
{
Edash = E/fnRough(KsPlus, Cs_[faceI]);
}
if (yPlus > yPlusLam)
{
scalar limitingNutw = max(nutw[faceI], nuw[faceI]);
// To avoid oscillations limit the change in the wall viscosity
// which is particularly important if it temporarily becomes zero
nutw[faceI] =
max
(
min
(
nuw[faceI]
*(yPlus*kappa/log(max(Edash*yPlus, 1+1e-4)) - 1),
2*limitingNutw
), 0.5*limitingNutw
);
}
else
{
nutw[faceI] = 0.0;
}
if (debug)
{
Info<< "yPlus = " << yPlus
<< ", KsPlus = " << KsPlus
<< ", Edash = " << Edash
<< endl;
}
}
}
void nutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
Andrew Heather
committed
writeEntryIfDifferent<word>(os, "k", "k", kName_);
writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
Cs_.writeEntry("Cs", os);
Ks_.writeEntry("Ks", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, nutRoughWallFunctionFvPatchScalarField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //