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" 153 "select the new times" 159 "comma-separated time ranges - eg, ':10,20,40:70,1000:'" 168 const word& constantName
176 label constantIdx = -1;
181 if (timeDirs[timeI].
name() == constantName)
185 else if (timeDirs[timeI].value() == 0)
190 if (constantIdx >= 0 && zeroIdx >= 0)
198 label latestIdx = -1;
202 latestIdx = timeDirs.
size() - 1;
205 if (latestIdx == constantIdx)
217 ).selected(timeDirs);
223 selectTimes[latestIdx] =
true;
226 if (constantIdx >= 0)
229 selectTimes[constantIdx] = args.
optionFound(
"constant");
238 selectTimes[zeroIdx] =
false;
243 selectTimes[zeroIdx] = args.
optionFound(
"withZero");
247 return subset(selectTimes, timeDirs);
272 if (timeDirs.
empty())
275 <<
"No time specified or available, selecting 'constant'" 281 runTime.
setTime(timeDirs[0], 0);
331 /timeDirs[timeI].name()
336 return subset(selectTimes, timeDirs);
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)
fileName path() const
Return path.
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.
virtual bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true) const =0
Does the name exist (as DIRECTORY or FILE) in the file system?
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.
const fileOperation & fileHandler()
Get current file handler.
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.