From fd734554b950eb55b59d065c05e29ef3d2d4e7c8 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 9 Jun 2016 16:06:09 +0100 Subject: [PATCH] functionObjects::yPlus: Rationalized the functionality in 'execute' and 'write' --- src/functionObjects/field/yPlus/yPlus.C | 90 +++++++++++-------------- 1 file changed, 40 insertions(+), 50 deletions(-) diff --git a/src/functionObjects/field/yPlus/yPlus.C b/src/functionObjects/field/yPlus/yPlus.C index e1e9249b52..503afa5d1d 100644 --- a/src/functionObjects/field/yPlus/yPlus.C +++ b/src/functionObjects/field/yPlus/yPlus.C @@ -82,8 +82,7 @@ void Foam::functionObjects::yPlus::calcYPlus const fvPatchList& patches = mesh.boundary(); - volScalarField::Boundary& yPlusBf = - yPlus.boundaryFieldRef(); + volScalarField::Boundary& yPlusBf = yPlus.boundaryFieldRef(); forAll(patches, patchi) { @@ -98,26 +97,6 @@ void Foam::functionObjects::yPlus::calcYPlus ); 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()) - { - 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; - } } else if (isA(patch)) { @@ -128,26 +107,6 @@ void Foam::functionObjects::yPlus::calcYPlus 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()) - { - 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; - } } } } @@ -182,7 +141,7 @@ Foam::functionObjects::yPlus::yPlus mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::AUTO_WRITE ), mesh, dimensionedScalar("0", dimless, 0.0) @@ -213,8 +172,6 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict) bool Foam::functionObjects::yPlus::execute(const bool postProcess) { - writeFiles::write(); - const fvMesh& mesh = refCast(obr_); volScalarField& yPlus = @@ -223,8 +180,6 @@ bool Foam::functionObjects::yPlus::execute(const bool postProcess) mesh.lookupObject(type()) ); - Log << type() << " " << name() << " output:" << nl; - if (mesh.foundObject(turbulenceModel::propertiesName)) { const turbulenceModel& model = @@ -245,15 +200,50 @@ bool Foam::functionObjects::yPlus::execute(const bool postProcess) bool Foam::functionObjects::yPlus::write(const bool postProcess) { - writeFiles::write(); - const volScalarField& yPlus = obr_.lookupObject(type()); - Log << " writing field " << yPlus.name() << endl; + Log << type() << " " << name() << " write:" << nl + << " writing field " << yPlus.name() << endl; yPlus.write(); + writeFiles::write(); + + const volScalarField::Boundary& yPlusBf = yPlus.boundaryField(); + + const fvMesh& mesh = refCast(obr_); + const fvPatchList& patches = mesh.boundary(); + + forAll(patches, patchi) + { + const fvPatch& patch = patches[patchi]; + + if (isA(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; }