From f8ea34bc5930dc2edbf85a8290c48463bce3e15d Mon Sep 17 00:00:00 2001
From: henry <Henry Weller h.weller@opencfd.co.uk>
Date: Fri, 9 Apr 2010 12:45:13 +0100
Subject: [PATCH] Time: Moved functionObject execution from "++" to "loop"

This change allows functionObjects to cleanly terminate the code e.g. on convergence.
---
 src/OpenFOAM/db/Time/Time.C | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C
index 8e18dc78611..36bccb3911c 100644
--- a/src/OpenFOAM/db/Time/Time.C
+++ b/src/OpenFOAM/db/Time/Time.C
@@ -518,11 +518,28 @@ bool Foam::Time::loop()
 
     if (running)
     {
-        operator++();
+        if (!subCycling_)
+        {
+            readModifiedObjects();
+
+            if (timeIndex_ == startTimeIndex_)
+            {
+                functionObjects_.start();
+            }
+            else
+            {
+                functionObjects_.execute();
+            }
+        }
 
         // Check update the "running" status following the "++" operation
         // to take into account possible side-effects from functionObjects
         running = run();
+
+        if (running)
+        {
+            operator++();
+        }
     }
 
     return running;
@@ -667,20 +684,6 @@ Foam::Time& Foam::Time::operator+=(const scalar deltaT)
 
 Foam::Time& Foam::Time::operator++()
 {
-    if (!subCycling_)
-    {
-        readModifiedObjects();
-
-        if (timeIndex_ == startTimeIndex_)
-        {
-            functionObjects_.start();
-        }
-        else
-        {
-            functionObjects_.execute();
-        }
-    }
-
     deltaT0_ = deltaTSave_;
     deltaTSave_ = deltaT_;
 
-- 
GitLab