setTimeIndex.H
Go to the documentation of this file.
1 {
2  instantList sourceTimes = runTimeSource.times();
3 
4  if (sourceTimes.empty())
5  {
6  FatalErrorInFunction << "No result times in source "
7  << runTimeSource.caseName()
8  << exit(FatalError);
9  }
10 
12  if (args.optionFound("sourceTime"))
13  {
14  if (args["sourceTime"] == "latestTime")
15  {
16  sourceTimeIndex = sourceTimes.size() - 1;
17  }
18  else
19  {
20  sourceTimeIndex = Time::findClosestTimeIndex
21  (
22  sourceTimes,
23  args.optionRead<scalar>("sourceTime")
24  );
25  }
26  }
27  else
28  {
29  sourceTimeIndex = Time::findClosestTimeIndex
30  (
31  sourceTimes,
32  runTimeTarget.time().userTimeValue()
33  );
34  }
35 
37 
38  Info<< "\nSource time: " << runTimeSource.userTimeName()
39  << "\nTarget time: " << runTimeTarget.userTimeName()
40  << endl;
41 }
T optionRead(const word &opt) const
Read a value from the named option.
Definition: argListI.H:193
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Time runTimeSource(Time::controlDictName, argsSrc)
Time runTimeTarget(Time::controlDictName, args)
label sourceTimeIndex
Definition: setTimeIndex.H:11
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
messageStream Info
List< instant > instantList
List of instants.
Definition: instantList.H:42
error FatalError
Foam::argList args(argc, argv)