Commit 3ba11a6e authored by Henry Weller's avatar Henry Weller
Browse files

functionObjects::yPlus: simplified, standardized, rationalized

parent eb79a51f
......@@ -24,9 +24,9 @@ License
\*---------------------------------------------------------------------------*/
#include "yPlus.H"
#include "volFields.H"
#include "turbulentTransportModel.H"
#include "turbulentFluidThermoModel.H"
#include "turbulenceModel.H"
#include "nutWallFunctionFvPatchScalarField.H"
#include "wallFvPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -62,6 +62,99 @@ void Foam::functionObjects::yPlus::writeFileHeader(const label i)
}
void Foam::functionObjects::yPlus::calcYPlus
(
const turbulenceModel& turbModel,
const fvMesh& mesh,
volScalarField& yPlus
)
{
volScalarField::Boundary d = nearWallDist(mesh).y();
const volScalarField::Boundary nutBf =
turbModel.nut()().boundaryField();
const volScalarField::Boundary nuEffBf =
turbModel.nuEff()().boundaryField();
const volScalarField::Boundary nuBf =
turbModel.nu()().boundaryField();
const fvPatchList& patches = mesh.boundary();
volScalarField::Boundary& yPlusBf =
yPlus.boundaryFieldRef();
forAll(patches, patchi)
{
const fvPatch& patch = patches[patchi];
if (isA<nutWallFunctionFvPatchScalarField>(nutBf[patchi]))
{
const nutWallFunctionFvPatchScalarField& nutPf =
dynamic_cast<const nutWallFunctionFvPatchScalarField&>
(
nutBf[patchi]
);
yPlusBf[patchi] = nutPf.yPlus();
const scalarField& yPlusp = yPlusBf[patchi];
const scalar minYplus = gMin(yPlusp);
const scalar maxYplus = gMax(yPlusp);
const scalar avgYplus = gAverage(yPlusp);
if (Pstream::master())
{
if (log_) Info
<< " patch " << patch.name()
<< " y+ : min = " << minYplus << ", max = " << maxYplus
<< ", average = " << avgYplus << nl;
writeTime(file());
file()
<< token::TAB << patch.name()
<< token::TAB << minYplus
<< token::TAB << maxYplus
<< token::TAB << avgYplus
<< endl;
}
}
else if (isA<wallFvPatch>(patch))
{
yPlusBf[patchi] =
d[patchi]
*sqrt
(
nuEffBf[patchi]
*mag(turbModel.U().boundaryField()[patchi].snGrad())
)/nuBf[patchi];
const scalarField& yPlusp = yPlusBf[patchi];
const scalar minYplus = gMin(yPlusp);
const scalar maxYplus = gMax(yPlusp);
const scalar avgYplus = gAverage(yPlusp);
if (Pstream::master())
{
if (log_) Info
<< " patch " << patch.name()
<< " y+ : min = " << minYplus << ", max = " << maxYplus
<< ", average = " << avgYplus << nl;
writeTime(file());
file()
<< token::TAB << patch.name()
<< token::TAB << minYplus
<< token::TAB << maxYplus
<< token::TAB << avgYplus
<< endl;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::yPlus::yPlus
......@@ -124,9 +217,6 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict)
bool Foam::functionObjects::yPlus::execute(const bool postProcess)
{
typedef compressible::turbulenceModel cmpModel;
typedef incompressible::turbulenceModel icoModel;
writeFiles::write();
const fvMesh& mesh = refCast<const fvMesh>(obr_);
......@@ -139,18 +229,10 @@ bool Foam::functionObjects::yPlus::execute(const bool postProcess)
if (log_) Info<< type() << " " << name() << " output:" << nl;
tmp<volSymmTensorField> Reff;
if (mesh.foundObject<cmpModel>(turbulenceModel::propertiesName))
{
const cmpModel& model =
mesh.lookupObject<cmpModel>(turbulenceModel::propertiesName);
calcYPlus(model, mesh, yPlus);
}
else if (mesh.foundObject<icoModel>(turbulenceModel::propertiesName))
if (mesh.foundObject<turbulenceModel>(turbulenceModel::propertiesName))
{
const icoModel& model =
mesh.lookupObject<icoModel>(turbulenceModel::propertiesName);
const turbulenceModel& model =
mesh.lookupObject<turbulenceModel>(turbulenceModel::propertiesName);
calcYPlus(model, mesh, yPlus);
}
......
......@@ -55,6 +55,7 @@ namespace Foam
// Forward declaration of classes
class objectRegistry;
class fvMesh;
class turbulenceModel;
namespace functionObjects
{
......@@ -79,10 +80,9 @@ class yPlus
virtual void writeFileHeader(const label i);
//- Calculate y+
template<class TurbulenceModel>
void calcYPlus
(
const TurbulenceModel& turbulenceModel,
const turbulenceModel& turbModel,
const fvMesh& mesh,
volScalarField& yPlus
);
......@@ -135,12 +135,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "yPlusTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 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 "yPlus.H"
#include "nutWallFunctionFvPatchScalarField.H"
#include "nearWallDist.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class TurbulenceModel>
void Foam::functionObjects::yPlus::calcYPlus
(
const TurbulenceModel& turbulenceModel,
const fvMesh& mesh,
volScalarField& yPlus
)
{
volScalarField::Boundary d = nearWallDist(mesh).y();
const volScalarField::Boundary nutBf =
turbulenceModel.nut()().boundaryField();
const volScalarField::Boundary nuEffBf =
turbulenceModel.nuEff()().boundaryField();
const volScalarField::Boundary nuBf =
turbulenceModel.nu()().boundaryField();
const fvPatchList& patches = mesh.boundary();
volScalarField::Boundary& yPlusBf =
yPlus.boundaryFieldRef();
forAll(patches, patchi)
{
const fvPatch& patch = patches[patchi];
if (isA<nutWallFunctionFvPatchScalarField>(nutBf[patchi]))
{
const nutWallFunctionFvPatchScalarField& nutPf =
dynamic_cast<const nutWallFunctionFvPatchScalarField&>
(
nutBf[patchi]
);
yPlusBf[patchi] = nutPf.yPlus();
const scalarField& yPlusp = yPlusBf[patchi];
const scalar minYplus = gMin(yPlusp);
const scalar maxYplus = gMax(yPlusp);
const scalar avgYplus = gAverage(yPlusp);
if (Pstream::master())
{
if (log_) Info
<< " patch " << patch.name()
<< " y+ : min = " << minYplus << ", max = " << maxYplus
<< ", average = " << avgYplus << nl;
writeTime(file());
file()
<< token::TAB << patch.name()
<< token::TAB << minYplus
<< token::TAB << maxYplus
<< token::TAB << avgYplus
<< endl;
}
}
else if (isA<wallFvPatch>(patch))
{
yPlusBf[patchi] =
d[patchi]
*sqrt
(
nuEffBf[patchi]
*mag(turbulenceModel.U().boundaryField()[patchi].snGrad())
)/nuBf[patchi];
const scalarField& yPlusp = yPlusBf[patchi];
const scalar minYplus = gMin(yPlusp);
const scalar maxYplus = gMax(yPlusp);
const scalar avgYplus = gAverage(yPlusp);
if (Pstream::master())
{
if (log_) Info
<< " patch " << patch.name()
<< " y+ : min = " << minYplus << ", max = " << maxYplus
<< ", average = " << avgYplus << nl;
writeTime(file());
file()
<< token::TAB << patch.name()
<< token::TAB << minYplus
<< token::TAB << maxYplus
<< token::TAB << avgYplus
<< endl;
}
}
}
}
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment