diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C index 7fbfb027246d132cd00b765ec694372beb7a1696..57945b0246e04c23d7705b6ca22779b3eddde7a1 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<regIOobject>(fieldName)) + { + const regIOobject& resultField = lookupField<regIOobject>(fieldName); + + if (resultField.ownedByRegistry()) + { + return const_cast<regIOobject&>(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 62315000f7a3493db973549e297dc39d1d16e885..78c259f0f738f357ab2d480c36693d27777d6962 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 48b680620e4423a43ac450af8c2e286e993c4089..b3e07b2513752c8465ae24f1069d82a26ec04d3f 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<FieldType>(fieldName) ) { - const_cast<FieldType&> + const FieldType& field = ( mesh_.lookupObject<FieldType>(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<FieldType&>(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 736fdece6726542eabcd2578979063b340ae74f4..53cd86a6063647b29c69866d3342dcd59974ffe4 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<word>("phi", "phi"); - rhoName_ = dict.lookupOrDefault<word>("rho", "rho"); - - return true; -} - - -bool Foam::functionObjects::CourantNo::execute(const bool postProcess) +bool Foam::functionObjects::CourantNo::calc() { if (foundField<surfaceScalarField>(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<word>("phi", "phi"); + rhoName_ = dict.lookupOrDefault<word>("rho", "rho"); + + return true; +} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H b/src/postProcessing/functionObjects/field/CourantNo/CourantNo.H index d29afdf24dd14b9781dcd7c8382c10ce218a4802..346cd2bb7edc72615a646e0d4fe63123ecda5507 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<volScalarField::Internal> byRho ( const tmp<volScalarField::Internal>& 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 e6f8ccfad1d0cc384d25d5438415cf4099dd0130..00231478761d152cb5683a304b67ee4e6d02ec73 100644 --- a/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C +++ b/src/postProcessing/functionObjects/field/Lambda2/Lambda2.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * 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() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::Lambda2::execute(const bool postProcess) +bool Foam::functionObjects::Lambda2::calc() { if (foundField<volVectorField>(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 34cc98d73c0b09410a807bcb6a79e05ce84a165d..f94e6cd1d736ece03a943b386e4c61dceb0effd2 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 d252a45b30767eb35aed8b67a6c69f63d056b966..1d08a64025a9c5d10a4decaf75107d19c92fd9d4 100644 --- a/src/postProcessing/functionObjects/field/MachNo/MachNo.C +++ b/src/postProcessing/functionObjects/field/MachNo/MachNo.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * 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() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private 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 4d744f621943f25360353a7e3f843dc5587baa53..342647cd90828ac21ff1d1d9bc80f72b8b2bbe7b 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 2164947a98620c4c9f52ee32eb27e194480df8f3..5e11a10ee472fb9b3840e5e67560148e7dab6e8c 100644 --- a/src/postProcessing/functionObjects/field/PecletNo/PecletNo.C +++ b/src/postProcessing/functionObjects/field/PecletNo/PecletNo.C @@ -46,40 +46,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::functionObjects::PecletNo::PecletNo -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "phi", "Pe") -{ - read(dict); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::PecletNo::~PecletNo() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionObjects::PecletNo::read(const dictionary& dict) -{ - fieldExpression::read(dict); - - phiName_ = dict.lookupOrDefault<word>("phi", "phi"); - - return true; -} - - -bool Foam::functionObjects::PecletNo::execute(const bool postProcess) +bool Foam::functionObjects::PecletNo::calc() { if (foundField<surfaceScalarField>(phiName_)) { @@ -112,4 +81,37 @@ bool Foam::functionObjects::PecletNo::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::PecletNo::PecletNo +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "phi", "Pe") +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::PecletNo::~PecletNo() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::PecletNo::read(const dictionary& dict) +{ + fieldExpression::read(dict); + + phiName_ = dict.lookupOrDefault<word>("phi", "phi"); + + return true; +} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/PecletNo/PecletNo.H b/src/postProcessing/functionObjects/field/PecletNo/PecletNo.H index 7dd7149f76b14627cdc007364ea65f57e26f25c7..3ff90f0cd4e7e5971bc4e6c9f638513bee6f7afb 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 52cc9f14893164b10abff4cf46e085255d94bd57..043550caa666d761d496248a4aa568343f958613 100644 --- a/src/postProcessing/functionObjects/field/Q/Q.C +++ b/src/postProcessing/functionObjects/field/Q/Q.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * 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() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::Q::execute(const bool postProcess) +bool Foam::functionObjects::Q::calc() { if (foundField<volVectorField>(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 feca1d1b4cb912e9a95d1419cafac7eeeb4adbde..1305b02b1f6a2a0a153c260127d273b1b5c028f5 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 50a055c0a6baf21789bc2184768fa04479a4f493..60cc2d36f79c03a35a6506d6572f2bbaaea83f81 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<scalar>(); + processed = processed || calcBF<vector>(); + + 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<scalar>(); - processed = processed || calc<vector>(); - - 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 b7f0363be2879431ea13734a26b4482d7048e058..56f0310f7f0101b1df710b4d2e9dbff5d1323e66 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<class Type> - 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 565b77c0d75355b1b494fd4dc25aca045005b1f2..6c51490edbbfeb11650a836bb7943f8cc8b2dc65 100644 --- a/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C +++ b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class Type> -bool Foam::functionObjects::blendingFactor::calc() +bool Foam::functionObjects::blendingFactor::calcBF() { typedef GeometricField<Type, fvPatchField, volMesh> FieldType; diff --git a/src/postProcessing/functionObjects/field/div/div.C b/src/postProcessing/functionObjects/field/div/div.C index c8aefb16932b3da98afa3c3dcc6e099bf63a7a1e..582e33ef555df4b2efd745529069bdea7a8b84e7 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<surfaceScalarField>(); + processed = processed || calcDiv<volVectorField>(); + + 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<surfaceScalarField>(); - processed = processed || calc<volVectorField>(); - - 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 1076300b88fd6fba36a353c1c66306b40dfac9a8..778147454f210079645414051a04592a09249c31 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<class FieldType> - 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 e791e25b2cf8778513d02c402791a7f34536d9d1..fb204a4569673b2ca8522417a22f590c4d802c45 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<class FieldType> -bool Foam::functionObjects::div::calc() +bool Foam::functionObjects::div::calcDiv() { if (foundField<FieldType>(fieldName_)) { diff --git a/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C b/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C index 3c28af5147a1beb9e44b5ea710804526f5951c8d..9370c668c99b4e65e7a5615c7a09d482f405f7fe 100644 --- a/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C +++ b/src/postProcessing/functionObjects/field/enstrophy/enstrophy.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::enstrophy::enstrophy -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "U", "enstrophy") -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::enstrophy::~enstrophy() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::enstrophy::execute(const bool postProcess) +bool Foam::functionObjects::enstrophy::calc() { if (foundField<volVectorField>(fieldName_)) { @@ -85,4 +66,23 @@ bool Foam::functionObjects::enstrophy::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::enstrophy::enstrophy +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "U", "enstrophy") +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::enstrophy::~enstrophy() +{} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/enstrophy/enstrophy.H b/src/postProcessing/functionObjects/field/enstrophy/enstrophy.H index 211102e20a7f138ef99105b5601f19f9dd9a7fb6..ae044e8aacf02defdb7f6570a97e8d046d49dd92 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 f4d5575594e8530b55ee5d6dcb2f7d6edf7f9d35..868e0d78f5da26877beeb95811197fecc24744b3 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 3b0e645e230bb2176c8008b6168d3c28480d336e..f6c7eb227fb2d6f2cf5c5c365ddcccbd18e4de99 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 d282617778d008d7b5784b9c16f183bb49749049..5193f3736c467ae2898987e21fa86c92d3e7b5b3 100644 --- a/src/postProcessing/functionObjects/field/flowType/flowType.C +++ b/src/postProcessing/functionObjects/field/flowType/flowType.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * 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() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::flowType::execute(const bool postProcess) +bool Foam::functionObjects::flowType::calc() { if (foundField<volVectorField>(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 f73e82b732a4bb43f4b90660219ca6597cfb0c6b..54205736f4048251c3410f3c117115508b9609c2 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 1ee5d82f8cc855136a945e9253a74b5f03464b68..b265ec80b7cb1583d33db4ccf515f9df218eccb9 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<scalar>(); + processed = processed || calcGrad<vector>(); + + 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<scalar>(); - processed = processed || calc<vector>(); - - 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 68bd4450f6184b48243fa44a2c1d15cf0cb7fef6..36db751f317adcacf039b71e31fc2f49ffd2631d 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<class Type> - 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 026b1a3c7054a501e3ad8561b8bf5cdd365075c9..1eeae1846658d291e5a542a6f4e94588f5c02922 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<class Type> -bool Foam::functionObjects::grad::calc() +bool Foam::functionObjects::grad::calcGrad() { typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; diff --git a/src/postProcessing/functionObjects/field/mag/mag.C b/src/postProcessing/functionObjects/field/mag/mag.C index c2e519d267e1af97927f951b2d4c6fa1581ce9d1..b37a053c580c2de3fdb98b193fdbd879788368dd 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<scalar>(); + processed = processed || calcMag<vector>(); + processed = processed || calcMag<sphericalTensor>(); + processed = processed || calcMag<symmTensor>(); + processed = processed || calcMag<tensor>(); + + 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<scalar>(); - processed = processed || calc<vector>(); - processed = processed || calc<sphericalTensor>(); - processed = processed || calc<symmTensor>(); - processed = processed || calc<tensor>(); - - 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 a77951827e3dda4e3ae0c72eb536cd6ac38f6698..f27908762d02e48b3d8012384741c79d9ae32455 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<class Type> - 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 5b78efb93a670f2599d36676eb6df278e8f0c40f..8cb4debaa68d27affc69437ee68fd9c3afbaede5 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<class Type> -bool Foam::functionObjects::mag::calc() +bool Foam::functionObjects::mag::calcMag() { typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; diff --git a/src/postProcessing/functionObjects/field/pressure/pressure.C b/src/postProcessing/functionObjects/field/pressure/pressure.C index da8a32693111885c235c09885948e478e40ed46a..d2f854f1814100404ea7e078602e1aa251db952e 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<volScalarField>(fieldName_)) + { + const volScalarField& p = lookupField<volScalarField>(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<volScalarField>(fieldName_)) - { - const volScalarField& p = lookupField<volScalarField>(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 bd92001723ed8027c3881214c7296c662ca40d5a..4970c5aa5859606a7291d2bb41354ce0f4d13164 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<volScalarField> coeff(const tmp<volScalarField>& 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 8c2291136f45f7163d84015c3df9d246d433449b..b6c462e50f709fd80ba16f25d7cf00303226ac43 100644 --- a/src/postProcessing/functionObjects/field/vorticity/vorticity.C +++ b/src/postProcessing/functionObjects/field/vorticity/vorticity.C @@ -45,28 +45,9 @@ namespace functionObjects } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::vorticity::vorticity -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - fieldExpression(name, runTime, dict, "U", "vorticity") -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::vorticity::~vorticity() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::vorticity::execute(const bool postProcess) +bool Foam::functionObjects::vorticity::calc() { if (foundField<volVectorField>(fieldName_)) { @@ -85,4 +66,23 @@ bool Foam::functionObjects::vorticity::execute(const bool postProcess) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::vorticity::vorticity +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, "U", "vorticity") +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::vorticity::~vorticity() +{} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/vorticity/vorticity.H b/src/postProcessing/functionObjects/field/vorticity/vorticity.H index 13c1f096f6982f66163305f1507fa50af84e39d2..44a0b1016382b1e8a079cfd4937c37c50b5a8c13 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); };