mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Time: restart with non-standard Time (e.g. engineTime) compared values instead of names.
This commit is contained in:
@ -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))
|
||||
{
|
||||
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)
|
||||
<< "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;
|
||||
// Same time. No need to check stored value
|
||||
checkValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 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))
|
||||
{
|
||||
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_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user