From 9ed84852a73637ee4209f2f16fd1ac46e2cec634 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Fri, 26 Jan 2018 16:31:56 +0000 Subject: [PATCH] Time: Fix logical error in re-evaluation of running state An unintended change in the running-state logic was introduced by commit 9a35ce69. The running state should only be re-evaluated when in the simulation is not ending. The "execute/end" function object invocation should not be permitted to change the running state. The simulation should always end if this state is reached. --- src/OpenFOAM/db/Time/Time.C | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 8018a06b6..7615df5e9 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -786,7 +786,7 @@ bool Foam::Time::running() const bool Foam::Time::run() const { - const bool running = this->running(); + bool running = this->running(); if (!subCycling_) { @@ -812,23 +812,23 @@ bool Foam::Time::run() const functionObjects_.execute(); } } + + // Re-evaluate if running in case a function object has changed things + running = this->running(); } - // Re-evaluate if running in case a function object has changed things - return this->running(); + return running; } bool Foam::Time::loop() { - const bool running = this->running(); - if (run()) { operator++(); } - return running; + return running(); }