Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / utilities / mesh / conversion / foamToStarMesh / getTimeIndex.H
blobd722c432e3b4aa5a45e7c11c1e5bfcd7c6d4f7a8
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_IF_MODIFIED,
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;