61 if (Times[timeI].
name() !=
"constant" &&
selected(Times[timeI]))
70 if (
operator[](rangeI).isExact())
74 int nearestIndex = -1;
75 scalar nearestDiff = Foam::great;
79 if (Times[timeI].
name() ==
"constant")
continue;
81 scalar
diff = fabs(Times[timeI].value() - target);
82 if (diff < nearestDiff)
89 if (nearestIndex >= 0)
91 lst[nearestIndex] =
true;
124 "include the 'constant/' dir in the times list" 132 "include the '0/' dir in the times list" 138 string(
"exclude the '0/' dir from the times list")
141 ?
", has precedence over the -withZero option" 148 "select the latest time" 154 "comma-separated time ranges - eg, ':10,20,40:70,1000:'" 163 const word& constantName
171 label constantIdx = -1;
176 if (timeDirs[timeI].
name() == constantName)
180 else if (timeDirs[timeI].value() == 0)
185 if (constantIdx >= 0 && zeroIdx >= 0)
193 label latestIdx = -1;
197 latestIdx = timeDirs.
size() - 1;
200 if (latestIdx == constantIdx)
212 ).selected(timeDirs);
218 selectTimes[latestIdx] =
true;
221 if (constantIdx >= 0)
224 selectTimes[constantIdx] = args.
optionFound(
"constant");
233 selectTimes[zeroIdx] =
false;
238 selectTimes[zeroIdx] = args.
optionFound(
"withZero");
242 return subset(selectTimes, timeDirs);
267 if (timeDirs.
empty())
270 <<
"No time specified or available, selecting 'constant'" 276 runTime.
setTime(timeDirs[0], 0);
void inplaceSubset(const UList< T > &select, const T &value, ListType &)
Inplace extract elements of List when select is a certain value.
bool selected(const instant &) const
Return true if the given instant is within the ranges.
List< instant > instantList
List of instants.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void inplaceSelect(instantList &) const
Select a list of Time values that are within the ranges.
T & operator[](const label)
Return element of UList.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
timeSelector()
Construct Null.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Various functions to operate on Lists.
static instantList timeDirs
A class for handling words, derived from string.
Extract command arguments and options from the supplied argc and argv parameters. ...
void append(const T &)
Append an element at the end of the list.
const word & constant() const
Return constant name.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
const Type & value() const
Return const reference to value.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
bool selected(const scalar) const
Return true if the given value is within the ranges.
instantList select(const instantList &) const
Select a list of Time values that are within the ranges.
scalar value() const
Value (const access)
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
word name(const complex &)
Return a string representation of a complex.
An instant of time. Contains the time value and name.
#define WarningInFunction
Report a warning using Foam::Warning.
instantList times() const
Search the case for valid time directories.
ListType subset(const UList< T > &select, const T &value, const ListType &)
Extract elements of List when select is a certain value.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Foam::argList args(argc, argv)
static HashTable< string > validOptions
A list of valid options.
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.