Skip to content
Snippets Groups Projects
Commit 2f6d77d5 authored by Henry's avatar Henry
Browse files

Combine yPlusRAS and yPlusLES into the single utility yPlus

which provides y+ values for the near-wall cells for laminar, LES and RAS
parent 78ca0ce0
No related branches found
No related tags found
No related merge requests found
yPlus.C
EXE = $(FOAM_APPBIN)/yPlus
......@@ -22,14 +22,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
yPlusRAS
yPlus
Description
Calculates and reports yPlus for all wall patches, for the specified times
when using RAS turbulence models.
Calculates and reports yPlus for the near-wall cells of all wall patches,
for the specified times for laminar, LES and RAS.
For walls at which wall-functions are applied the wall-function provides
the y+ values otherwise they are obtained directly from the near-wall
velocity gradient and effective and laminar viscosities.
Default behaviour assumes operating in incompressible mode.
Use the -compressible option for compressible RAS cases.
Use the -compressible option for compressible cases.
\*---------------------------------------------------------------------------*/
......@@ -38,57 +42,93 @@ Description
#include "turbulentTransportModel.H"
#include "turbulentFluidThermoModel.H"
#include "nutWallFunctionFvPatchScalarField.H"
#include "nearWallDist.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void calcIncompressibleYPlus
template<class TurbulenceModel>
void calcYPlus
(
const TurbulenceModel& turbulenceModel,
const fvMesh& mesh,
const Time& runTime,
const volVectorField& U,
volScalarField& yPlus
)
{
typedef nutWallFunctionFvPatchScalarField wallFunctionPatchField;
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
#include "createPhi.H"
const volScalarField::GeometricBoundaryField nutBf =
turbulenceModel->nut()().boundaryField();
singlePhaseTransportModel laminarTransport(U, phi);
const volScalarField::GeometricBoundaryField nuEffBf =
turbulenceModel->nuEff()().boundaryField();
autoPtr<incompressible::RASModel> RASModel
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
const volScalarField::GeometricBoundaryField nuBf =
turbulenceModel->nu()().boundaryField();
const volScalarField::GeometricBoundaryField nutPatches =
RASModel->nut()().boundaryField();
const fvPatchList& patches = mesh.boundary();
bool foundNutPatch = false;
forAll(nutPatches, patchi)
forAll(patches, patchi)
{
if (isA<wallFunctionPatchField>(nutPatches[patchi]))
const fvPatch& patch = patches[patchi];
if (isA<nutWallFunctionFvPatchScalarField>(nutBf[patchi]))
{
foundNutPatch = true;
const nutWallFunctionFvPatchScalarField& nutPf =
dynamic_cast<const nutWallFunctionFvPatchScalarField&>
(
nutBf[patchi]
);
const wallFunctionPatchField& nutPw =
dynamic_cast<const wallFunctionPatchField&>
(nutPatches[patchi]);
yPlus.boundaryField()[patchi] = nutPf.yPlus();
const scalarField& Yp = yPlus.boundaryField()[patchi];
yPlus.boundaryField()[patchi] = nutPw.yPlus();
Info<< "Patch " << patchi
<< " named " << nutPf.patch().name()
<< ", wall-function " << nutPf.type()
<< ", y+ : min: " << gMin(Yp) << " max: " << gMax(Yp)
<< " average: " << gAverage(Yp) << nl << endl;
}
else if (isA<wallFvPatch>(patch))
{
yPlus.boundaryField()[patchi] =
d[patchi]
*sqrt
(
nuEffBf[patchi]
*mag(U.boundaryField()[patchi].snGrad())
)/nuBf[patchi];
const scalarField& Yp = yPlus.boundaryField()[patchi];
Info<< "Patch " << patchi
<< " named " << nutPw.patch().name()
<< " named " << patch.name()
<< " y+ : min: " << gMin(Yp) << " max: " << gMax(Yp)
<< " average: " << gAverage(Yp) << nl << endl;
}
}
}
if (!foundNutPatch)
{
Info<< " no " << wallFunctionPatchField::typeName << " patches"
<< endl;
}
void calcIncompressibleYPlus
(
const fvMesh& mesh,
const Time& runTime,
const volVectorField& U,
volScalarField& yPlus
)
{
#include "createPhi.H"
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::turbulenceModel> turbulenceModel
(
incompressible::turbulenceModel::New(U, phi, laminarTransport)
);
calcYPlus(turbulenceModel, mesh, runTime, U, yPlus);
}
......@@ -100,8 +140,6 @@ void calcCompressibleYPlus
volScalarField& yPlus
)
{
typedef nutWallFunctionFvPatchScalarField wallFunctionPatchField;
IOobject rhoHeader
(
"rho",
......@@ -122,15 +160,12 @@ void calcCompressibleYPlus
#include "compressibleCreatePhi.H"
autoPtr<fluidThermo> pThermo
(
fluidThermo::New(mesh)
);
autoPtr<fluidThermo> pThermo(fluidThermo::New(mesh));
fluidThermo& thermo = pThermo();
autoPtr<compressible::RASModel> RASModel
autoPtr<compressible::turbulenceModel> turbulenceModel
(
compressible::RASModel::New
compressible::turbulenceModel::New
(
rho,
U,
......@@ -139,35 +174,7 @@ void calcCompressibleYPlus
)
);
const volScalarField::GeometricBoundaryField nutPatches =
RASModel->nut()().boundaryField();
bool foundNutPatch = false;
forAll(nutPatches, patchi)
{
if (isA<wallFunctionPatchField>(nutPatches[patchi]))
{
foundNutPatch = true;
const wallFunctionPatchField& nutPw =
dynamic_cast<const wallFunctionPatchField&>
(nutPatches[patchi]);
yPlus.boundaryField()[patchi] = nutPw.yPlus();
const scalarField& Yp = yPlus.boundaryField()[patchi];
Info<< "Patch " << patchi
<< " named " << nutPw.patch().name()
<< " y+ : min: " << gMin(Yp) << " max: " << gMax(Yp)
<< " average: " << gAverage(Yp) << nl << endl;
}
}
if (!foundNutPatch)
{
Info<< " no " << wallFunctionPatchField::typeName << " patches"
<< endl;
}
calcYPlus(turbulenceModel, mesh, runTime, U, yPlus);
}
......
yPlusLES.C
EXE = $(FOAM_APPBIN)/yPlusLES
EXE_INC = \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-lincompressibleTransportModels \
-lfiniteVolume \
-lgenericPatchFields
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);
#include "createPhi.H"
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::LESModel> sgsModel
(
incompressible::LESModel::New(U, phi, laminarTransport)
);
volScalarField::GeometricBoundaryField d(nearWallDist(mesh).y());
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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/>.
Application
yPlusLES
Description
Calculates and reports yPlus for all wall patches, for the specified times
when using LES turbulence models.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "turbulentTransportModel.H"
#include "nutWallFunctionFvPatchScalarField.H"
#include "nearWallDist.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
timeSelector::addOptions();
#include "setRootCase.H"
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createMesh.H"
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate();
volScalarField yPlus
(
IOobject
(
"yPlus",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("yPlus", dimless, 0.0)
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);
#include "createPhi.H"
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::LESModel> sgsModel
(
incompressible::LESModel::New(U, phi, laminarTransport)
);
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
volScalarField nuEff(sgsModel->nuEff());
const fvPatchList& patches = mesh.boundary();
const volScalarField nuLam(sgsModel->nu());
forAll(patches, patchi)
{
const fvPatch& currPatch = patches[patchi];
if (isA<wallFvPatch>(currPatch))
{
yPlus.boundaryField()[patchi] =
d[patchi]
*sqrt
(
nuEff.boundaryField()[patchi]
*mag(U.boundaryField()[patchi].snGrad())
)
/nuLam.boundaryField()[patchi];
const scalarField& Yp = yPlus.boundaryField()[patchi];
Info<< "Patch " << patchi
<< " named " << currPatch.name()
<< " y+ : min: " << gMin(Yp) << " max: " << gMax(Yp)
<< " average: " << gAverage(Yp) << nl << endl;
}
}
Info<< "Writing yPlus to field "
<< yPlus.name() << nl << endl;
yPlus.write();
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
yPlusRAS.C
EXE = $(FOAM_APPBIN)/yPlusRAS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment