From fee6e312b928e73f6acb195df2f1e49c7ae17d66 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 17 Feb 2009 12:48:10 +0100 Subject: [PATCH] Time and functionObject updated for end() - added end() method to functionObject, functionObjectList & associated classes - moved outputFilters from src/sampling -> src/OpenFOAM/db/functionObjects --- src/OpenFOAM/Make/files | 7 ++- src/OpenFOAM/db/Time/Time.C | 7 +-- src/OpenFOAM/db/Time/Time.H | 34 +++++++---- .../IOOutputFilter/IOOutputFilter.C | 0 .../IOOutputFilter/IOOutputFilter.H | 0 .../OutputFilterFunctionObject.C | 31 +++++++--- .../OutputFilterFunctionObject.H | 21 ++++--- .../functionObject/functionObject.C | 6 ++ .../functionObject/functionObject.H | 8 ++- .../functionObjectList/functionObjectList.C | 57 +++++++++++-------- .../functionObjectList/functionObjectList.H | 18 +++--- .../outputFilterOutputControl.C | 0 .../outputFilterOutputControl.H | 0 .../fieldAverage/fieldAverage/fieldAverage.C | 9 +++ .../fieldAverage/fieldAverage/fieldAverage.H | 5 +- .../fieldAverageItem/fieldAverageItemIO.C | 6 +- .../field/fieldMinMax/fieldMinMax.C | 7 +++ .../field/fieldMinMax/fieldMinMax.H | 15 +++-- .../forces/forceCoeffs/forceCoeffs.C | 6 ++ .../forces/forceCoeffs/forceCoeffs.H | 5 +- .../functionObjects/forces/forces/forces.C | 7 +++ .../functionObjects/forces/forces/forces.H | 5 +- .../functionObjects/systemCall/systemCall.C | 29 ++++++++-- .../functionObjects/systemCall/systemCall.H | 19 ++++--- .../dynamicPressure/dynamicPressure.C | 14 +++-- .../dynamicPressure/dynamicPressure.H | 9 ++- src/sampling/Make/files | 2 - src/sampling/probes/probes.C | 6 ++ src/sampling/probes/probes.H | 9 ++- .../sampledSet/sampledSets/sampledSets.C | 6 ++ .../sampledSet/sampledSets/sampledSets.H | 5 +- .../isoSurface/sampledIsoSurface.C | 2 +- .../isoSurface/sampledIsoSurface.H | 2 +- .../sampledSurfaces/sampledSurfaces.C | 7 ++- .../sampledSurfaces/sampledSurfaces.H | 5 +- 35 files changed, 255 insertions(+), 114 deletions(-) rename src/{sampling/outputFilters => OpenFOAM/db/functionObjects}/IOOutputFilter/IOOutputFilter.C (100%) rename src/{sampling/outputFilters => OpenFOAM/db/functionObjects}/IOOutputFilter/IOOutputFilter.H (100%) rename src/{sampling/outputFilters => OpenFOAM/db/functionObjects}/OutputFilterFunctionObject/OutputFilterFunctionObject.C (93%) rename src/{sampling/outputFilters => OpenFOAM/db/functionObjects}/OutputFilterFunctionObject/OutputFilterFunctionObject.H (92%) rename src/OpenFOAM/db/{ => functionObjects}/functionObject/functionObject.C (98%) rename src/OpenFOAM/db/{ => functionObjects}/functionObject/functionObject.H (94%) rename src/OpenFOAM/db/{ => functionObjects}/functionObjectList/functionObjectList.C (93%) rename src/OpenFOAM/db/{ => functionObjects}/functionObjectList/functionObjectList.H (91%) rename src/{sampling/outputFilters => OpenFOAM/db/functionObjects}/outputFilterOutputControl/outputFilterOutputControl.C (100%) rename src/{sampling/outputFilters => OpenFOAM/db/functionObjects}/outputFilterOutputControl/outputFilterOutputControl.H (100%) diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 92c81085ab..833be5ccd5 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -144,11 +144,14 @@ $(regIOobject)/regIOobjectWrite.C db/IOobjectList/IOobjectList.C db/objectRegistry/objectRegistry.C -db/functionObject/functionObject.C -db/functionObjectList/functionObjectList.C db/CallbackRegistry/CallbackRegistryName.C db/dlLibraryTable/dlLibraryTable.C +db/functionObjects/functionObject/functionObject.C +db/functionObjects/functionObjectList/functionObjectList.C +db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C + + Time = db/Time $(Time)/TimePaths.C $(Time)/TimeState.C diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index d157501506..f52303220f 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -498,8 +498,8 @@ bool Foam::Time::run() const // ie, when exiting the control loop if (!running && timeIndex_ != startTimeIndex_) { - // Note, the execute() also calls an indirect start() if required - functionObjects_.execute(); + // Note, end() also calls an indirect start() as required + functionObjects_.end(); } } @@ -509,8 +509,7 @@ bool Foam::Time::run() const bool Foam::Time::end() const { - bool done = value() > (endTime_ + 0.5*deltaT_); - return done; + return value() > (endTime_ + 0.5*deltaT_); } diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 3cb65583b2..70f6985b41 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -348,16 +348,28 @@ public: // Check - //- Return true if run should continue - // @sa end() + //- Return true if run should continue, + // also invokes the functionObjectList::end() method + // when the time goes out of range // @note - // the rounding heuristics near endTime mean that - // @code run() @endcode and @code !end() @endcode may - // not yield the same result + // For correct baheviour, the following style of time-loop + // is recommended: + // @code + // while (runTime.run()) + // { + // runTime++; + // solve; + // runTime.write(); + // } + // @endcode virtual bool run() const; - //- Return true if end of run - // @sa run() + //- Return true if end of run, + // does not invoke any functionObject methods + // @note + // The rounding heuristics near endTime mean that + // @code run() @endcode and @code !end() @endcode may + // not yield the same result virtual bool end() const; @@ -406,13 +418,15 @@ public: // Member operators - //- Set deltaT to that specified and increment time + //- Set deltaT to that specified and increment time via operator++() virtual Time& operator+=(const dimensionedScalar&); - //- Set deltaT to that specified and increment time + //- Set deltaT to that specified and increment time via operator++() virtual Time& operator+=(const scalar); - //- Prefix increment + //- Prefix increment, + // also invokes the functionObjectList::start() or + // functionObjectList::execute() method, depending on the time-index virtual Time& operator++(); //- Postfix increment, this is identical to the prefix increment diff --git a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C similarity index 100% rename from src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C rename to src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C diff --git a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H similarity index 100% rename from src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H rename to src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H diff --git a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C similarity index 93% rename from src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C rename to src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C index 45305257e9..15a32c1e8e 100644 --- a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -65,6 +65,20 @@ Foam::OutputFilterFunctionObject::OutputFilterFunctionObject // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +void Foam::OutputFilterFunctionObject::on() +{ + enabled_ = true; +} + + +template +void Foam::OutputFilterFunctionObject::off() +{ + enabled_ = false; +} + + template bool Foam::OutputFilterFunctionObject::start() { @@ -120,16 +134,19 @@ bool Foam::OutputFilterFunctionObject::execute() template -void Foam::OutputFilterFunctionObject::on() +bool Foam::OutputFilterFunctionObject::end() { - enabled_ = true; -} + if (enabled_) + { + ptr_->end(); + if (enabled_ && outputControl_.output()) + { + ptr_->write(); + } + } -template -void Foam::OutputFilterFunctionObject::off() -{ - enabled_ = false; + return true; } diff --git a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H similarity index 92% rename from src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.H rename to src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index 80ee33cf81..5ab4ebbece 100644 --- a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -53,7 +53,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class OutputFilterFunctionObject Declaration + Class OutputFilterFunctionObject Declaration \*---------------------------------------------------------------------------*/ template @@ -69,7 +69,7 @@ class OutputFilterFunctionObject word regionName_; word dictName_; - //- Switch for the execution of the functionObjects + //- Switch for the execution of the functionObject bool enabled_; outputFilterOutputControl outputControl_; @@ -114,18 +114,23 @@ public: return name_; } - //- start is called at the start of the time-loop - virtual bool start(); - - //- execute is called at each ++ or += of the time-loop - virtual bool execute(); - //- Switch the function object on virtual void on(); //- Switch the function object off virtual void off(); + + //- Called at the start of the time-loop + virtual bool start(); + + //- Called at each ++ or += of the time-loop + virtual bool execute(); + + //- Called when Time::run() determines that the time-loop exits + virtual bool end(); + + //- Read and set the function object if its data have changed virtual bool read(const dictionary&); }; diff --git a/src/OpenFOAM/db/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C similarity index 98% rename from src/OpenFOAM/db/functionObject/functionObject.C rename to src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index 29ee48342b..a731621ff6 100644 --- a/src/OpenFOAM/db/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -103,6 +103,12 @@ Foam::functionObject::~functionObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +bool Foam::functionObject::end() +{ + return execute(); +} + + Foam::autoPtr Foam::functionObject::iNew::operator() ( const word& name, diff --git a/src/OpenFOAM/db/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H similarity index 94% rename from src/OpenFOAM/db/functionObject/functionObject.H rename to src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 268bf128e4..94a2f7aea4 100644 --- a/src/OpenFOAM/db/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -137,12 +137,16 @@ public: // Member Functions - //- start is called at the start of the time-loop + //- Called at the start of the time-loop virtual bool start() = 0; - //- execute is called at each ++ or += of the time-loop + //- Called at each ++ or += of the time-loop virtual bool execute() = 0; + //- Called when Time::run() determines that the time-loop exits. + // By default it simply calls execute(). + virtual bool end(); + //- Read and set the function object if its data have changed virtual bool read(const dictionary&) = 0; }; diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C similarity index 93% rename from src/OpenFOAM/db/functionObjectList/functionObjectList.C rename to src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 1ca37e02e3..0e52db7fc7 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -142,7 +142,12 @@ bool Foam::functionObjectList::execute() read(); } - forAllIter(PtrList, *this, iter) + forAllIter + ( + PtrList, + static_cast&>(*this), + iter + ) { ok = iter().execute() && ok; } @@ -152,6 +157,32 @@ bool Foam::functionObjectList::execute() } +bool Foam::functionObjectList::end() +{ + bool ok = true; + + if (execution_) + { + if (!updated_) + { + read(); + } + + forAllIter + ( + PtrList, + static_cast&>(*this), + iter + ) + { + ok = iter().end() && ok; + } + } + + return ok; +} + + bool Foam::functionObjectList::read() { bool ok = true; @@ -279,28 +310,4 @@ bool Foam::functionObjectList::read() } -bool Foam::functionObjectList::manualStart() -{ - bool state = execution_; - execution_ = true; - - bool ret = start(); - - execution_ = state; - return ret; -} - - -bool Foam::functionObjectList::manualExecute() -{ - bool state = execution_; - execution_ = true; - - bool ret = execute(); - - execution_ = state; - return ret; -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H similarity index 91% rename from src/OpenFOAM/db/functionObjectList/functionObjectList.H rename to src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 374e23775b..ea2c43adf3 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -26,8 +26,8 @@ Class Foam::functionObjectList Description - List of function objects with execute() function that is called for each - object. + List of function objects with start(), execute() and end() functions + that is called for each object. See Also Foam::functionObject and Foam::OutputFilterFunctionObject @@ -147,22 +147,18 @@ public: virtual bool status() const; - //- Start is called at the start of the time-loop + //- Called at the start of the time-loop virtual bool start(); - //- Execute is called at each ++ or += of the time-loop + //- Called at each ++ or += of the time-loop virtual bool execute(); + //- Called when Time::run() determines that the time-loop exits + virtual bool end(); + //- Read and set the function objects if their data have changed virtual bool read(); - - //- Call start() manually regardless of the execution status - virtual bool manualStart(); - - //- Call execute() manually regardless of the execution status - virtual bool manualExecute(); - }; diff --git a/src/sampling/outputFilters/outputFilterOutputControl/outputFilterOutputControl.C b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C similarity index 100% rename from src/sampling/outputFilters/outputFilterOutputControl/outputFilterOutputControl.C rename to src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C diff --git a/src/sampling/outputFilters/outputFilterOutputControl/outputFilterOutputControl.H b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.H similarity index 100% rename from src/sampling/outputFilters/outputFilterOutputControl/outputFilterOutputControl.H rename to src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.H diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C index b9c4023401..b3ca4f6d4d 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C @@ -255,6 +255,15 @@ void Foam::fieldAverage::execute() } +void Foam::fieldAverage::end() +{ + if (active_) + { + calcAverages(); + } +} + + void Foam::fieldAverage::write() { if (active_) diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H index 2cb245b14d..435bb2746d 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H @@ -41,7 +41,7 @@ Description // averaging info if available cleanRestart true; - // Fields to be probed. runTime modifiable! + // Fields to be averaged. runTime modifiable! fields ( U @@ -281,6 +281,9 @@ public: //- Execute the averaging virtual void execute(); + //- Execute the averaging at the final time-loop + virtual void end(); + //- Calculate the field average data and write virtual void write(); }; diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C index 82c934e194..d149063b06 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C @@ -76,14 +76,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem) "(Foam::Ostream&, const Foam::fieldAverageItem&)" ); - os<< faItem.fieldName_ << nl; - os<< token::BEGIN_BLOCK << nl; + os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl; os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl; os.writeKeyword("prime2Mean") << faItem.mean_ << token::END_STATEMENT << nl; os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_] - << token::END_STATEMENT << nl; - os<< token::END_BLOCK << nl; + << token::END_STATEMENT << nl << token::END_BLOCK << nl; os.check ( diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C index 051f9f9a6d..509e483f2b 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -163,6 +163,13 @@ void Foam::fieldMinMax::execute() // Do nothing - only valid on write } + +void Foam::fieldMinMax::end() +{ + // Do nothing - only valid on write +} + + void Foam::fieldMinMax::write() { if (active_) diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H index 17cfcf54e3..812359f71c 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -80,8 +80,8 @@ protected: // Protected data - //- Name of this set of forces, - // Also used as the name of the probes directory. + //- Name of this set of field min/max. + // Also used as the name of the output directory. word name_; const objectRegistry& obr_; @@ -108,7 +108,7 @@ protected: // Private Member Functions - //- If the forces file has not been created create it + //- If the output file has not been created create it void makeFile(); //- Disallow default bitwise copy construct @@ -147,18 +147,21 @@ public: // Member Functions - //- Return name of the set of forces + //- Return name of the set of field min/max virtual const word& name() const { return name_; } - //- Read the forces data + //- Read the field min/max data virtual void read(const dictionary&); - //- Execute + //- Execute, currently does nothing virtual void execute(); + //- Execute at the final time-loop, currently does nothing + virtual void end(); + //- Calculate the field min/max template void calcMinMaxFields(const word& fieldName); diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index d76b7fdd28..5fe1b84670 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -104,6 +104,12 @@ void Foam::forceCoeffs::execute() } +void Foam::forceCoeffs::end() +{ + // Do nothing - only valid on write +} + + void Foam::forceCoeffs::write() { if (active_) diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H index 87e6cf47c8..d9a948db08 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H @@ -126,9 +126,12 @@ public: //- Read the forces data virtual void read(const dictionary&); - //- Execute + //- Execute, currently does nothing virtual void execute(); + //- Execute at the final time-loop, currently does nothing + virtual void end(); + //- Write the forces virtual void write(); }; diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 3ed12ef475..3fb9cc135a 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -273,6 +273,13 @@ void Foam::forces::execute() // Do nothing - only valid on write } + +void Foam::forces::end() +{ + // Do nothing - only valid on write +} + + void Foam::forces::write() { if (active_) diff --git a/src/postProcessing/functionObjects/forces/forces/forces.H b/src/postProcessing/functionObjects/forces/forces/forces.H index 08d9d09ce2..73edae9da1 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.H +++ b/src/postProcessing/functionObjects/forces/forces/forces.H @@ -200,9 +200,12 @@ public: //- Read the forces data virtual void read(const dictionary&); - //- Execute + //- Execute, currently does nothing virtual void execute(); + //- Execute at the final time-loop, currently does nothing + virtual void end(); + //- Write the forces virtual void write(); diff --git a/src/postProcessing/functionObjects/systemCall/systemCall.C b/src/postProcessing/functionObjects/systemCall/systemCall.C index f0cc9f9c08..6fdf84d70c 100644 --- a/src/postProcessing/functionObjects/systemCall/systemCall.C +++ b/src/postProcessing/functionObjects/systemCall/systemCall.C @@ -41,15 +41,14 @@ namespace Foam Foam::systemCall::systemCall ( const word& name, - const objectRegistry& obr, + const objectRegistry&, const dictionary& dict, - const bool loadFromFiles + const bool ) : name_(name), - obr_(obr), - active_(true), executeCalls_(), + endCalls_(), writeCalls_() { read(dict); @@ -66,8 +65,16 @@ Foam::systemCall::~systemCall() void Foam::systemCall::read(const dictionary& dict) { - dict.lookup("executeCalls") >> executeCalls_; - dict.lookup("writeCalls") >> writeCalls_; + dict.readIfPresent("executeCalls", executeCalls_); + dict.readIfPresent("endCalls", endCalls_); + dict.readIfPresent("writeCalls", writeCalls_); + + if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty()) + { + WarningIn("Foam::system::read(const dictionary&)") + << "no executeCalls, endCalls or writeCalls defined." + << endl; + } } @@ -79,6 +86,16 @@ void Foam::systemCall::execute() } } + +void Foam::systemCall::end() +{ + forAll(endCalls_, callI) + { + ::system(endCalls_[callI].c_str()); + } +} + + void Foam::systemCall::write() { forAll(writeCalls_, callI) diff --git a/src/postProcessing/functionObjects/systemCall/systemCall.H b/src/postProcessing/functionObjects/systemCall/systemCall.H index e516159b69..6dc8fed529 100644 --- a/src/postProcessing/functionObjects/systemCall/systemCall.H +++ b/src/postProcessing/functionObjects/systemCall/systemCall.H @@ -63,14 +63,12 @@ protected: //- Name of this set of system calls word name_; - const objectRegistry& obr_; - - //- on/off switch - bool active_; - //- List of calls to execute - every step stringList executeCalls_; + //- List of calls to execute when exiting the time-loop + stringList endCalls_; + //- List of calls to execute - write steps stringList writeCalls_; @@ -97,9 +95,9 @@ public: systemCall ( const word& name, - const objectRegistry&, + const objectRegistry& unused, const dictionary&, - const bool loadFromFiles = false + const bool loadFromFilesUnused = false ); @@ -119,10 +117,13 @@ public: //- Read the system calls virtual void read(const dictionary&); - //- Execute + //- Execute the "executeCalls" at each time-step virtual void execute(); - //- Write + //- Execute the "endCalls" at the final time-loop + virtual void end(); + + //- Write, execute the "writeCalls" virtual void write(); //- Update for changes of mesh diff --git a/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.C b/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.C index f5398a8441..a31c913ba7 100644 --- a/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.C +++ b/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.C @@ -58,7 +58,7 @@ Foam::dynamicPressure::dynamicPressure name_(name), obr_(obr), active_(true), - pName_(dict.lookup("p")), + pName_(dict.lookupOrDefault("p", "p")), rho_(readScalar(dict.lookup("rho"))) { // Check if the available mesh is an fvMesh, otherwise deactivate @@ -68,7 +68,7 @@ Foam::dynamicPressure::dynamicPressure WarningIn ( "dynamicPressure::dynamicPressure" - "(const objectRegistry& obr, const dictionary& dict)" + "(const objectRegistry&, const dictionary&)" ) << "No fvMesh available, deactivating." << nl << endl; } @@ -81,7 +81,7 @@ Foam::dynamicPressure::dynamicPressure WarningIn ( "dynamicPressure::dynamicPressure" - "(const objectRegistry& obr, const dictionary& dict)" + "(const objectRegistry&, const dictionary&)" ) << "Pressure is not kinematic pressure, deactivating." << nl << endl; } @@ -103,7 +103,7 @@ void Foam::dynamicPressure::read(const dictionary& dict) { if (active_) { - dict.lookup("p") >> pName_; + dict.readIfPresent("p", pName_); dict.lookup("rho") >> rho_; } } @@ -115,6 +115,12 @@ void Foam::dynamicPressure::execute() } +void Foam::dynamicPressure::end() +{ + // Do nothing - only valid on write +} + + void Foam::dynamicPressure::write() { if (active_) diff --git a/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.H b/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.H index cf7f5530f3..c3c6bdbb0f 100644 --- a/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.H +++ b/src/postProcessing/functionObjects/utilities/dynamicPressure/dynamicPressure.H @@ -66,10 +66,10 @@ class dynamicPressure //- on/off switch bool active_; - //- Name of pressure field + //- Name of pressure field, default is "p" word pName_; - //- Density + //- Density value scalar rho_; @@ -120,9 +120,12 @@ public: //- Read the dynamicPressure data virtual void read(const dictionary&); - //- Execute + //- Execute, currently does nothing virtual void execute(); + //- Execute at the final time-loop, currently does nothing + virtual void end(); + //- Calculate the dynamicPressure and write virtual void write(); diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 004f81d435..c528032519 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -48,8 +48,6 @@ graphField/writePatchGraph.C graphField/writeCellGraph.C graphField/makeGraph.C -outputFilters/outputFilterOutputControl/outputFilterOutputControl.C - meshToMesh = meshToMeshInterpolation/meshToMesh $(meshToMesh)/meshToMesh.C $(meshToMesh)/calculateMeshToMeshAddressing.C diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index f0596ea563..91c588c6d3 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -304,6 +304,12 @@ void Foam::probes::execute() } +void Foam::probes::end() +{ + // Do nothing - only valid on write +} + + void Foam::probes::write() { if (probeLocations_.size() && checkFieldTypes()) diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/probes.H index 27c2a9a3bb..33e4f39e25 100644 --- a/src/sampling/probes/probes.H +++ b/src/sampling/probes/probes.H @@ -194,15 +194,18 @@ public: return cellList_; } + //- Execute, currently does nothing + virtual void execute(); + + //- Execute at the final time-loop, currently does nothing + virtual void end(); + //- Sample and write virtual void write(); //- Read the probes virtual void read(const dictionary&); - //- Execute - virtual void execute(); - //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&) {} diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index f09a82e30a..621efba7a5 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -275,6 +275,12 @@ void Foam::sampledSets::execute() } +void Foam::sampledSets::end() +{ + // Do nothing - only valid on write +} + + void Foam::sampledSets::write() { if (size() && checkFieldTypes()) diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.H b/src/sampling/sampledSet/sampledSets/sampledSets.H index baf21e450b..da38f9e1c5 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.H +++ b/src/sampling/sampledSet/sampledSets/sampledSets.H @@ -270,9 +270,12 @@ public: //- set verbosity level void verbose(const bool verbosity = true); - //- Execute + //- Execute, currently does nothing virtual void execute(); + //- Execute at the final time-loop, currently does nothing + virtual void end(); + //- Sample and write virtual void write(); diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index 2cbe93c40a..5fd09bda66 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -335,7 +335,7 @@ bool Foam::sampledIsoSurface::updateGeometry() const subMeshPtr_.reset ( - new fvMeshSubset(static_cast(mesh())) + new fvMeshSubset(fvm) ); subMeshPtr_().setLargeCellSubset ( diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H index 4cf334ecbd..99324cdf5f 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H @@ -87,7 +87,7 @@ class sampledIsoSurface // Recreated for every isoSurface - //- Time at last call, also track it surface needs an update + //- Time at last call, also track if surface needs an update mutable label prevTimeIndex_; //- Cached volfield diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 003515c7d4..9eb0e73f11 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -203,7 +203,6 @@ Foam::sampledSurfaces::~sampledSurfaces() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - void Foam::sampledSurfaces::verbose(const bool verbosity) { verbose_ = verbosity; @@ -216,6 +215,12 @@ void Foam::sampledSurfaces::execute() } +void Foam::sampledSurfaces::end() +{ + // Do nothing - only valid on write +} + + void Foam::sampledSurfaces::write() { if (size() && checkFieldTypes()) diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 2635783409..7bf12aaba8 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -257,9 +257,12 @@ public: //- set verbosity level void verbose(const bool verbosity = true); - //- Execute + //- Execute, currently does nothing virtual void execute(); + //- Execute at the final time-loop, currently does nothing + virtual void end(); + //- Sample and write virtual void write();