diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C index 87f0bb599fdc37005911dbc527abec99428c3f39..d49d91e5093b9d737e7faa6b8974507f97b94039 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C @@ -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); } diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H index 8674fa15640ced0987150f5dd9a5dbd48a31df0d..c1f72dfbe3d961ec67154a5a9444a7827095b29b 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H @@ -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 // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlusTemplates.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlusTemplates.C deleted file mode 100644 index 6577f516819a8b043e09eda9539e430f5ee6aba4..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlusTemplates.C +++ /dev/null @@ -1,127 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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; - } - } - } -} - - -// ************************************************************************* //