Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / utilities / preProcessing / mapFields / setTimeIndex.H
blob80dfb3efca44c97b028783125de210640642793e
1     instantList sourceTimes = runTimeSource.times();
2     label sourceTimeIndex = runTimeSource.timeIndex();
3     if (args.optionFound("sourceTime"))
4     {
5         if (args.option("sourceTime") == "latestTime")
6         {
7             sourceTimeIndex = sourceTimes.size() - 1;
8         }
9         else
10         {
11             sourceTimeIndex = Time::findClosestTimeIndex
12             (
13                 sourceTimes,
14                 args.optionRead<scalar>("sourceTime")
15             );
16         }
17     }
18     else
19     {
20         sourceTimeIndex = Time::findClosestTimeIndex
21         (
22             sourceTimes,
23             runTimeTarget.time().value()
24         );
25     }
27     runTimeSource.setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex);
29     Info<< "\nSource time: " << runTimeSource.value()
30         << "\nTarget time: " << runTimeTarget.value()
31         << endl;