openfoam/applications/utilities/mesh/conversion/foamToFireMesh/getTimeIndex.H
Mark Olesen a592ebc073 STYLE: avoid unrestricted dictionary lookup in conversion, sampling, surfMesh
- aids with detection of excess tokens (issue #762)

- deprecated dictionary::operator[] in favour of the lookup() method
  which offers more flexibilty and clarity of purpose.
  Additionally, the read<> and get<> forms should generally be used
  instead anyhow.
2018-07-18 13:33:00 +02:00

36 lines
883 B
C

// Read time index from */uniform/time, but treat 0 and constant specially
word timeName = "0";
if
(
runTime.timeName() != runTime.constant()
&& runTime.timeName() != "0"
)
{
IOobject io
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
);
if (io.typeHeaderOk<IOdictionary>(true))
{
const label timeIndex = IOdictionary(io).get<label>("index");
timeName = Foam::name(timeIndex);
}
else
{
timeName = runTime.timeName();
// Info<< "skip ... missing entry " << io.objectPath() << endl;
// continue;
}
}
Info<< "\nTime [" << timeName << "] = " << runTime.timeName() << nl;