openfoam/applications/utilities/postProcessing/dataConversion/foamToEnsight/getTimeIndex.H
Mark Olesen 9a2a22a03a ENH: provide setter methods for IOobject read/write options etc.
- simplifies local toggling.

- centralize fileModification static variables into IOobject.
  They were previously scattered between IOobject and regIOobject
2021-03-17 15:10:00 +01:00

41 lines
960 B
C

// Read time index from */uniform/time, but treat 0 and constant specially
// or simply increment from the '-index' option if it was supplied
label timeIndex = 0;
{
if (doConsecutive)
{
timeIndex = indexingNumber++;
}
else if
(
runTime.timeName() != runTime.constant()
&& runTime.timeName() != "0"
)
{
IOobject io
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false // no register
);
if (io.typeHeaderOk<IOdictionary>(true, false))
{
io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
IOdictionary timeObject(io);
timeObject.readEntry("index", timeIndex);
}
else
{
Info<< "skip ... missing entry " << io.objectPath() << endl;
continue;
}
}
}