setTimeIndex.H
Go to the documentation of this file.
1 {
2  instantList sourceTimes = runTimeSource.times();
3  label sourceTimeIndex = runTimeSource.timeIndex();
4  if (args.optionFound("sourceTime"))
5  {
6  if (args["sourceTime"] == "latestTime")
7  {
8  sourceTimeIndex = sourceTimes.size() - 1;
9  }
10  else
11  {
12  sourceTimeIndex = Time::findClosestTimeIndex
13  (
14  sourceTimes,
15  args.optionRead<scalar>("sourceTime")
16  );
17  }
18  }
19  else
20  {
21  sourceTimeIndex = Time::findClosestTimeIndex
22  (
23  sourceTimes,
24  runTimeTarget.time().value()
25  );
26  }
27 
28  runTimeSource.setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex);
29 
30  Info<< "\nSource time: " << runTimeSource.value()
31  << "\nTarget time: " << runTimeTarget.value()
32  << endl;
33 }
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
List< instant > instantList
List of instants.
Definition: instantList.H:42
Time runTimeTarget(Time::controlDictName, args)
messageStream Info
Time runTimeSource(Time::controlDictName, argsSrc)
T optionRead(const word &opt) const
Read a value from the named option.
Definition: argListI.H:187
Foam::argList args(argc, argv)