mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
GIT: Initial state after latest Foundation merge
This commit is contained in:
206
src/functionObjects/field/yPlus/yPlus.C
Normal file
206
src/functionObjects/field/yPlus/yPlus.C
Normal file
@ -0,0 +1,206 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "turbulenceModel.H"
|
||||
#include "nutWallFunctionFvPatchScalarField.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(yPlus, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
yPlus,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::yPlus::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "y+ ()");
|
||||
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "patch");
|
||||
writeTabbed(os, "min");
|
||||
writeTabbed(os, "max");
|
||||
writeTabbed(os, "average");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::yPlus::yPlus
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name)
|
||||
{
|
||||
tmp<volScalarField> tyPlusPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
typeName,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
store(tyPlusPtr, typeName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::yPlus::~yPlus()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::yPlus::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
dict.readIfPresent("phi", phiName_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::yPlus::execute()
|
||||
{
|
||||
typedef compressible::turbulenceModel cmpTurbModel;
|
||||
typedef incompressible::turbulenceModel icoTurbModel;
|
||||
|
||||
volScalarField& yPlus =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh_.lookupObject<volScalarField>(resultName_)
|
||||
);
|
||||
|
||||
if (mesh.foundObject<cmpTurbModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
const cmpTurbModel& model =
|
||||
mesh.lookupObject<cmpTurbModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
calcYPlus(model, yPlus);
|
||||
}
|
||||
else if (mesh.foundObject<icoTurbModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
const icoTurbModel& model =
|
||||
mesh.lookupObject<icoTurbModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
calcYPlus(model, yPlus);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unable to find turbulence model in the "
|
||||
<< "database: yPlus will not be calculated" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::yPlus::write()
|
||||
{
|
||||
const volScalarField& yPlus =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
Log << type() << " " << name() << " write:" << nl
|
||||
<< " writing field " << yPlus.name() << endl;
|
||||
|
||||
yPlus.write();
|
||||
|
||||
writeFile::write();
|
||||
|
||||
const volScalarField::Boundary& yPlusBf = yPlus.boundaryField();
|
||||
const fvPatchList& patches = mesh_.boundary();
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const fvPatch& patch = patches[patchi];
|
||||
|
||||
if (isA<wallFvPatch>(patch))
|
||||
{
|
||||
const scalarField& yPlusp = yPlusBf[patchi];
|
||||
|
||||
const scalar minYplus = gMin(yPlusp);
|
||||
const scalar maxYplus = gMax(yPlusp);
|
||||
const scalar avgYplus = gAverage(yPlusp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Log << " 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user