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
|
\\ / 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,10 +221,31 @@ void Foam::Time::setControls()
|
|||||||
timeIndex_ = startTimeIndex_;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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())
|
if (storedTimeName != timeName())
|
||||||
{
|
{
|
||||||
@ -233,10 +254,12 @@ void Foam::Time::setControls()
|
|||||||
<< " differs from actual time " << timeName() << '.' << nl
|
<< " differs from actual time " << timeName() << '.' << nl
|
||||||
<< " This may cause unexpected database behaviour."
|
<< " This may cause unexpected database behaviour."
|
||||||
<< " If you are not interested" << nl
|
<< " If you are not interested" << nl
|
||||||
<< " in preserving time state delete the time dictionary."
|
<< " in preserving time state delete"
|
||||||
|
<< " the time dictionary."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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_)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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
|
||||||
@ -93,6 +93,7 @@ Foam::engineTime::engineTime
|
|||||||
|
|
||||||
startTime_ = degToTime(startTime_);
|
startTime_ = degToTime(startTime_);
|
||||||
value() = degToTime(value());
|
value() = degToTime(value());
|
||||||
|
deltaTSave_ = deltaT_;
|
||||||
deltaT0_ = deltaT_;
|
deltaT0_ = deltaT_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user