Skip to content
Snippets Groups Projects
Commit f3590edf authored by mattijs's avatar mattijs
Browse files

BUG: Time: restart with non-standard Time (e.g. engineTime) compared values instead of names.

parent f9262f75
Branches
Tags
No related merge requests found
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -221,20 +221,43 @@ void Foam::Time::setControls()
timeIndex_ = startTimeIndex_;
}
scalar timeValue;
if (timeDict.readIfPresent("value", timeValue))
// Check if values stored in time dictionary are consistent
// 1. Based on time name
bool checkValue = true;
string storedTimeName;
if (timeDict.readIfPresent("name", storedTimeName))
{
word storedTimeName(timeName(timeValue));
if (storedTimeName == timeName())
{
// Same time. No need to check stored value
checkValue = false;
}
}
if (storedTimeName != timeName())
// 2. Based on time value
// (consistent up to the current time writing precision so it won't
// trigger if we just change the write precision)
if (checkValue)
{
scalar storedTimeValue;
if (timeDict.readIfPresent("value", storedTimeValue))
{
IOWarningIn("Time::setControls()", timeDict)
<< "Time read from time dictionary " << storedTimeName
<< " differs from actual time " << timeName() << '.' << nl
<< " This may cause unexpected database behaviour."
<< " If you are not interested" << nl
<< " in preserving time state delete the time dictionary."
<< endl;
word storedTimeName(timeName(storedTimeValue));
if (storedTimeName != timeName())
{
IOWarningIn("Time::setControls()", timeDict)
<< "Time read from time dictionary " << storedTimeName
<< " differs from actual time " << timeName() << '.' << nl
<< " This may cause unexpected database behaviour."
<< " If you are not interested" << nl
<< " in preserving time state delete"
<< " the time dictionary."
<< endl;
}
}
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -293,12 +293,14 @@ bool Foam::Time::writeObject
{
if (outputTime())
{
const word tmName(timeName());
IOdictionary timeDict
(
IOobject
(
"time",
timeName(),
tmName,
"uniform",
*this,
IOobject::NO_READ,
......@@ -308,6 +310,7 @@ bool Foam::Time::writeObject
);
timeDict.add("value", value());
timeDict.add("name", string(tmName));
timeDict.add("index", timeIndex_);
timeDict.add("deltaT", deltaT_);
timeDict.add("deltaT0", deltaT0_);
......@@ -317,7 +320,7 @@ bool Foam::Time::writeObject
if (writeOK && purgeWrite_)
{
previousOutputTimes_.push(timeName());
previousOutputTimes_.push(tmName);
while (previousOutputTimes_.size() > purgeWrite_)
{
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -91,9 +91,10 @@ Foam::engineTime::engineTime
timeAdjustment();
startTime_ = degToTime(startTime_);
value() = degToTime(value());
deltaT0_ = deltaT_;
startTime_ = degToTime(startTime_);
value() = degToTime(value());
deltaTSave_ = deltaT_;
deltaT0_ = deltaT_;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment