Commit 36ca836f authored by Henry's avatar Henry
Browse files

Time: Correct precision adjustment for user-time

parent 295a357a
......@@ -1086,7 +1086,7 @@ Foam::Time& Foam::Time::operator++()
deltaTSave_ = deltaT_;
// Save old time value and name
const scalar oldTimeValue = value();
const scalar oldTimeValue = timeToUserTime(value());
const word oldTimeName = dimensionedScalar::name();
// Increment time
......@@ -1276,19 +1276,22 @@ Foam::Time& Foam::Time::operator++()
// Adjust the precision of the time directory name if necessary
if (outputTime_)
{
// Time value obtained by reading timeName
scalar timeNameValue = -VGREAT;
// Tolerance used when testing time equivalence
scalar timeTol =
const scalar timeTol =
max(min(pow(10.0, -precision_), 0.1*deltaT_), SMALL);
// User-time equivalent of deltaT
const scalar userDeltaT = timeToUserTime(deltaT_);
// Time value obtained by reading timeName
scalar timeNameValue = -VGREAT;
// Check that new time representation differs from old one
// reinterpretation of the word
if
(
readScalar(dimensionedScalar::name().c_str(), timeNameValue)
&& (mag(timeNameValue - oldTimeValue - deltaT_) > timeTol)
&& (mag(timeNameValue - oldTimeValue - userDeltaT) > timeTol)
)
{
int oldPrecision = precision_;
......@@ -1296,7 +1299,7 @@ Foam::Time& Foam::Time::operator++()
(
precision_ < maxPrecision_
&& readScalar(dimensionedScalar::name().c_str(), timeNameValue)
&& (mag(timeNameValue - oldTimeValue - deltaT_) > timeTol)
&& (mag(timeNameValue - oldTimeValue - userDeltaT) > timeTol)
)
{
precision_++;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment