Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToEnsightParts / getTimeIndex.H
blobecf12f8b1373f9debc0759b99c4e0625004c9284
1 // Read time index from */uniform/time, but treat 0 and constant specially
2 // or simply increment from the '-index' option if it was supplied
4     label timeIndex = 0;
6     if (optIndex)
7     {
8         timeIndex = indexingNumber++;
9     }
10     else if
11     (
12         runTime.timeName() != "constant"
13      && runTime.timeName() != "0"
14     )
15     {
16         IOobject io
17         (
18             "time",
19             runTime.timeName(),
20             "uniform",
21             runTime,
22             IOobject::READ_IF_PRESENT,
23             IOobject::NO_WRITE,
24             false
25         );
27         if (io.headerOk())
28         {
29             io.readOpt() = IOobject::MUST_READ;
30             IOdictionary timeObject(io);
32             timeObject.lookup("index") >> timeIndex;
33         }
34         else
35         {
36             Info<< "skip ... missing entry " << io.objectPath() << endl;
37             continue;
38         }
39     }
41     timeIndices.insert(timeIndex, timeDirs[timeI].value());
42     Info<< "\nTime [" << timeIndex << "] = " << runTime.timeName() << nl;