From f83975a70103e06ed361ab958a8b5c7034084236 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 2 May 2016 16:28:24 +0100 Subject: [PATCH] functionObjects: Moved into the functionObjects namespace and rationalized and simplified failable construction Rather than requiring each functionObject to handle failed construction internally (using the active_ flag) the static member function "viable" is provided which returns true if construction of the functionObject is likely to be successful. Failed construction is then handled by the wrapper-class which constructs the functionObject, e.g. "OutputFilterFunctionObject". --- .../dsmcFieldsCalc/dsmcFieldsCalc.C | 2 +- .../dynamicCode/functionObjectTemplate.C | 14 +- .../dynamicCode/functionObjectTemplate.H | 12 +- .../functionObject/FUNCTIONOBJECT.C | 12 +- .../IOOutputFilter/IOOutputFilter.C | 51 +- .../IOOutputFilter/IOOutputFilter.H | 27 +- .../OutputFilterFunctionObject.C | 64 +- .../OutputFilterFunctionObject.H | 2 +- .../derived/rotorDiskSource/rotorDiskSource.C | 1 - .../IO/partialWrite/partialWrite.C | 16 +- .../IO/partialWrite/partialWrite.H | 8 +- .../removeRegisteredObject.C | 8 +- .../removeRegisteredObject.H | 8 +- .../IO/writeDictionary/writeDictionary.C | 8 +- .../IO/writeDictionary/writeDictionary.H | 8 +- .../writeRegisteredObject.C | 8 +- .../writeRegisteredObject.H | 8 +- .../cloud/cloudInfo/cloudInfo.C | 75 +- .../cloud/cloudInfo/cloudInfo.H | 11 +- .../fieldAverage/IOFieldAverage.H | 4 +- .../fieldAverage/fieldAverage/fieldAverage.C | 145 ++- .../fieldAverage/fieldAverage/fieldAverage.H | 23 +- .../fieldAverage/fieldAverageTemplates.C | 41 +- .../fieldAverageFunctionObject.H | 4 +- .../fieldAverageItem/fieldAverageItem.C | 55 +- .../fieldAverageItem/fieldAverageItem.H | 24 +- .../fieldAverageItem/fieldAverageItemIO.C | 30 +- .../fieldCoordinateSystemTransform.C | 133 ++- .../fieldCoordinateSystemTransform.H | 19 +- ...dCoordinateSystemTransformFunctionObject.H | 8 +- .../fieldCoordinateSystemTransformTemplates.C | 6 +- .../field/fieldMinMax/fieldMinMax.C | 128 ++- .../field/fieldMinMax/fieldMinMax.H | 19 +- .../fieldMinMax/fieldMinMaxFunctionObject.H | 4 +- .../field/fieldMinMax/fieldMinMaxTemplates.C | 4 +- .../field/fieldValues/cellSource/cellSource.C | 214 +++-- .../field/fieldValues/cellSource/cellSource.H | 33 +- .../cellSource/cellSourceFunctionObject.H | 8 +- .../fieldValues/cellSource/cellSourceI.H | 9 +- .../cellSource/cellSourceTemplates.C | 24 +- .../field/fieldValues/faceSource/faceSource.C | 286 +++--- .../field/fieldValues/faceSource/faceSource.H | 33 +- .../faceSource/faceSourceFunctionObject.H | 8 +- .../fieldValues/faceSource/faceSourceI.H | 13 +- .../faceSource/faceSourceTemplates.C | 30 +- .../field/fieldValues/fieldValue/fieldValue.C | 52 +- .../field/fieldValues/fieldValue/fieldValue.H | 6 - .../fieldValues/fieldValue/fieldValueI.H | 8 +- .../fieldValueDelta/fieldValueDelta.C | 154 +-- .../fieldValueDelta/fieldValueDelta.H | 34 +- .../fieldValueDeltaFunctionObject.H | 8 +- .../fieldValueDeltaTemplates.C | 7 +- .../field/histogram/histogram.C | 198 ++-- .../field/histogram/histogram.H | 9 +- .../field/nearWallFields/nearWallFields.C | 290 +++--- .../field/nearWallFields/nearWallFields.H | 19 +- .../nearWallFieldsFunctionObject.H | 4 +- .../nearWallFields/nearWallFieldsTemplates.C | 6 +- .../field/processorField/processorField.C | 122 ++- .../field/processorField/processorField.H | 19 +- .../processorFieldFunctionObject.H | 4 +- .../field/readFields/readFields.C | 121 ++- .../field/readFields/readFields.H | 19 +- .../readFields/readFieldsFunctionObject.H | 4 +- .../field/readFields/readFieldsTemplates.C | 2 +- .../regionSizeDistribution.C | 896 +++++++++--------- .../regionSizeDistribution.H | 19 +- .../regionSizeDistributionFunctionObject.H | 4 +- .../regionSizeDistributionTemplates.C | 5 +- .../field/streamLine/streamLine.C | 689 +++++++------- .../field/streamLine/streamLine.H | 23 +- .../streamLine/streamLineFunctionObject.H | 4 +- .../surfaceInterpolateFields.C | 163 ++-- .../surfaceInterpolateFields.H | 17 +- .../surfaceInterpolateFieldsFunctionObject.H | 8 +- .../surfaceInterpolateFieldsTemplates.C | 2 +- .../wallBoundedStreamLine.C | 676 +++++++------ .../wallBoundedStreamLine.H | 23 +- .../wallBoundedStreamLineFunctionObject.H | 4 +- .../forces/forceCoeffs/forceCoeffs.C | 45 +- .../forces/forceCoeffs/forceCoeffs.H | 8 +- .../functionObjects/forces/forces/forces.C | 280 +++--- .../functionObjects/forces/forces/forces.H | 11 +- .../fvTools/calcFvcDiv/calcFvcDiv.C | 102 +- .../fvTools/calcFvcDiv/calcFvcDiv.H | 21 +- .../calcFvcDiv/calcFvcDivFunctionObject.H | 5 +- .../fvTools/calcFvcDiv/calcFvcDivTemplates.C | 4 +- .../fvTools/calcFvcGrad/calcFvcGrad.C | 100 +- .../fvTools/calcFvcGrad/calcFvcGrad.H | 21 +- .../calcFvcGrad/calcFvcGradFunctionObject.H | 5 +- .../calcFvcGrad/calcFvcGradTemplates.C | 8 +- .../functionObjects/fvTools/calcMag/calcMag.C | 106 +-- .../functionObjects/fvTools/calcMag/calcMag.H | 21 +- .../fvTools/calcMag/calcMagFunctionObject.H | 5 +- .../fvTools/calcMag/calcMagTemplates.C | 6 +- .../abortCalculation/abortCalculation.C | 78 +- .../abortCalculation/abortCalculation.H | 18 +- .../abortCalculationFunctionObject.H | 4 +- .../functionObjects/systemCall/systemCall.C | 37 +- .../functionObjects/systemCall/systemCall.H | 16 +- .../systemCall/systemCallFunctionObject.H | 4 +- .../utilities/CourantNo/CourantNo.C | 136 ++- .../utilities/CourantNo/CourantNo.H | 19 +- .../CourantNo/CourantNoFunctionObject.H | 5 +- .../utilities/CourantNo/IOCourantNo.H | 4 +- .../utilities/Lambda2/IOLambda2.H | 4 +- .../utilities/Lambda2/Lambda2.C | 139 ++- .../utilities/Lambda2/Lambda2.H | 21 +- .../utilities/Lambda2/Lambda2FunctionObject.H | 5 +- .../utilities/Peclet/IOPeclet.H | 4 +- .../functionObjects/utilities/Peclet/Peclet.C | 251 +++-- .../functionObjects/utilities/Peclet/Peclet.H | 21 +- .../utilities/Peclet/PecletFunctionObject.H | 5 +- .../functionObjects/utilities/Q/Q.C | 133 ++- .../functionObjects/utilities/Q/Q.H | 21 +- .../utilities/Q/QFunctionObject.H | 5 +- .../blendingFactor/IOblendingFactor.H | 4 +- .../utilities/blendingFactor/blendingFactor.C | 86 +- .../utilities/blendingFactor/blendingFactor.H | 22 +- .../blendingFactorFunctionObject.H | 4 +- .../blendingFactor/blendingFactorTemplates.C | 4 +- .../utilities/dsmcFields/dsmcFields.C | 372 ++++---- .../utilities/dsmcFields/dsmcFields.H | 22 +- .../dsmcFields/dsmcFieldsFunctionObject.H | 4 +- .../utilities/pressureTools/IOpressureTools.H | 4 +- .../utilities/pressureTools/pressureTools.C | 209 ++-- .../utilities/pressureTools/pressureTools.H | 21 +- .../pressureToolsFunctionObject.H | 4 +- .../utilities/residuals/IOresiduals.H | 4 +- .../utilities/residuals/residuals.C | 76 +- .../utilities/residuals/residuals.H | 19 +- .../residuals/residualsFunctionObject.H | 4 +- .../utilities/residuals/residualsTemplates.C | 4 +- .../scalarTransport/IOscalarTransport.H | 5 +- .../scalarTransport/scalarTransport.C | 34 +- .../scalarTransport/scalarTransport.H | 16 +- .../scalarTransportFunctionObject.H | 4 +- .../IOtimeActivatedFileUpdate.H | 5 +- .../timeActivatedFileUpdate.C | 94 +- .../timeActivatedFileUpdate.H | 19 +- .../timeActivatedFileUpdateFunctionObject.H | 4 +- .../turbulenceFields/IOturbulenceFields.H | 5 +- .../turbulenceFields/turbulenceFields.C | 176 ++-- .../turbulenceFields/turbulenceFields.H | 19 +- .../turbulenceFieldsFunctionObject.H | 4 +- .../turbulenceFieldsTemplates.C | 2 +- .../utilities/vorticity/IOvorticity.H | 4 +- .../utilities/vorticity/vorticity.C | 126 ++- .../utilities/vorticity/vorticity.H | 21 +- .../vorticity/vorticityFunctionObject.H | 5 +- .../wallShearStress/IOwallShearStress.H | 4 +- .../wallShearStress/wallShearStress.C | 265 +++--- .../wallShearStress/wallShearStress.H | 19 +- .../wallShearStressFunctionObject.H | 4 +- .../functionObjects/utilities/yPlus/IOyPlus.H | 4 +- .../functionObjects/utilities/yPlus/yPlus.C | 169 ++-- .../functionObjects/utilities/yPlus/yPlus.H | 19 +- .../utilities/yPlus/yPlusFunctionObject.H | 5 +- .../utilities/yPlus/yPlusTemplates.C | 2 +- .../pyrolysisModels/noPyrolysis/noPyrolysis.C | 10 +- .../meshToMesh0/meshToMesh0Templates.C | 1 - src/sampling/probes/patchProbes.C | 12 + src/sampling/probes/patchProbes.H | 10 + src/sampling/probes/probes.C | 24 +- src/sampling/probes/probes.H | 10 + .../sampledSet/sampledSets/sampledSets.C | 24 +- .../sampledSet/sampledSets/sampledSets.H | 10 + .../sampledSurfaces/sampledSurfaces.C | 27 +- .../sampledSurfaces/sampledSurfaces.H | 10 + ...veViewFactorFixedValueFvPatchScalarField.C | 2 - .../radiationModels/noRadiation/noRadiation.C | 4 +- .../radiationModels/opaqueSolid/opaqueSolid.C | 4 +- .../submodels/sootModel/noSoot/noSoot.C | 6 +- .../moleFractions/moleFractions.C | 14 + .../moleFractions/moleFractions.H | 10 + 175 files changed, 4667 insertions(+), 4353 deletions(-) diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C index 6059ebf5a..ecd4b4f1e 100644 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C +++ b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C @@ -138,7 +138,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) return; } - dsmcFields dF + functionObjects::dsmcFields dF ( "dsmcFieldsUtility", mesh, diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index 91b31dda2..cb256b9b9 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -76,6 +76,18 @@ ${typeName}FunctionObject::${typeName}FunctionObject } +bool ${typeName}FunctionObject::viable +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool +) +{ + return true; +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // ${typeName}FunctionObject::~${typeName}FunctionObject() diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H index a139f25a8..b1f7e7af8 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -102,6 +102,16 @@ public: const bool loadFromFilesUnused = false ); + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + static bool viable + ( + const word& name, + const objectRegistry& unused, + const dictionary&, + const bool loadFromFilesUnused = false + ); + //- Destructor virtual ~${typeName}FunctionObject(); diff --git a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C index 68189c6d4..5c480baee 100644 --- a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C +++ b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C @@ -71,21 +71,15 @@ void Foam::FUNCTIONOBJECT::read(const dictionary& dict) void Foam::FUNCTIONOBJECT::execute() -{ - // Do nothing - only valid on write -} +{} void Foam::FUNCTIONOBJECT::end() -{ - // Do nothing - only valid on write -} +{} void Foam::FUNCTIONOBJECT::timeSet() -{ - // Do nothing - only valid on write -} +{} void Foam::FUNCTIONOBJECT::write() diff --git a/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C index 18b46f29a..e70e55a1b 100644 --- a/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C +++ b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,6 +66,32 @@ Foam::IOOutputFilter::IOOutputFilter {} +template +bool Foam::IOOutputFilter::viable +( + const word& outputFilterName, + const objectRegistry& obr, + const word& dictName, + const IOobject::readOption rOpt, + const bool readFromFiles +) +{ + IOdictionary dict + ( + IOobject + ( + dictName, + obr.time().system(), + obr, + rOpt, + IOobject::NO_WRITE + ) + ); + + return OutputFilter::viable(outputFilterName, obr, dict, readFromFiles); +} + + template Foam::IOOutputFilter::IOOutputFilter ( @@ -99,6 +125,13 @@ Foam::IOOutputFilter::~IOOutputFilter() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +const Foam::word& Foam::IOOutputFilter::name() const +{ + return IOdictionary::name(); +} + + template bool Foam::IOOutputFilter::read() { @@ -121,4 +154,20 @@ void Foam::IOOutputFilter::write() } +template +void Foam::IOOutputFilter::updateMesh(const mapPolyMesh& mpm) +{ + read(); + OutputFilter::updateMesh(mpm); +} + + +template +void Foam::IOOutputFilter::movePoints(const polyMesh& mesh) +{ + read(); + OutputFilter::movePoints(mesh); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H index 77b248f7e..6950b523f 100644 --- a/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H +++ b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H @@ -94,6 +94,16 @@ public: const bool loadFromFile = false ); + //- Return true if the construction of this functionObject is viable + static bool viable + ( + const word& outputFilterName, + const objectRegistry&, + const word& dictName = OutputFilter::typeName() + "Dict", + const IOobject::readOption rOpt = IOobject::MUST_READ_IF_MODIFIED, + const bool loadFromFiles = false + ); + //- Construct for given objectRegistry and dictionary // Dictionary read from full path. // Allow the possibility to load fields from files @@ -114,10 +124,7 @@ public: // Member Functions //- Return name - virtual const word& name() const - { - return IOdictionary::name(); - } + virtual const word& name() const; //- Inherit read from OutputFilter using OutputFilter::read; @@ -132,18 +139,10 @@ public: virtual void write(); //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh& mpm) - { - read(); - OutputFilter::updateMesh(mpm); - } + virtual void updateMesh(const mapPolyMesh& mpm); //- Update for changes of mesh - virtual void movePoints(const polyMesh& mesh) - { - read(); - OutputFilter::movePoints(mesh); - } + virtual void movePoints(const polyMesh& mesh); }; diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C index 100e88f27..7c81faefc 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,32 +55,64 @@ bool Foam::OutputFilterFunctionObject::active() const template -void Foam::OutputFilterFunctionObject::allocateFilter() +bool Foam::OutputFilterFunctionObject::allocateFilter() { if (dictName_.size()) { - ptr_.reset + if ( - new IOOutputFilter + IOOutputFilter::viable ( name(), time_.lookupObject(regionName_), dictName_ ) - ); + ) + { + ptr_.reset + ( + new IOOutputFilter + ( + name(), + time_.lookupObject(regionName_), + dictName_ + ) + ); + } + else + { + enabled_ = false; + } } else { - ptr_.reset + if ( - new OutputFilter + OutputFilter::viable ( name(), time_.lookupObject(regionName_), dict_ ) - ); + ) + { + ptr_.reset + ( + new OutputFilter + ( + name(), + time_.lookupObject(regionName_), + dict_ + ) + ); + } + else + { + enabled_ = false; + } } + + return enabled_; } @@ -144,10 +176,12 @@ bool Foam::OutputFilterFunctionObject::start() if (enabled_ && storeFilter_) { - allocateFilter(); + return allocateFilter(); + } + else + { + return true; } - - return true; } @@ -159,9 +193,9 @@ bool Foam::OutputFilterFunctionObject::execute { if (active()) { - if (!storeFilter_) + if (!storeFilter_ && !allocateFilter()) { - allocateFilter(); + return false; } if (evaluateControl_.output()) @@ -189,9 +223,9 @@ bool Foam::OutputFilterFunctionObject::end() { if (enabled_) { - if (!storeFilter_) + if (!storeFilter_ && !allocateFilter()) { - allocateFilter(); + return false; } ptr_->end(); diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index cf97dc562..5cd592ee8 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -111,7 +111,7 @@ class OutputFilterFunctionObject void readDict(); //- Creates most of the data associated with this object. - void allocateFilter(); + bool allocateFilter(); //- Destroys most of the data associated with this object. void destroyFilter(); diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index 33757db42..821a6cc01 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -96,7 +96,6 @@ void Foam::fv::rotorDiskSource::checkData() } case ifLocal: { - // Do nothing break; } default: diff --git a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C index c04f6eca2..3d5faaf96 100644 --- a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C +++ b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C @@ -58,8 +58,7 @@ Foam::functionObjects::partialWrite::partialWrite } -Foam::autoPtr -Foam::functionObjects::partialWrite::New +bool Foam::functionObjects::partialWrite::viable ( const word& name, const objectRegistry& obr, @@ -67,17 +66,8 @@ Foam::functionObjects::partialWrite::New const bool loadFromFiles ) { - if (isA(obr)) - { - return autoPtr - ( - new partialWrite(name, obr, dict, loadFromFiles) - ); - } - else - { - return autoPtr(); - } + // Construction is viable if the available mesh is an fvMesh + return isA(obr); } diff --git a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H index a49aabc12..76a18f5fb 100644 --- a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H +++ b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::partialWrite + Foam::functionObjects::partialWrite Group grpIOFunctionObjects @@ -171,9 +171,9 @@ public: const bool loadFromFiles = false ); - //- Construct on free-store and return pointer if successful - // otherwise return a null-pointer - static autoPtr New + //- Return true if the construction of this functionObject is viable + // i.e. the prerequisites for construction are available + static bool viable ( const word& name, const objectRegistry&, diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C index ea296544c..9bd09cd0b 100644 --- a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C @@ -56,8 +56,7 @@ Foam::functionObjects::removeRegisteredObject::removeRegisteredObject } -Foam::autoPtr -Foam::functionObjects::removeRegisteredObject::New +bool Foam::functionObjects::removeRegisteredObject::viable ( const word& name, const objectRegistry& obr, @@ -65,10 +64,7 @@ Foam::functionObjects::removeRegisteredObject::New const bool loadFromFiles ) { - return autoPtr - ( - new removeRegisteredObject(name, obr, dict, loadFromFiles) - ); + return true; } diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H index 860a2e986..5bbb16d92 100644 --- a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::removeRegisteredObject + Foam::functionObjects::removeRegisteredObject Group grpIOFunctionObjects @@ -128,9 +128,9 @@ public: const bool loadFromFiles = false ); - //- Construct on free-store and return pointer if successful - // otherwise return a null-pointer - static autoPtr New + //- Return true if the construction of this functionObject is viable + // i.e. the prerequisites for construction are available + static bool viable ( const word& name, const objectRegistry&, diff --git a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C index 7acd2abef..afe37cf4a 100644 --- a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C +++ b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C @@ -107,8 +107,7 @@ Foam::functionObjects::writeDictionary::writeDictionary } -Foam::autoPtr -Foam::functionObjects::writeDictionary::New +bool Foam::functionObjects::writeDictionary::viable ( const word& name, const objectRegistry& obr, @@ -116,10 +115,7 @@ Foam::functionObjects::writeDictionary::New const bool loadFromFiles ) { - return autoPtr - ( - new writeDictionary(name, obr, dict, loadFromFiles) - ); + return true; } diff --git a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H index 19d42766e..3f822fa89 100644 --- a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H +++ b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::writeDictionary + Foam::functionObjects::writeDictionary Group grpUtilitiesFunctionObjects @@ -120,9 +120,9 @@ public: const bool loadFromFiles = false ); - //- Construct on free-store and return pointer if successful - // otherwise return a null-pointer - static autoPtr New + //- Return true if the construction of this functionObject is viable + // i.e. the prerequisites for construction are available + static bool viable ( const word& name, const objectRegistry&, diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C index ad68d6b9a..6385ad89b 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C @@ -57,8 +57,7 @@ Foam::functionObjects::writeRegisteredObject::writeRegisteredObject } -Foam::autoPtr -Foam::functionObjects::writeRegisteredObject::New +bool Foam::functionObjects::writeRegisteredObject::viable ( const word& name, const objectRegistry& obr, @@ -66,10 +65,7 @@ Foam::functionObjects::writeRegisteredObject::New const bool loadFromFiles ) { - return autoPtr - ( - new writeRegisteredObject(name, obr, dict, loadFromFiles) - ); + return true; } diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H index 37bb625c4..8fb674a88 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::writeRegisteredObject + Foam::functionObjects::writeRegisteredObject Group grpIOFunctionObjects @@ -143,9 +143,9 @@ public: const bool loadFromFiles = false ); - //- Construct on free-store and return pointer if successful - // otherwise return a null-pointer - static autoPtr New + //- Return true if the construction of this functionObject is viable + // i.e. the prerequisites for construction are available + static bool viable ( const word& name, const objectRegistry&, diff --git a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C index f17f36684..7641bf5c0 100644 --- a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C +++ b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C @@ -62,15 +62,13 @@ Foam::functionObjects::cloudInfo::cloudInfo : functionObjectFiles(obr, name), name_(name), - obr_(obr), - active_(true) + obr_(obr) { read(dict); } -Foam::autoPtr -Foam::functionObjects::cloudInfo::New +bool Foam::functionObjects::cloudInfo::viable ( const word& name, const objectRegistry& obr, @@ -78,10 +76,7 @@ Foam::functionObjects::cloudInfo::New const bool loadFromFiles ) { - return autoPtr - ( - new cloudInfo(name, obr, dict, loadFromFiles) - ); + return true; } @@ -95,24 +90,21 @@ Foam::functionObjects::cloudInfo::~cloudInfo() void Foam::functionObjects::cloudInfo::read(const dictionary& dict) { - if (active_) - { - functionObjectFiles::resetNames(dict.lookup("clouds")); + functionObjectFiles::resetNames(dict.lookup("clouds")); - Info<< type() << " " << name_ << ": "; - if (names().size()) + Info<< type() << " " << name_ << ": "; + if (names().size()) + { + Info<< "applying to clouds:" << nl; + forAll(names(), i) { - Info<< "applying to clouds:" << nl; - forAll(names(), i) - { - Info<< " " << names()[i] << nl; - } - Info<< endl; - } - else - { - Info<< "no clouds to be processed" << nl << endl; + Info<< " " << names()[i] << nl; } + Info<< endl; + } + else + { + Info<< "no clouds to be processed" << nl << endl; } } @@ -131,29 +123,26 @@ void Foam::functionObjects::cloudInfo::timeSet() void Foam::functionObjects::cloudInfo::write() { - if (active_) + functionObjectFiles::write(); + + forAll(names(), i) { - functionObjectFiles::write(); + const word& cloudName = names()[i]; - forAll(names(), i) + const kinematicCloud& cloud = + obr_.lookupObject(cloudName); + + label nParcels = returnReduce(cloud.nParcels(), sumOp