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 "mutRoughWallFunctionFvPatchScalarField.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace compressible
{
namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
scalar mutRoughWallFunctionFvPatchScalarField::fnRough
(
const scalar KsPlus,
) const
{
if (KsPlus < 90.0)
{
return pow
(
(KsPlus - 2.25)/87.75 + Cs*KsPlus,
sin(0.4258*(log(KsPlus) - 0.811))
);
}
else
{
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutRoughWallFunctionFvPatchScalarField::
mutRoughWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Andrew Heather
committed
rhoName_("rho"),
muName_("mu"),
kName_("k"),
Ks_(p.size(), 0.0),
Cs_(p.size(), 0.0)
{}
mutRoughWallFunctionFvPatchScalarField::
mutRoughWallFunctionFvPatchScalarField
(
const mutRoughWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Andrew Heather
committed
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
kName_(ptf.kName_),
Ks_(ptf.Ks_, mapper),
Cs_(ptf.Cs_, mapper)
{}
mutRoughWallFunctionFvPatchScalarField::
mutRoughWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Andrew Heather
committed
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
kName_(dict.lookupOrDefault<word>("k", "k")),
Ks_("Ks", dict, p.size()),
Cs_("Cs", dict, p.size())
{}
mutRoughWallFunctionFvPatchScalarField::
mutRoughWallFunctionFvPatchScalarField
(
Andrew Heather
committed
const mutRoughWallFunctionFvPatchScalarField& rwfpsf
)
:
Andrew Heather
committed
fixedValueFvPatchScalarField(rwfpsf),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kName_(rwfpsf.kName_),
Ks_(rwfpsf.Ks_),
Cs_(rwfpsf.Cs_)
{}
mutRoughWallFunctionFvPatchScalarField::
mutRoughWallFunctionFvPatchScalarField
(
Andrew Heather
committed
const mutRoughWallFunctionFvPatchScalarField& rwfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
Andrew Heather
committed
fixedValueFvPatchScalarField(rwfpsf, iF),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kName_(rwfpsf.kName_),
Ks_(rwfpsf.Ks_),
Cs_(rwfpsf.Cs_)
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
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mutRoughWallFunctionFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchScalarField::autoMap(m);
Ks_.autoMap(m);
Cs_.autoMap(m);
}
void mutRoughWallFunctionFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
fixedValueFvPatchScalarField::rmap(ptf, addr);
const mutRoughWallFunctionFvPatchScalarField& nrwfpsf =
refCast<const mutRoughWallFunctionFvPatchScalarField>(ptf);
Cs_.rmap(nrwfpsf.Cs_, addr);
Ks_.rmap(nrwfpsf.Ks_, addr);
}
void mutRoughWallFunctionFvPatchScalarField::updateCoeffs()
{
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar Cmu = rasModel.Cmu().value();
const scalar Cmu25 = pow(Cmu, 0.25);
const scalar kappa = rasModel.kappa().value();
const scalar E = rasModel.E().value();
scalar yPlusLam = rasModel.yPlusLam();
const scalarField& y = rasModel.y()[patch().index()];
const scalarField& rhow =
Andrew Heather
committed
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
Andrew Heather
committed
const scalarField& k = db().lookupObject<volScalarField>(kName_);
const scalarField& muw =
Andrew Heather
committed
patch().lookupPatchField<volScalarField, scalar>(muName_);
scalarField& mutw = *this;
forAll(mutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uStar = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]);
scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]);
scalar Edash = E;
scalar yPlusLamNew = yPlusLam;
if (KsPlus > 2.25)
{
Edash = E/fnRough(KsPlus, Cs_[faceI]);
yPlusLamNew = rasModel.yPlusLam(kappa, Edash);
}
if (debug)
{
Info<< "yPlus = " << yPlus
<< ", KsPlus = " << KsPlus
<< ", Edash = " << Edash
<< ", yPlusLam = " << yPlusLam
<< endl;
}
if (yPlus > yPlusLamNew)
{
mutw[faceI] =
muw[faceI]
*(yPlus*kappa/log(max(Edash*yPlus, 1+1e-4)) - 1);
}
else
{
mutw[faceI] = 0.0;
}
}
}
void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
Andrew Heather
committed
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
writeEntryIfDifferent<word>(os, "k", "k", kName_);
Cs_.writeEntry("Cs", os);
Ks_.writeEntry("Ks", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, mutRoughWallFunctionFvPatchScalarField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace compressible
} // End namespace Foam
// ************************************************************************* //