52 return ranges_.contains(t.
value());
65 times[timei].name() !=
"constant" && contains(times[timei])
70 for (
const scalarRange&
range : ranges_)
74 const scalar target =
range.value();
76 const label nearestIndex =
84 if (nearestIndex >= 0)
86 selectTimes[nearestIndex] =
true;
97 return subset(selected(times), times);
118 "Include the 'constant/' dir in the times list" 126 "Include the '0/' dir in the times list" 132 string(
"Exclude the '0/' dir from the times list")
135 ?
", has precedence over the -withZero option" 142 "Select the latest time" 148 "List of ranges. Eg, ':10,20 40:70 1000:', 'none', etc" 157 const word& constantName
164 label constantIdx = -1;
166 label latestIdx = -1;
171 if (times[timei].
name() == constantName)
175 else if (times[timei].value() == 0)
180 if (constantIdx >= 0 && zeroIdx >= 0)
191 latestIdx = times.
size() - 1;
194 if (latestIdx == constantIdx)
203 selectTimes = timeSelector(
args[
"time"]).selected(times);
209 selectTimes[latestIdx] =
true;
212 if (constantIdx >= 0)
215 selectTimes[constantIdx] =
args.
found(
"constant");
224 selectTimes[zeroIdx] =
false;
229 selectTimes[zeroIdx] =
args.
found(
"withZero");
233 return subset(selectTimes, times);
259 <<
"No time specified or available, selecting 'constant'"
List< instant > instantList
List of instants.
const Type & value() const noexcept
Return const reference to value.
void size(const label n)
Older name for setAddressableSize.
void inplaceSelect(instantList ×) const
Select a list of Time values that are within the ranges.
static label findClosestTimeIndex(const instantList &timeDirs, const scalar t, const word &constantName="constant")
Search instantList for the time index closest to the specified time.
timeSelector() noexcept=default
Default construct.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
void inplaceSubset(const BoolListType &select, ListType &input, const bool invert=false)
Inplace extract elements of the input list when select is true.
bool selected(const instant &t) const
True if value of the instant is within any of the ranges.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
instantList select(const instantList ×) const
Select a list of Time values that are within the ranges.
Various functions to operate on Lists.
scalar value() const noexcept
The value (const access)
#define forAll(list, i)
Loop across all elements in list.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
Extract command arguments and options from the supplied argc and argv parameters. ...
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0) otherwise return just the current ti...
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
const word & constant() const noexcept
Return constant name.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
instantList times() const
Search the case for valid time directories.
#define WarningInFunction
Report a warning using Foam::Warning.
bool contains(const scalar value) const
True if the value is matched by any of the sub-ranges.
Foam::argList args(argc, argv)
bool contains(const scalar value) const
True if value is within any of the ranges.
static HashTable< string > validOptions
A list of valid options.
bool found(const word &optName) const
Return true if the named option is found.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.