From 115a291b8aa916771db3de25945b2826690cd219 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 19 Jul 2016 11:57:37 +0100 Subject: [PATCH] postProcess: Added call to functionObject::end() at end of time-loop Resolves bug-report http://bugs.openfoam.org/view.php?id=2148 --- .../postProcessing/postProcess/postProcess.C | 16 ++++++++++++---- .../functionObjectList/postProcess.H | 10 ++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/applications/utilities/postProcessing/postProcess/postProcess.C b/applications/utilities/postProcessing/postProcess/postProcess.C index 3522721648..d0c998aeb2 100644 --- a/applications/utilities/postProcessing/postProcess/postProcess.C +++ b/applications/utilities/postProcessing/postProcess/postProcess.C @@ -59,7 +59,8 @@ void executeFunctionObjects const Time& runTime, fvMesh& mesh, const HashSet& selectedFields, - functionObjectList& functions + functionObjectList& functions, + bool lastTime ) { Info<< nl << "Reading fields:" << endl; @@ -115,6 +116,12 @@ void executeFunctionObjects // Execute the functionObjects in post-processing mode functions.execute(); + // Execute the functionObject 'end()' function for the last time + if (lastTime) + { + functions.end(); + } + while (!storedObjects.empty()) { storedObjects.pop()->checkOut(); @@ -164,9 +171,9 @@ int main(int argc, char *argv[]) functionObjectList::New(args, runTime, functionsDict, selectedFields) ); - forAll(timeDirs, timeI) + forAll(timeDirs, timei) { - runTime.setTime(timeDirs[timeI], timeI); + runTime.setTime(timeDirs[timei], timei); Info<< "Time = " << runTime.timeName() << endl; @@ -192,7 +199,8 @@ int main(int argc, char *argv[]) runTime, mesh, selectedFields, - functionsPtr() + functionsPtr(), + timei == timeDirs.size()-1 ); } catch (IOerror& err) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H b/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H index 38ce9059d4..06f7aa3f4e 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H @@ -104,9 +104,9 @@ if (argList::postProcess(argc, argv)) functionObjectList::New(args, runTime, functionsDict, selectedFields) ); - forAll(timeDirs, timeI) + forAll(timeDirs, timei) { - runTime.setTime(timeDirs[timeI], timeI); + runTime.setTime(timeDirs[timei], timei); Info<< "Time = " << runTime.timeName() << endl; @@ -137,6 +137,12 @@ if (argList::postProcess(argc, argv)) #endif functionsPtr->execute(); + + // Execute the functionObject 'end()' function for the last time + if (timei == timeDirs.size()-1) + { + functionsPtr->end(); + } } catch (IOerror& err) {