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

This commit is contained in:
mattijs
2012-02-23 14:55:28 +00:00
parent f9262f751f
commit f3590edfa0
3 changed files with 47 additions and 20 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -221,20 +221,43 @@ void Foam::Time::setControls()
timeIndex_ = startTimeIndex_; timeIndex_ = startTimeIndex_;
} }
scalar timeValue;
if (timeDict.readIfPresent("value", timeValue))
{
word storedTimeName(timeName(timeValue));
if (storedTimeName != timeName()) // Check if values stored in time dictionary are consistent
// 1. Based on time name
bool checkValue = true;
string storedTimeName;
if (timeDict.readIfPresent("name", storedTimeName))
{
if (storedTimeName == timeName())
{ {
IOWarningIn("Time::setControls()", timeDict) // Same time. No need to check stored value
<< "Time read from time dictionary " << storedTimeName checkValue = false;
<< " 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." // 2. Based on time value
<< endl; // (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))
{
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;
}
} }
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -293,12 +293,14 @@ bool Foam::Time::writeObject
{ {
if (outputTime()) if (outputTime())
{ {
const word tmName(timeName());
IOdictionary timeDict IOdictionary timeDict
( (
IOobject IOobject
( (
"time", "time",
timeName(), tmName,
"uniform", "uniform",
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
@ -308,6 +310,7 @@ bool Foam::Time::writeObject
); );
timeDict.add("value", value()); timeDict.add("value", value());
timeDict.add("name", string(tmName));
timeDict.add("index", timeIndex_); timeDict.add("index", timeIndex_);
timeDict.add("deltaT", deltaT_); timeDict.add("deltaT", deltaT_);
timeDict.add("deltaT0", deltaT0_); timeDict.add("deltaT0", deltaT0_);
@ -317,7 +320,7 @@ bool Foam::Time::writeObject
if (writeOK && purgeWrite_) if (writeOK && purgeWrite_)
{ {
previousOutputTimes_.push(timeName()); previousOutputTimes_.push(tmName);
while (previousOutputTimes_.size() > purgeWrite_) while (previousOutputTimes_.size() > purgeWrite_)
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -91,9 +91,10 @@ Foam::engineTime::engineTime
timeAdjustment(); timeAdjustment();
startTime_ = degToTime(startTime_); startTime_ = degToTime(startTime_);
value() = degToTime(value()); value() = degToTime(value());
deltaT0_ = deltaT_; deltaTSave_ = deltaT_;
deltaT0_ = deltaT_;
} }