From 2362899f3e2929e065056e9c8a7659b1908f2f7c Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 30 Sep 2020 11:05:02 +0100 Subject: [PATCH] solutionControl: Execute function objects after residual check Function objects that write need to execute after the residual checks so that the associated modification of the time state correctly makes them write on the final iteration. This reverts commit c6089ae3a65f608a60d665c2baa45158ce954789, meaning that residual controls can no longer apply to fields solved for as part of function object executions. Creating a system which permits solutions done within function objects to be subject to residual control, *and* which correctly causes function objects to write on final iterations, would be significantly more complex. --- .../pimpleControl/pimpleControl.C | 18 +++--------------- .../pimpleMultiRegionControl.C | 18 +++--------------- .../simpleControl/simpleControl.C | 18 +++--------------- 3 files changed, 9 insertions(+), 45 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C index f17f27cc02..8e42b74d3d 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,14 +101,12 @@ bool Foam::pimpleControl::run(Time& time) { read(); - time.run(); - if (!endIfConverged(time)) { storePrevIterFields(); } - return time.running(); + return time.run(); } @@ -116,22 +114,12 @@ bool Foam::pimpleControl::loop(Time& time) { read(); - time.run(); - if (!endIfConverged(time)) { storePrevIterFields(); } - if (time.running()) - { - time ++; - return true; - } - else - { - return false; - } + return time.loop(); } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C index 7b3b7509f7..1cb1a672a3 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -309,8 +309,6 @@ bool Foam::pimpleMultiRegionControl::run(Time& time) { read(); - time.run(); - if (!endIfConverged(time)) { forAll(pimpleControls_, i) @@ -323,7 +321,7 @@ bool Foam::pimpleMultiRegionControl::run(Time& time) } } - return time.running(); + return time.run(); } @@ -331,8 +329,6 @@ bool Foam::pimpleMultiRegionControl::loop(Time& time) { read(); - time.run(); - if (!endIfConverged(time)) { forAll(pimpleControls_, i) @@ -345,15 +341,7 @@ bool Foam::pimpleMultiRegionControl::loop(Time& time) } } - if (time.running()) - { - time ++; - return true; - } - else - { - return false; - } + return time.loop(); } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C index 2c094be106..fb4ec83cf4 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,14 +66,12 @@ bool Foam::simpleControl::run(Time& time) { read(); - time.run(); - if (!endIfConverged(time)) { storePrevIterFields(); } - return time.running(); + return time.run(); } @@ -81,22 +79,12 @@ bool Foam::simpleControl::loop(Time& time) { read(); - time.run(); - if (!endIfConverged(time)) { storePrevIterFields(); } - if (time.running()) - { - time ++; - return true; - } - else - { - return false; - } + return time.loop(); }