initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / conversion / foamToStarMesh / getTimeIndex.H
blob85a92405dda760fbbfc5931102afe41aa602b2e6
1 // Read time index from */uniform/time, but treat 0 and constant specially
3     word timeName = "0";
5     if
6     (
7         runTime.timeName() != "constant"
8      && runTime.timeName() != "0"
9     )
10     {
11         IOobject io
12         (
13             "time",
14             runTime.timeName(),
15             "uniform",
16             runTime,
17             IOobject::READ_IF_PRESENT,
18             IOobject::NO_WRITE,
19             false
20         );
22         if (io.headerOk())
23         {
24             IOdictionary timeObject
25             (
26                 IOobject
27                 (
28                     "time",
29                     runTime.timeName(),
30                     "uniform",
31                     runTime,
32                     IOobject::MUST_READ,
33                     IOobject::NO_WRITE,
34                     false
35                 )
36             );
38             label index;
39             timeObject.lookup("index") >> index;
40             timeName = Foam::name(index);
41         }
42         else
43         {
44             timeName = runTime.timeName();
45             // Info<< "skip ... missing entry " << io.objectPath() << endl;
46             // continue;
47         }
48     }
50     Info<< "\nTime [" << timeName << "] = " << runTime.timeName() << nl;