mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
solutionControl: Fix repeat-write when converged at a write time
Solution controls now detect when convergence occurs at a write time and avoid writing the final directory twice. This also resolves the issue whereby a purgeWrite setting would remove an extra directory. This resolves bug report https://bugs.openfoam.org/view.php?id=2904
This commit is contained in:
@ -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_)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user