diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index daa8745fd..860434c6a 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -556,7 +556,14 @@ bool Foam::Time::writeObject // Does the writeTime trigger purging? if (writeTime_ && purgeWrite_) { - previousWriteTimes_.push(timeName()); + if + ( + previousWriteTimes_.size() == 0 + || previousWriteTimes_.top() != timeName() + ) + { + previousWriteTimes_.push(timeName()); + } while (previousWriteTimes_.size() > purgeWrite_) { diff --git a/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.C b/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.C index 0fbf50280..8529df91b 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.C @@ -96,4 +96,27 @@ bool Foam::convergenceControl::converged() } +bool Foam::convergenceControl::endIfConverged(Time& time) +{ + if (converged()) + { + if (time.writeTime()) + { + time.stopAt(Time::saNoWriteNow); + time.setEndTime(time); + } + else + { + time.writeAndEnd(); + } + + return true; + } + else + { + return false; + } +} + + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.H b/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.H index 3f821c893..7fb09166a 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/convergenceControl/convergenceControl/convergenceControl.H @@ -154,6 +154,9 @@ public: //- Flag to indicate whether convergance has been reached bool converged(); + + //- End the run if convergance has been reached + bool endIfConverged(Time& time); }; diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C index cb9eb5b4e..d6a00d4b1 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C @@ -103,11 +103,7 @@ bool Foam::pimpleControl::run(Time& time) { read(); - if (converged()) - { - time.writeAndEnd(); - } - else + if (!endIfConverged(time)) { storePrevIterFields(); } @@ -120,11 +116,7 @@ bool Foam::pimpleControl::loop(Time& time) { read(); - if (converged()) - { - time.writeAndEnd(); - } - else + if (!endIfConverged(time)) { storePrevIterFields(); } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C index a4211afd7..7b14ed7a9 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C @@ -302,11 +302,7 @@ bool Foam::pimpleMultiRegionControl::run(Time& time) { read(); - if (converged()) - { - time.writeAndEnd(); - } - else + if (!endIfConverged(time)) { forAll(pimpleControls_, i) { @@ -326,11 +322,7 @@ bool Foam::pimpleMultiRegionControl::loop(Time& time) { read(); - if (converged()) - { - time.writeAndEnd(); - } - else + if (!endIfConverged(time)) { forAll(pimpleControls_, i) { diff --git a/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C index e089d8e5e..891353921 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C @@ -66,11 +66,7 @@ bool Foam::simpleControl::run(Time& time) { read(); - if (converged()) - { - time.writeAndEnd(); - } - else + if (!endIfConverged(time)) { storePrevIterFields(); } @@ -83,11 +79,7 @@ bool Foam::simpleControl::loop(Time& time) { read(); - if (converged()) - { - time.writeAndEnd(); - } - else + if (!endIfConverged(time)) { storePrevIterFields(); } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl/solutionControl.H b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl/solutionControl.H index 97d5cbc4a..f1caaa64d 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl/solutionControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl/solutionControl.H @@ -81,7 +81,7 @@ public: // Constructors - //- Construct from the time, a the name of the algorithm and a registry + //- Construct from the time, the name of the algorithm and a registry solutionControl ( const objectRegistry& registry,