Skip to content

Commit

Permalink
Time: Adjust the precision of the time name if necessary every time-step
Browse files Browse the repository at this point in the history
This change guarantees that the precision of the time written to the log file,
all functionObject logs and the time directories is sufficient to be unique
irrespective of the change in the time-step or start time of the run.  If the
calculated time precision exceeds what can be represented by the floating point
resolution, e.g. by the time-step dropping to a VERY low value, the run stops.
  • Loading branch information
Henry Weller committed Apr 8, 2024
1 parent c11a241 commit d2817a0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/OpenFOAM/db/Time/Time.C
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,7 @@ Foam::Time& Foam::Time::operator++()
writeOnce_ = false;
}

// Adjust the precision of the time directory name if necessary
if (writeTime_)
// Adjust the precision of the time name if necessary
{
// User-time equivalent of deltaT
const scalar userDeltaT =
Expand Down Expand Up @@ -1288,13 +1287,13 @@ Foam::Time& Foam::Time::operator++()
if (curPrecision_ == maxPrecision_)
{
// Reached maxPrecision limit
WarningInFunction
FatalErrorInFunction
<< "Current time name " << dimensionedScalar::name()
<< nl
<< " The maximum time precision has been reached"
" which might result in overwriting previous"
" results."
<< endl;
<< exit(FatalError);
}

// Check if round-off error caused time-reversal
Expand All @@ -1308,14 +1307,14 @@ Foam::Time& Foam::Time::operator++()
)
)
{
WarningInFunction
FatalErrorInFunction
<< "Current time name " << dimensionedScalar::name()
<< " is set to an instance prior to the "
"previous one "
<< oldTimeName << nl
<< " This might result in temporal "
"discontinuities."
<< endl;
<< exit(FatalError);
}
}
}
Expand Down

0 comments on commit d2817a0

Please sign in to comment.