Newer
Older
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\/ 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 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 "yPlusLES.H"
#include "volFields.H"
#include "incompressible/LES/LESModel/LESModel.H"
#include "compressible/LES/LESModel/LESModel.H"
#include "wallFvPatch.H"
#include "nearWallDist.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(yPlusLES, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::yPlusLES::writeFileHeader(const label i)
file() << "# y+ (LES)" << nl
<< "# time " << token::TAB << "patch" << token::TAB
<< "min" << token::TAB << "max" << token::TAB << "average"
<< endl;
void Foam::yPlusLES::calcIncompressibleYPlus
(
const fvMesh& mesh,
const volVectorField& U,
volScalarField& yPlus
{
const incompressible::LESModel& model =
mesh.lookupObject<incompressible::LESModel>("LESProperties");
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
volScalarField nuEff(model.nuEff());
const fvPatchList& patches = mesh.boundary();
const volScalarField nuLam(model.nu());
bool foundPatch = false;
forAll(patches, patchI)
{
const fvPatch& currPatch = patches[patchI];
if (isA<wallFvPatch>(currPatch))
{
foundPatch = true;
yPlus.boundaryField()[patchI] =
d[patchI]
*sqrt
(
nuEff.boundaryField()[patchI]
*mag(U.boundaryField()[patchI].snGrad())
)
/nuLam.boundaryField()[patchI];
const scalarField& Yp = yPlus.boundaryField()[patchI];
scalar minYp = gMin(Yp);
scalar maxYp = gMax(Yp);
scalar avgYp = gAverage(Yp);
if (log_)
{
Info<< " patch " << currPatch.name()
<< " y+ : min = " << minYp << ", max = " << maxYp
<< ", average = " << avgYp << nl;
}
if (Pstream::master())
{
file() << obr_.time().value() << token::TAB
<< currPatch.name() << token::TAB
<< minYp << token::TAB << maxYp << token::TAB
<< avgYp << endl;
}
if (log_ && !foundPatch)
{
Info<< " no " << wallFvPatch::typeName << " patches" << endl;
}
}
void Foam::yPlusLES::calcCompressibleYPlus
(
const fvMesh& mesh,
const volVectorField& U,
volScalarField& yPlus
124
125
126
127
128
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
{
const compressible::LESModel& model =
mesh.lookupObject<compressible::LESModel>("LESProperties");
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
volScalarField muEff(model.muEff());
const fvPatchList& patches = mesh.boundary();
const volScalarField muLam(model.mu());
Info<< type() << " output:" << nl;
bool foundPatch = false;
forAll(patches, patchI)
{
const fvPatch& currPatch = patches[patchI];
if (isA<wallFvPatch>(currPatch))
{
foundPatch = true;
yPlus.boundaryField()[patchI] =
d[patchI]
*sqrt
(
muEff.boundaryField()[patchI]
*mag(U.boundaryField()[patchI].snGrad())
)
/muLam.boundaryField()[patchI];
const scalarField& Yp = yPlus.boundaryField()[patchI];
scalar minYp = gMin(Yp);
scalar maxYp = gMax(Yp);
scalar avgYp = gAverage(Yp);
if (log_)
{
Info<< " patch " << currPatch.name()
<< " y+ : min = " << minYp << ", max = " << maxYp
<< ", average = " << avgYp << nl;
}
if (Pstream::master())
{
file() << obr_.time().value() << token::TAB
<< currPatch.name() << token::TAB
<< minYp << token::TAB << maxYp << token::TAB
<< avgYp << endl;
}
}
if (log_ && !foundPatch)
{
Info<< " no " << wallFvPatch::typeName << " patches" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::yPlusLES::yPlusLES
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
functionObjectFile(obr, name, typeName),
name_(name),
obr_(obr),
active_(true),
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
{
// Check if the available mesh is an fvMesh, otherwise deactivate
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"yPlusLES::yPlusLES"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "No fvMesh available, deactivating." << nl
<< endl;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::yPlusLES::~yPlusLES()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::yPlusLES::read(const dictionary& dict)
{
if (active_)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
}
}
void Foam::yPlusLES::execute()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::end()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::timeSet()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::write()
{
if (active_)
{
functionObjectFile::write();
const surfaceScalarField& phi =
obr_.lookupObject<surfaceScalarField>(phiName_);
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField yPlusLES
(
IOobject
(
"yPlusLES",
mesh.time().timeName(),
mesh,
IOobject::NO_READ
),
mesh,
dimensionedScalar("0", dimless, 0.0)
);
Info<< type() << " " << name_ << " output:" << nl;
if (phi.dimensions() == dimMass/dimTime)
{
calcCompressibleYPlus(mesh, U, yPlusLES);
}
else
{
calcIncompressibleYPlus(mesh, U, yPlusLES);
}
Info<< " writing field " << yPlusLES.name() << nl
<< endl;