From 6bc00144fc546f7283b4c749f356a0db344dad94 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 25 May 2016 15:40:58 +0100 Subject: [PATCH] functionObjects: Clear the result field from the objectRegistry if the argument fields are not available This is needed to handle the processing of many time directories, some of which may have the required fields and some not. --- .../fvMeshFunctionObject.C | 25 +++++++ .../fvMeshFunctionObject.H | 3 + .../fvMeshFunctionObjectTemplates.C | 16 ++++- .../field/CourantNo/CourantNo.C | 70 +++++++++---------- .../field/CourantNo/CourantNo.H | 8 +-- .../functionObjects/field/Lambda2/Lambda2.C | 42 +++++------ .../functionObjects/field/Lambda2/Lambda2.H | 11 ++- .../functionObjects/field/MachNo/MachNo.C | 42 +++++------ .../functionObjects/field/MachNo/MachNo.H | 11 ++- .../functionObjects/field/PecletNo/PecletNo.C | 68 +++++++++--------- .../functionObjects/field/PecletNo/PecletNo.H | 9 ++- .../functionObjects/field/Q/Q.C | 42 +++++------ .../functionObjects/field/Q/Q.H | 11 ++- .../field/blendingFactor/blendingFactor.C | 36 +++++----- .../field/blendingFactor/blendingFactor.H | 10 +-- .../blendingFactor/blendingFactorTemplates.C | 2 +- .../functionObjects/field/div/div.C | 32 ++++----- .../functionObjects/field/div/div.H | 11 ++- .../functionObjects/field/div/divTemplates.C | 2 +- .../field/enstrophy/enstrophy.C | 42 +++++------ .../field/enstrophy/enstrophy.H | 11 ++- .../field/fieldExpression/fieldExpression.C | 37 +++++++++- .../field/fieldExpression/fieldExpression.H | 10 ++- .../functionObjects/field/flowType/flowType.C | 42 +++++------ .../functionObjects/field/flowType/flowType.H | 11 ++- .../functionObjects/field/grad/grad.C | 32 ++++----- .../functionObjects/field/grad/grad.H | 11 ++- .../field/grad/gradTemplates.C | 2 +- .../functionObjects/field/mag/mag.C | 44 ++++++------ .../functionObjects/field/mag/mag.H | 11 ++- .../functionObjects/field/mag/magTemplates.C | 2 +- .../functionObjects/field/pressure/pressure.C | 40 ++++++----- .../functionObjects/field/pressure/pressure.H | 6 +- .../field/vorticity/vorticity.C | 42 +++++------ .../field/vorticity/vorticity.H | 11 ++- 35 files changed, 435 insertions(+), 370 deletions(-) diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C index 7fbfb0272..57945b024 100644 --- a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C +++ b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C @@ -66,6 +66,31 @@ bool Foam::functionObjects::fvMeshFunctionObject::writeField } +bool Foam::functionObjects::fvMeshFunctionObject::clearField +( + const word& fieldName +) +{ + if (foundField(fieldName)) + { + const regIOobject& resultField = lookupField(fieldName); + + if (resultField.ownedByRegistry()) + { + return const_cast(resultField).checkOut(); + } + else + { + return false; + } + } + else + { + return true; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::fvMeshFunctionObject::fvMeshFunctionObject diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H index 62315000f..78c259f0f 100644 --- a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H +++ b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H @@ -95,6 +95,9 @@ protected: //- Write field if present in objectRegistry bool writeField(const word& fieldName); + //- Clear field from the objectRegistry if present + bool clearField(const word& fieldName); + private: diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C index 48b680620..b3e07b251 100644 --- a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C +++ b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObjectTemplates.C @@ -74,10 +74,22 @@ bool Foam::functionObjects::fvMeshFunctionObject::store && mesh_.foundObject(fieldName) ) { - const_cast + const FieldType& field = ( mesh_.lookupObject(fieldName) - ) = tfield; + ); + + // If there is a result field already registered assign to the new + // result field otherwise transfer ownership of the new result field to + // the object registry + if (&field != &tfield()) + { + const_cast(field) = tfield; + } + else + { + mesh_.objectRegistry::store(tfield.ptr()); + } } else { diff --git a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C index 736fdece6..53cd86a60 100644 --- a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C +++ b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.C @@ -66,41 +66,7 @@ Foam::functionObjects::CourantNo::byRho } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::CourantNo::CourantNo -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "phi", "Co") -{ - read(dict); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::CourantNo::~CourantNo() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::CourantNo::read(const dictionary& dict) -{ - fieldExpression::read(dict); - - phiName_ = dict.lookupOrDefault("phi", "phi"); - rhoName_ = dict.lookupOrDefault("rho", "rho"); - - return true; -} - - -bool Foam::functionObjects::CourantNo::execute(const bool postProcess) +bool Foam::functionObjects::CourantNo::calc() { if (foundField(phiName_)) { @@ -163,4 +129,38 @@ bool Foam::functionObjects::CourantNo::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::CourantNo::CourantNo +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "phi", "Co") +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::CourantNo::~CourantNo() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::CourantNo::read(const dictionary& dict) +{ + fieldExpression::read(dict); + + phiName_ = dict.lookupOrDefault("phi", "phi"); + rhoName_ = dict.lookupOrDefault("rho", "rho"); + + return true; +} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H index d29afdf24..346cd2bb7 100644 --- a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H +++ b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H @@ -73,12 +73,15 @@ class CourantNo // Private Member Functions - //- Divide Co by rho if required + //- Divide the Courant number by rho if required tmp byRho ( const tmp& Co ) const; + //- Calculate the Courant number field and return true if successful + virtual bool calc(); + public: @@ -105,9 +108,6 @@ public: //- Read the CourantNo data virtual bool read(const dictionary&); - - //- Calculate the Courant number - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C index e6f8ccfad..002314787 100644 --- a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C +++ b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::functionObjects::Lambda2::Lambda2 -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "U", "Lambda2") -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::Lambda2::~Lambda2() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::Lambda2::execute(const bool postProcess) +bool Foam::functionObjects::Lambda2::calc() { if (foundField(fieldName_)) { @@ -93,4 +74,23 @@ bool Foam::functionObjects::Lambda2::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::Lambda2::Lambda2 +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "U", "Lambda2") +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::Lambda2::~Lambda2() +{} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H index 34cc98d73..f94e6cd1d 100644 --- a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H +++ b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.H @@ -61,6 +61,11 @@ class Lambda2 : public fieldExpression { + // Private Member Functions + + //- Calculate the Lambda2 field and return true if successful + virtual bool calc(); + public: @@ -81,12 +86,6 @@ public: //- Destructor virtual ~Lambda2(); - - - // Member Functions - - //- Calculate the Lambda2 field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/MachNo/MachNo.C b/src/postProcessing/functionObjects/field/MachNo/MachNo.C index d252a45b3..1d08a6402 100644 --- a/src/postProcessing/functionObjects/field/MachNo/MachNo.C +++ b/src/postProcessing/functionObjects/field/MachNo/MachNo.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::functionObjects::MachNo::MachNo -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "U", "Ma") -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::MachNo::~MachNo() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::MachNo::execute(const bool postProcess) +bool Foam::functionObjects::MachNo::calc() { if ( @@ -92,4 +73,23 @@ bool Foam::functionObjects::MachNo::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::MachNo::MachNo +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "U", "Ma") +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::MachNo::~MachNo() +{} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/MachNo/MachNo.H b/src/postProcessing/functionObjects/field/MachNo/MachNo.H index 4d744f621..342647cd9 100644 --- a/src/postProcessing/functionObjects/field/MachNo/MachNo.H +++ b/src/postProcessing/functionObjects/field/MachNo/MachNo.H @@ -60,6 +60,11 @@ class MachNo : public fieldExpression { + // Private Member Functions + + //- Calculate the Mach number field and return true if successful + virtual bool calc(); + public: @@ -81,12 +86,6 @@ public: //- Destructor virtual ~MachNo(); - - - // Member Functions - - //- Calculate the Mach number field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/PecletNo/PecletNo.C b/src/postProcessing/functionObjects/field/PecletNo/PecletNo.C index 2164947a9..5e11a10ee 100644 --- a/src/postProcessing/functionObjects/field/PecletNo/PecletNo.C +++ b/src/postProcessing/functionObjects/field/PecletNo/PecletNo.C @@ -46,6 +46,41 @@ namespace functionObjects } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::PecletNo::calc() +{ + if (foundField(phiName_)) + { + tmp nuEff + ( + mesh_.lookupObject + ( + turbulenceModel::propertiesName + ).nuEff() + ); + + const surfaceScalarField& phi = + mesh_.lookupObject(phiName_); + + return store + ( + resultName_, + mag(phi) + /( + mesh_.magSf() + *mesh_.surfaceInterpolation::deltaCoeffs() + *fvc::interpolate(nuEff) + ) + ); + } + else + { + return false; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::PecletNo::PecletNo @@ -79,37 +114,4 @@ bool Foam::functionObjects::PecletNo::read(const dictionary& dict) } -bool Foam::functionObjects::PecletNo::execute(const bool postProcess) -{ - if (foundField(phiName_)) - { - tmp nuEff - ( - mesh_.lookupObject - ( - turbulenceModel::propertiesName - ).nuEff() - ); - - const surfaceScalarField& phi = - mesh_.lookupObject(phiName_); - - return store - ( - resultName_, - mag(phi) - /( - mesh_.magSf() - *mesh_.surfaceInterpolation::deltaCoeffs() - *fvc::interpolate(nuEff) - ) - ); - } - else - { - return false; - } -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/PecletNo/PecletNo.H b/src/postProcessing/functionObjects/field/PecletNo/PecletNo.H index 7dd7149f7..3ff90f0cd 100644 --- a/src/postProcessing/functionObjects/field/PecletNo/PecletNo.H +++ b/src/postProcessing/functionObjects/field/PecletNo/PecletNo.H @@ -66,6 +66,12 @@ class PecletNo word phiName_; + // Private Member Functions + + //- Calculate the Peclet number field and return true if successful + virtual bool calc(); + + public: //- Runtime type information @@ -92,9 +98,6 @@ public: //- Read the PecletNo data virtual bool read(const dictionary&); - - //- Calculate the Peclet number field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/Q/Q.C b/src/postProcessing/functionObjects/field/Q/Q.C index 52cc9f148..043550caa 100644 --- a/src/postProcessing/functionObjects/field/Q/Q.C +++ b/src/postProcessing/functionObjects/field/Q/Q.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::functionObjects::Q::Q -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "U", "Q") -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::Q::~Q() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::Q::execute(const bool postProcess) +bool Foam::functionObjects::Q::calc() { if (foundField(fieldName_)) { @@ -87,4 +68,23 @@ bool Foam::functionObjects::Q::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::Q::Q +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "U", "Q") +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::Q::~Q() +{} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/Q/Q.H b/src/postProcessing/functionObjects/field/Q/Q.H index feca1d1b4..1305b02b1 100644 --- a/src/postProcessing/functionObjects/field/Q/Q.H +++ b/src/postProcessing/functionObjects/field/Q/Q.H @@ -64,6 +64,11 @@ class Q : public fieldExpression { + // Private Member Functions + + //- Calculate the Q field and return true if successful + virtual bool calc(); + public: @@ -84,12 +89,6 @@ public: //- Destructor virtual ~Q(); - - - // Member Functions - - //- Calculate the Q field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.C b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.C index 50a055c0a..60cc2d36f 100644 --- a/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.C +++ b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.C @@ -38,6 +38,25 @@ namespace functionObjects } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::blendingFactor::calc() +{ + bool processed = false; + + processed = processed || calcBF(); + processed = processed || calcBF(); + + if (!processed) + { + WarningInFunction + << "Unprocessed field " << fieldName_ << endl; + } + + return processed; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::blendingFactor::blendingFactor @@ -73,21 +92,4 @@ bool Foam::functionObjects::blendingFactor::read(const dictionary& dict) } -bool Foam::functionObjects::blendingFactor::execute(const bool postProcess) -{ - bool processed = false; - - processed = processed || calc(); - processed = processed || calc(); - - if (!processed) - { - WarningInFunction - << "Unprocessed field " << fieldName_ << endl; - } - - return processed; -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.H b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.H index b7f0363be..56f0310f7 100644 --- a/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.H +++ b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.H @@ -69,9 +69,12 @@ class blendingFactor // Private Member Functions - //- Calculate the blending factor + //- Calculate the blending factor field template - bool calc(); + bool calcBF(); + + //- Calculate the blending factor field and return true if successful + virtual bool calc(); public: @@ -99,9 +102,6 @@ public: //- Read the blendingFactor data virtual bool read(const dictionary&); - - //- Calculate the blending-factor - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C index 565b77c0d..6c51490ed 100644 --- a/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C +++ b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -bool Foam::functionObjects::blendingFactor::calc() +bool Foam::functionObjects::blendingFactor::calcBF() { typedef GeometricField FieldType; diff --git a/src/postProcessing/functionObjects/field/div/div.C b/src/postProcessing/functionObjects/field/div/div.C index c8aefb169..582e33ef5 100644 --- a/src/postProcessing/functionObjects/field/div/div.C +++ b/src/postProcessing/functionObjects/field/div/div.C @@ -40,6 +40,19 @@ namespace functionObjects } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::div::calc() +{ + bool processed = false; + + processed = processed || calcDiv(); + processed = processed || calcDiv(); + + return processed; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::div::div @@ -59,23 +72,4 @@ Foam::functionObjects::div::~div() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::div::execute(const bool postProcess) -{ - bool processed = false; - - processed = processed || calc(); - processed = processed || calc(); - - if (!processed) - { - WarningInFunction - << "Unprocessed field " << fieldName_ << endl; - } - - return processed; -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/div/div.H b/src/postProcessing/functionObjects/field/div/div.H index 1076300b8..778147454 100644 --- a/src/postProcessing/functionObjects/field/div/div.H +++ b/src/postProcessing/functionObjects/field/div/div.H @@ -66,7 +66,10 @@ class div //- Calculate the divergence of either a // volScalarField or a surfaceScalarField and register the result template - bool calc(); + bool calcDiv(); + + //- Calculate the divergence field and return true if successful + virtual bool calc(); public: @@ -88,12 +91,6 @@ public: //- Destructor virtual ~div(); - - - // Member Functions - - //- Calculate the divergence field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/div/divTemplates.C b/src/postProcessing/functionObjects/field/div/divTemplates.C index e791e25b2..fb204a456 100644 --- a/src/postProcessing/functionObjects/field/div/divTemplates.C +++ b/src/postProcessing/functionObjects/field/div/divTemplates.C @@ -28,7 +28,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -bool Foam::functionObjects::div::calc() +bool Foam::functionObjects::div::calcDiv() { if (foundField(fieldName_)) { diff --git a/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C b/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C index 3c28af514..9370c668c 100644 --- a/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C +++ b/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C @@ -45,6 +45,27 @@ namespace functionObjects } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::enstrophy::calc() +{ + if (foundField(fieldName_)) + { + return store + ( + resultName_, + 0.5*magSqr(fvc::curl(lookupField(fieldName_))) + ); + } + else + { + return false; + } + + return true; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::enstrophy::enstrophy @@ -64,25 +85,4 @@ Foam::functionObjects::enstrophy::~enstrophy() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::enstrophy::execute(const bool postProcess) -{ - if (foundField(fieldName_)) - { - return store - ( - resultName_, - 0.5*magSqr(fvc::curl(lookupField(fieldName_))) - ); - } - else - { - return false; - } - - return true; -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/enstrophy/enstrophy.H b/src/postProcessing/functionObjects/field/enstrophy/enstrophy.H index 211102e20..ae044e8aa 100644 --- a/src/postProcessing/functionObjects/field/enstrophy/enstrophy.H +++ b/src/postProcessing/functionObjects/field/enstrophy/enstrophy.H @@ -59,6 +59,11 @@ class enstrophy : public fieldExpression { + // Private Member Functions + + //- Calculate the enstrophy field and return true if successful + virtual bool calc(); + public: @@ -79,12 +84,6 @@ public: //- Destructor virtual ~enstrophy(); - - - // Member Functions - - //- Calculate the enstrophy field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.C b/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.C index f4d557559..868e0d78f 100644 --- a/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.C +++ b/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.C @@ -36,6 +36,15 @@ namespace functionObjects } +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +bool Foam::functionObjects::fieldExpression::calc() +{ + NotImplemented; + return false; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::fieldExpression::fieldExpression @@ -81,9 +90,35 @@ bool Foam::functionObjects::fieldExpression::read(const dictionary& dict) } +bool Foam::functionObjects::fieldExpression::execute(const bool postProcess) +{ + if (!calc()) + { + Warning + << "functionObject " << type() << ": Cannot find required field " + << fieldName_ << endl; + + // Clear the result field from the objectRegistry if present + clear(); + + return false; + } + else + { + return true; + } +} + + bool Foam::functionObjects::fieldExpression::write(const bool postProcess) { - return fvMeshFunctionObject::writeField(resultName_); + return writeField(resultName_); +} + + +bool Foam::functionObjects::fieldExpression::clear() +{ + return clearField(resultName_); } diff --git a/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.H b/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.H index 3b0e645e2..f6c7eb227 100644 --- a/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.H +++ b/src/postProcessing/functionObjects/field/fieldExpression/fieldExpression.H @@ -69,6 +69,11 @@ protected: word resultName_; + // Protected member functions + + virtual bool calc(); + + private: // Private Member Functions @@ -109,10 +114,13 @@ public: virtual bool read(const dictionary&); //- Calculate the fieldExpressionergence field - virtual bool execute(const bool postProcess = false) = 0; + virtual bool execute(const bool postProcess = false); //- Write the fieldExpressionergence field virtual bool write(const bool postProcess = false); + + //- Clear the result field from the objectRegistry + virtual bool clear(); }; diff --git a/src/postProcessing/functionObjects/field/flowType/flowType.C b/src/postProcessing/functionObjects/field/flowType/flowType.C index d28261777..5193f3736 100644 --- a/src/postProcessing/functionObjects/field/flowType/flowType.C +++ b/src/postProcessing/functionObjects/field/flowType/flowType.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::functionObjects::flowType::flowType -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "U", "flowType") -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::flowType::~flowType() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::flowType::execute(const bool postProcess) +bool Foam::functionObjects::flowType::calc() { if (foundField(fieldName_)) { @@ -97,4 +78,23 @@ bool Foam::functionObjects::flowType::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::flowType::flowType +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "U", "flowType") +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::flowType::~flowType() +{} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/flowType/flowType.H b/src/postProcessing/functionObjects/field/flowType/flowType.H index f73e82b73..54205736f 100644 --- a/src/postProcessing/functionObjects/field/flowType/flowType.H +++ b/src/postProcessing/functionObjects/field/flowType/flowType.H @@ -70,6 +70,11 @@ class flowType : public fieldExpression { + // Private Member Functions + + //- Calculate the flowType field and return true if successful + virtual bool calc(); + public: @@ -90,12 +95,6 @@ public: //- Destructor virtual ~flowType(); - - - // Member Functions - - //- Calculate the flowType field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/grad/grad.C b/src/postProcessing/functionObjects/field/grad/grad.C index 1ee5d82f8..b265ec80b 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.C +++ b/src/postProcessing/functionObjects/field/grad/grad.C @@ -38,6 +38,19 @@ namespace functionObjects } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::grad::calc() +{ + bool processed = false; + + processed = processed || calcGrad(); + processed = processed || calcGrad(); + + return processed; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::grad::grad @@ -59,23 +72,4 @@ Foam::functionObjects::grad::~grad() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::grad::execute(const bool postProcess) -{ - bool processed = false; - - processed = processed || calc(); - processed = processed || calc(); - - if (!processed) - { - WarningInFunction - << "Unprocessed field " << fieldName_ << endl; - } - - return true; -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/grad/grad.H b/src/postProcessing/functionObjects/field/grad/grad.H index 68bd4450f..36db751f3 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.H +++ b/src/postProcessing/functionObjects/field/grad/grad.H @@ -64,7 +64,10 @@ class grad //- Calculate the magnitude of the field and register the result template - bool calc(); + bool calcGrad(); + + //- Calculate the gradient field and return true if successful + virtual bool calc(); public: @@ -86,12 +89,6 @@ public: //- Destructor virtual ~grad(); - - - // Member Functions - - //- Calculate the gradient field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/grad/gradTemplates.C b/src/postProcessing/functionObjects/field/grad/gradTemplates.C index 026b1a3c7..1eeae1846 100644 --- a/src/postProcessing/functionObjects/field/grad/gradTemplates.C +++ b/src/postProcessing/functionObjects/field/grad/gradTemplates.C @@ -28,7 +28,7 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template -bool Foam::functionObjects::grad::calc() +bool Foam::functionObjects::grad::calcGrad() { typedef GeometricField VolFieldType; typedef GeometricField SurfaceFieldType; diff --git a/src/postProcessing/functionObjects/field/mag/mag.C b/src/postProcessing/functionObjects/field/mag/mag.C index c2e519d26..b37a053c5 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.C +++ b/src/postProcessing/functionObjects/field/mag/mag.C @@ -38,6 +38,28 @@ namespace functionObjects } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::mag::calc() +{ + bool processed = false; + + processed = processed || calcMag(); + processed = processed || calcMag(); + processed = processed || calcMag(); + processed = processed || calcMag(); + processed = processed || calcMag(); + + if (!processed) + { + WarningInFunction + << "Unprocessed field " << fieldName_ << endl; + } + + return processed; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::mag::mag @@ -59,26 +81,4 @@ Foam::functionObjects::mag::~mag() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::mag::execute(const bool postProcess) -{ - bool processed = false; - - processed = processed || calc(); - processed = processed || calc(); - processed = processed || calc(); - processed = processed || calc(); - processed = processed || calc(); - - if (!processed) - { - WarningInFunction - << "Unprocessed field " << fieldName_ << endl; - } - - return processed; -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/mag/mag.H b/src/postProcessing/functionObjects/field/mag/mag.H index a77951827..f27908762 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.H +++ b/src/postProcessing/functionObjects/field/mag/mag.H @@ -64,7 +64,10 @@ class mag //- Calculate the magnitude of the field and register the result template - bool calc(); + bool calcMag(); + + //- Calculate the magnitude of the field and return true if successful + virtual bool calc(); public: @@ -86,12 +89,6 @@ public: //- Destructor virtual ~mag(); - - - // Member Functions - - //- Calculate the magnitude field - virtual bool execute(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/mag/magTemplates.C b/src/postProcessing/functionObjects/field/mag/magTemplates.C index 5b78efb93..8cb4debaa 100644 --- a/src/postProcessing/functionObjects/field/mag/magTemplates.C +++ b/src/postProcessing/functionObjects/field/mag/magTemplates.C @@ -29,7 +29,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -bool Foam::functionObjects::mag::calc() +bool Foam::functionObjects::mag::calcMag() { typedef GeometricField VolFieldType; typedef GeometricField SurfaceFieldType; diff --git a/src/postProcessing/functionObjects/field/pressure/pressure.C b/src/postProcessing/functionObjects/field/pressure/pressure.C index da8a32693..d2f854f18 100644 --- a/src/postProcessing/functionObjects/field/pressure/pressure.C +++ b/src/postProcessing/functionObjects/field/pressure/pressure.C @@ -159,6 +159,27 @@ Foam::functionObjects::pressure::coeff } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::pressure::calc() +{ + if (foundField(fieldName_)) + { + const volScalarField& p = lookupField(fieldName_); + + return store + ( + resultName_, + coeff(pRef(pDyn(p, rhoScale(p)))) + ); + } + else + { + return false; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::pressure::pressure @@ -238,23 +259,4 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict) } -bool Foam::functionObjects::pressure::execute(const bool postProcess) -{ - if (foundField(fieldName_)) - { - const volScalarField& p = lookupField(fieldName_); - - return store - ( - resultName_, - coeff(pRef(pDyn(p, rhoScale(p)))) - ); - } - else - { - return false; - } -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/pressure/pressure.H b/src/postProcessing/functionObjects/field/pressure/pressure.H index bd9200172..4970c5aa5 100644 --- a/src/postProcessing/functionObjects/field/pressure/pressure.H +++ b/src/postProcessing/functionObjects/field/pressure/pressure.H @@ -196,6 +196,9 @@ class pressure //- Convert to coeff by applying the freestream dynamic pressure scaling tmp coeff(const tmp& tp) const; + //- Calculate the derived pressure field and return true if successful + virtual bool calc(); + public: @@ -222,9 +225,6 @@ public: //- Read the pressure data virtual bool read(const dictionary&); - - //- Calculate the selected pressure form - 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 8c2291136..b6c462e50 100644 --- a/src/postProcessing/functionObjects/field/vorticity/vorticity.C +++ b/src/postProcessing/functionObjects/field/vorticity/vorticity.C @@ -45,6 +45,27 @@ namespace functionObjects } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::vorticity::calc() +{ + if (foundField(fieldName_)) + { + return store + ( + resultName_, + fvc::curl(lookupField(fieldName_)) + ); + } + else + { + return false; + } + + return true; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::vorticity::vorticity @@ -64,25 +85,4 @@ Foam::functionObjects::vorticity::~vorticity() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::vorticity::execute(const bool postProcess) -{ - if (foundField(fieldName_)) - { - return store - ( - resultName_, - fvc::curl(lookupField(fieldName_)) - ); - } - else - { - return false; - } - - return true; -} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/vorticity/vorticity.H b/src/postProcessing/functionObjects/field/vorticity/vorticity.H index 13c1f096f..44a0b1016 100644 --- a/src/postProcessing/functionObjects/field/vorticity/vorticity.H +++ b/src/postProcessing/functionObjects/field/vorticity/vorticity.H @@ -59,6 +59,11 @@ class vorticity : public fieldExpression { + // Private Member Functions + + //- Calculate the vorticity field and return true if successful + virtual bool calc(); + public: @@ -79,12 +84,6 @@ public: //- Destructor virtual ~vorticity(); - - - // Member Functions - - //- Calculate the vorticity field - virtual bool execute(const bool postProcess = false); };