From 8f68a493e8bac1f111fb5377bf85481534c61063 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Sat, 21 May 2016 23:12:12 +0100 Subject: [PATCH] functionObjects: Cleanup, reorganize and simplify --- .../fvMeshFunctionObject.H | 2 +- .../fvMeshFunctionObjectTemplates.C | 2 +- .../field/CourantNo/CourantNo.C | 112 +++++----- .../field/CourantNo/CourantNo.H | 14 +- .../functionObjects/field/Lambda2/Lambda2.C | 84 ++------ .../functionObjects/field/Lambda2/Lambda2.H | 28 +-- .../functionObjects/field/Make/files | 1 + .../functionObjects/field/Make/options | 3 +- .../functionObjects/field/Peclet/Peclet.C | 115 ++++++++++ .../{utilities => field}/Peclet/Peclet.H | 21 +- .../functionObjects/field/Q/Q.H | 2 +- .../field/vorticity/vorticity.C | 72 ++----- .../field/vorticity/vorticity.H | 29 +-- .../functionObjects/utilities/Make/files | 1 - .../functionObjects/utilities/Peclet/Peclet.C | 202 ------------------ 15 files changed, 227 insertions(+), 461 deletions(-) create mode 100644 src/postProcessing/functionObjects/field/Peclet/Peclet.C rename src/postProcessing/functionObjects/{utilities => field}/Peclet/Peclet.H (85%) delete mode 100644 src/postProcessing/functionObjects/utilities/Peclet/Peclet.C diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H index b090c7c4b5c..bf89a2646d6 100644 --- a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H +++ b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H @@ -88,7 +88,7 @@ protected: bool store ( word& fieldName, - tmp<FieldType> tfield, + const tmp<FieldType>& tfield, bool cacheable = false ); diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C index 2a466a789b3..48b680620e4 100644 --- a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C +++ b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C @@ -52,7 +52,7 @@ template<class FieldType> bool Foam::functionObjects::fvMeshFunctionObject::store ( word& fieldName, - tmp<FieldType> tfield, + const tmp<FieldType>& tfield, bool cacheable ) { diff --git a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C index 40fa5ca004b..736fdece672 100644 --- a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C +++ b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C @@ -75,29 +75,9 @@ Foam::functionObjects::CourantNo::CourantNo const dictionary& dict ) : - fvMeshFunctionObject(name, runTime, dict) + fieldExpression(name, runTime, dict, "phi", "Co") { read(dict); - - volScalarField* CourantNoPtr - ( - new volScalarField - ( - IOobject - ( - type(), - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("0", dimless, 0.0), - zeroGradientFvPatchScalarField::typeName - ) - ); - - mesh_.objectRegistry::store(CourantNoPtr); } @@ -111,6 +91,8 @@ Foam::functionObjects::CourantNo::~CourantNo() bool Foam::functionObjects::CourantNo::read(const dictionary& dict) { + fieldExpression::read(dict); + phiName_ = dict.lookupOrDefault<word>("phi", "phi"); rhoName_ = dict.lookupOrDefault<word>("rho", "rho"); @@ -120,38 +102,64 @@ bool Foam::functionObjects::CourantNo::read(const dictionary& dict) bool Foam::functionObjects::CourantNo::execute(const bool postProcess) { - const surfaceScalarField& phi = - mesh_.lookupObject<surfaceScalarField>(phiName_); - - volScalarField& Co = const_cast<volScalarField&> - ( - mesh_.lookupObject<volScalarField>(type()) - ); - - Co.ref() = byRho - ( - (0.5*mesh_.time().deltaT()) - *fvc::surfaceSum(mag(phi))()() - /mesh_.V() - ); - Co.correctBoundaryConditions(); - - return true; -} - - -bool Foam::functionObjects::CourantNo::write(const bool postProcess) -{ - const volScalarField& CourantNo = - obr_.lookupObject<volScalarField>(type()); - - Info<< type() << " " << name() << " output:" << nl - << " writing field " << CourantNo.name() << nl - << endl; - - CourantNo.write(); + if (foundField<surfaceScalarField>(phiName_)) + { + const surfaceScalarField& phi = + lookupField<surfaceScalarField>(phiName_); - return true; + tmp<volScalarField::Internal> Coi + ( + byRho + ( + (0.5*mesh_.time().deltaT()) + *fvc::surfaceSum(mag(phi))()() + /mesh_.V() + ) + ); + + if (foundField<volScalarField>(resultName_)) + { + volScalarField& Co + ( + const_cast<volScalarField&> + ( + lookupField<volScalarField>(resultName_) + ) + ); + + Co.ref() = Coi(); + Co.correctBoundaryConditions(); + } + else + { + tmp<volScalarField> tCo + ( + new volScalarField + ( + IOobject + ( + resultName_, + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("0", dimless, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + tCo.ref().ref() = Coi(); + tCo.ref().correctBoundaryConditions(); + mesh_.objectRegistry::store(tCo.ptr()); + } + + return true; + } + else + { + return false; + } } diff --git a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H index feaa6b0aea6..1e20c5e58e4 100644 --- a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H +++ b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H @@ -33,6 +33,7 @@ Description be retrieved and used for other applications. SeeAlso + Foam::functionObjects::fieldExpression Foam::functionObjects::fvMeshFunctionObject SourceFiles @@ -43,7 +44,7 @@ SourceFiles #ifndef functionObjects_CourantNo_H #define functionObjects_CourantNo_H -#include "fvMeshFunctionObject.H" +#include "fieldExpression.H" #include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,7 +60,7 @@ namespace functionObjects class CourantNo : - public fvMeshFunctionObject + public fieldExpression { // Private data @@ -78,12 +79,6 @@ class CourantNo const tmp<volScalarField::Internal>& Co ) const; - //- Disallow default bitwise copy construct - CourantNo(const CourantNo&); - - //- Disallow default bitwise assignment - void operator=(const CourantNo&); - public: @@ -113,9 +108,6 @@ public: //- Execute, currently does nothing virtual bool execute(const bool postProcess = false); - - //- Calculate the CourantNo and write - virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C index c942606b5a8..e6f8ccfad1d 100644 --- a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C +++ b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C @@ -24,8 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "Lambda2.H" -#include "volFields.H" -#include "zeroGradientFvPatchFields.H" #include "fvcGrad.H" #include "addToRunTimeSelectionTable.H" @@ -56,29 +54,8 @@ Foam::functionObjects::Lambda2::Lambda2 const dictionary& dict ) : - fvMeshFunctionObject(name, runTime, dict) -{ - read(dict); - - volScalarField* Lambda2Ptr - ( - new volScalarField - ( - IOobject - ( - type(), - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("0", dimless/sqr(dimTime), 0.0) - ) - ); - - mesh_.objectRegistry::store(Lambda2Ptr); -} + fieldExpression(name, runTime, dict, "U", "Lambda2") +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -89,51 +66,30 @@ Foam::functionObjects::Lambda2::~Lambda2() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::functionObjects::Lambda2::read(const dictionary& dict) -{ - UName_ = dict.lookupOrDefault<word>("U", "U"); - - return true; -} - - bool Foam::functionObjects::Lambda2::execute(const bool postProcess) { - const volVectorField& U = - mesh_.lookupObject<volVectorField>(UName_); - - const volTensorField gradU(fvc::grad(U)); + if (foundField<volVectorField>(fieldName_)) + { + const volVectorField& U = lookupField<volVectorField>(fieldName_); + const tmp<volTensorField> tgradU(fvc::grad(U)); + const volTensorField& gradU = tgradU(); - const volTensorField SSplusWW - ( - (symm(gradU) & symm(gradU)) - + (skew(gradU) & skew(gradU)) - ); - - volScalarField& Lambda2 = - const_cast<volScalarField&> + const volTensorField SSplusWW ( - mesh_.lookupObject<volScalarField>(type()) + (symm(gradU) & symm(gradU)) + + (skew(gradU) & skew(gradU)) ); - Lambda2 = -eigenValues(SSplusWW)().component(vector::Y); - - return true; -} - - -bool Foam::functionObjects::Lambda2::write(const bool postProcess) -{ - const volScalarField& Lambda2 = - obr_.lookupObject<volScalarField>(type()); - - Info<< type() << " " << name() << " output:" << nl - << " writing field " << Lambda2.name() << nl - << endl; - - Lambda2.write(); - - return true; + return store + ( + resultName_, + -eigenValues(SSplusWW)().component(vector::Y) + ); + } + else + { + return false; + } } diff --git a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H index 0957556aa35..28b46b6ea0b 100644 --- a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H +++ b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H @@ -33,6 +33,7 @@ Description the velocity gradient tensor. SeeAlso + Foam::functionObjects::fieldExpression Foam::functionObjects::fvMeshFunctionObject SourceFiles @@ -43,8 +44,7 @@ SourceFiles #ifndef functionObjects_Lambda2_H #define functionObjects_Lambda2_H -#include "fvMeshFunctionObject.H" -#include "volFieldsFwd.H" +#include "fieldExpression.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,22 +59,8 @@ namespace functionObjects class Lambda2 : - public fvMeshFunctionObject + public fieldExpression { - // Private data - - //- Name of velocity field, default is "U" - word UName_; - - - // Private Member Functions - - //- Disallow default bitwise copy construct - Lambda2(const Lambda2&); - - //- Disallow default bitwise assignment - void operator=(const Lambda2&); - public: @@ -99,14 +85,8 @@ public: // Member Functions - //- Read the Lambda2 data - virtual bool read(const dictionary&); - - //- Calculate Lambda2 + //- Calculate the Lambda2 field virtual bool execute(const bool postProcess = false); - - //- Write Lambda2 - virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index 4d4491351df..86bda4ca735 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -40,5 +40,6 @@ vorticity/vorticity.C Q/Q.C Lambda2/Lambda2.C CourantNo/CourantNo.C +Peclet/Peclet.C LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects diff --git a/src/postProcessing/functionObjects/field/Make/options b/src/postProcessing/functionObjects/field/Make/options index 0732822dba6..c1ebbb17e7c 100644 --- a/src/postProcessing/functionObjects/field/Make/options +++ b/src/postProcessing/functionObjects/field/Make/options @@ -4,7 +4,8 @@ EXE_INC = \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ - -I$(LIB_SRC)/surfMesh/lnInclude + -I$(LIB_SRC)/surfMesh/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude LIB_LIBS = \ -lfiniteVolume \ diff --git a/src/postProcessing/functionObjects/field/Peclet/Peclet.C b/src/postProcessing/functionObjects/field/Peclet/Peclet.C new file mode 100644 index 00000000000..a948b658b2b --- /dev/null +++ b/src/postProcessing/functionObjects/field/Peclet/Peclet.C @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013-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 "Peclet.H" +#include "turbulenceModel.H" +#include "surfaceInterpolate.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(Peclet, 0); + + addToRunTimeSelectionTable + ( + functionObject, + Peclet, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::Peclet::Peclet +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "phi", "Pe") +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::Peclet::~Peclet() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::Peclet::read(const dictionary& dict) +{ + fieldExpression::read(dict); + + phiName_ = dict.lookupOrDefault<word>("phi", "phi"); + + return true; +} + + +bool Foam::functionObjects::Peclet::execute(const bool postProcess) +{ + if (foundField<surfaceScalarField>(phiName_)) + { + tmp<volScalarField> nuEff + ( + mesh_.lookupObject<turbulenceModel> + ( + turbulenceModel::propertiesName + ).nuEff() + ); + + const surfaceScalarField& phi = + mesh_.lookupObject<surfaceScalarField>(phiName_); + + return store + ( + resultName_, + mag(phi) + /( + mesh_.magSf() + *mesh_.surfaceInterpolation::deltaCoeffs() + *fvc::interpolate(nuEff) + ) + ); + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H b/src/postProcessing/functionObjects/field/Peclet/Peclet.H similarity index 85% rename from src/postProcessing/functionObjects/utilities/Peclet/Peclet.H rename to src/postProcessing/functionObjects/field/Peclet/Peclet.H index d2e872b8689..1abbb49cdc1 100644 --- a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H +++ b/src/postProcessing/functionObjects/field/Peclet/Peclet.H @@ -32,6 +32,7 @@ Description surfaceScalarField. SeeAlso + Foam::functionObjects::fieldExpression Foam::functionObjects::fvMeshFunctionObject SourceFiles @@ -42,8 +43,7 @@ SourceFiles #ifndef functionObjects_Peclet_H #define functionObjects_Peclet_H -#include "fvMeshFunctionObject.H" -#include "volFieldsFwd.H" +#include "fieldExpression.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -58,25 +58,13 @@ namespace functionObjects class Peclet : - public fvMeshFunctionObject + public fieldExpression { // Private data //- Name of flux field, default is "phi" word phiName_; - //- Name of density field (compressible cases only), default is "rho" - word rhoName_; - - - // Private Member Functions - - //- Disallow default bitwise copy construct - Peclet(const Peclet&); - - //- Disallow default bitwise assignment - void operator=(const Peclet&); - public: @@ -107,9 +95,6 @@ public: //- Calculate the Peclet number field virtual bool execute(const bool postProcess = false); - - //- Write the Peclet number field - virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/Q/Q.H b/src/postProcessing/functionObjects/field/Q/Q.H index 40f5cd81032..7811508faa2 100644 --- a/src/postProcessing/functionObjects/field/Q/Q.H +++ b/src/postProcessing/functionObjects/field/Q/Q.H @@ -88,7 +88,7 @@ public: // Member Functions - //- Calculate the Q-field + //- Calculate the Q field virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/vorticity/vorticity.C b/src/postProcessing/functionObjects/field/vorticity/vorticity.C index fab61b736ad..8c2291136f4 100644 --- a/src/postProcessing/functionObjects/field/vorticity/vorticity.C +++ b/src/postProcessing/functionObjects/field/vorticity/vorticity.C @@ -24,7 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "vorticity.H" -#include "volFields.H" #include "fvcCurl.H" #include "addToRunTimeSelectionTable.H" @@ -55,30 +54,8 @@ Foam::functionObjects::vorticity::vorticity const dictionary& dict ) : - fvMeshFunctionObject(name, runTime, dict), - outputName_(typeName) -{ - read(dict); - - volVectorField* vorticityPtr - ( - new volVectorField - ( - IOobject - ( - outputName_, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedVector("0", dimless/dimTime, Zero) - ) - ); - - mesh_.objectRegistry::store(vorticityPtr); -} + fieldExpression(name, runTime, dict, "U", "vorticity") +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -89,43 +66,20 @@ Foam::functionObjects::vorticity::~vorticity() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::functionObjects::vorticity::read(const dictionary& dict) +bool Foam::functionObjects::vorticity::execute(const bool postProcess) { - UName_ = dict.lookupOrDefault<word>("U", "U"); - if (UName_ != "U") + if (foundField<volVectorField>(fieldName_)) { - outputName_ = typeName + "(" + UName_ + ")"; + return store + ( + resultName_, + fvc::curl(lookupField<volVectorField>(fieldName_)) + ); + } + else + { + return false; } - - return true; -} - - -bool Foam::functionObjects::vorticity::execute(const bool postProcess) -{ - const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_); - - volVectorField& vorticity = const_cast<volVectorField&> - ( - mesh_.lookupObject<volVectorField>(outputName_) - ); - - vorticity = fvc::curl(U); - - return true; -} - - -bool Foam::functionObjects::vorticity::write(const bool postProcess) -{ - const volVectorField& vorticity = - mesh_.lookupObject<volVectorField>(outputName_); - - Info<< type() << " " << name() << " output:" << nl - << " writing field " << vorticity.name() << nl - << endl; - - vorticity.write(); return true; } diff --git a/src/postProcessing/functionObjects/field/vorticity/vorticity.H b/src/postProcessing/functionObjects/field/vorticity/vorticity.H index 6d719e3ed90..6d8a360ecd1 100644 --- a/src/postProcessing/functionObjects/field/vorticity/vorticity.H +++ b/src/postProcessing/functionObjects/field/vorticity/vorticity.H @@ -31,6 +31,7 @@ Description This function object calculates the vorticity, the curl of the velocity. SeeAlso + Foam::functionObjects::fieldExpression Foam::functionObjects::fvMeshFunctionObject SourceFiles @@ -41,8 +42,7 @@ SourceFiles #ifndef functionObjects_vorticity_H #define functionObjects_vorticity_H -#include "fvMeshFunctionObject.H" -#include "volFieldsFwd.H" +#include "fieldExpression.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,25 +57,8 @@ namespace functionObjects class vorticity : - public fvMeshFunctionObject + public fieldExpression { - // Private data - - //- Name of velocity field, default is "U" - word UName_; - - //- Name of vorticity field - word outputName_; - - - // Private Member Functions - - //- Disallow default bitwise copy construct - vorticity(const vorticity&); - - //- Disallow default bitwise assignment - void operator=(const vorticity&); - public: @@ -100,14 +83,8 @@ public: // Member Functions - //- Read the vorticity data - virtual bool read(const dictionary&); - //- Execute, currently does nothing virtual bool execute(const bool postProcess = false); - - //- Calculate the vorticity and write - virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 25364ae2251..7e7e618e3d2 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -13,7 +13,6 @@ blendingFactor/blendingFactor.C dsmcFields/dsmcFields.C turbulenceFields/turbulenceFields.C -Peclet/Peclet.C yPlus/yPlus.C LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects diff --git a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C deleted file mode 100644 index e84f841287f..00000000000 --- a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C +++ /dev/null @@ -1,202 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013-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 "Peclet.H" -#include "volFields.H" -#include "dictionary.H" -#include "surfaceFields.H" -#include "turbulentTransportModel.H" -#include "turbulentFluidThermoModel.H" -#include "surfaceInterpolate.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ - defineTypeNameAndDebug(Peclet, 0); - - addToRunTimeSelectionTable - ( - functionObject, - Peclet, - dictionary - ); -} -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::Peclet::Peclet -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fvMeshFunctionObject(name, runTime, dict) -{ - read(dict); - - surfaceScalarField* PecletPtr - ( - new surfaceScalarField - ( - IOobject - ( - type(), - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("0", dimless, 0.0) - ) - ); - - mesh_.objectRegistry::store(PecletPtr); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::Peclet::~Peclet() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::Peclet::read(const dictionary& dict) -{ - phiName_ = dict.lookupOrDefault<word>("phi", "phi"); - rhoName_ = dict.lookupOrDefault<word>("rho", "rho"); - - return true; -} - - -bool Foam::functionObjects::Peclet::execute(const bool postProcess) -{ - typedef compressible::turbulenceModel cmpTurbModel; - typedef incompressible::turbulenceModel icoTurbModel; - - tmp<volScalarField> nuEff; - if (mesh_.foundObject<cmpTurbModel>(turbulenceModel::propertiesName)) - { - const cmpTurbModel& model = - mesh_.lookupObject<cmpTurbModel> - ( - turbulenceModel::propertiesName - ); - - const volScalarField& rho = - mesh_.lookupObject<volScalarField>(rhoName_); - - nuEff = model.muEff()/rho; - } - else if - ( - mesh_.foundObject<icoTurbModel>(turbulenceModel::propertiesName) - ) - { - const icoTurbModel& model = - mesh_.lookupObject<icoTurbModel> - ( - turbulenceModel::propertiesName - ); - - nuEff = model.nuEff(); - } - else if (mesh_.foundObject<dictionary>("transportProperties")) - { - const dictionary& model = - mesh_.lookupObject<dictionary>("transportProperties"); - - nuEff = - tmp<volScalarField> - ( - new volScalarField - ( - IOobject - ( - "nuEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(model.lookup("nu")) - ) - ); - } - else - { - FatalErrorInFunction - << "Unable to determine the viscosity" - << exit(FatalError); - } - - const surfaceScalarField& phi = - mesh_.lookupObject<surfaceScalarField>(phiName_); - - surfaceScalarField& Peclet = - const_cast<surfaceScalarField&> - ( - mesh_.lookupObject<surfaceScalarField>(type()) - ); - - Peclet = - mag(phi) - /( - mesh_.magSf() - *mesh_.surfaceInterpolation::deltaCoeffs() - *fvc::interpolate(nuEff) - ); - - return true; -} - - -bool Foam::functionObjects::Peclet::write(const bool postProcess) -{ - const surfaceScalarField& Peclet = - mesh_.lookupObject<surfaceScalarField>(type()); - - Info<< type() << " " << name() << " output:" << nl - << " writing field " << Peclet.name() << nl - << endl; - - Peclet.write(); - - return true; -} - - -// ************************************************************************* // -- GitLab