46 return ranges_.contains(value);
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;
118 "Include 'constant/' dir in the times list"
126 "Include '0/' dir in the times list"
132 string(
"Exclude '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"
158 "Include 'constant/' dir in the times"
163 "Exclude '0/' dir from the times (currently ignored)"
168 "Select the latest time"
174 "Select the nearest time to the specified value"
183 const word& constantName
190 label constantIdx = -1;
192 label latestIdx = -1;
197 if (times[timei].
name() == constantName)
201 else if (times[timei].value() == 0)
206 if (constantIdx >= 0 && zeroIdx >= 0)
217 latestIdx = times.
size() - 1;
220 if (latestIdx == constantIdx)
235 selectTimes[latestIdx] =
true;
238 if (constantIdx >= 0)
241 selectTimes[constantIdx] =
args.
found(
"constant");
250 selectTimes[zeroIdx] =
false;
255 selectTimes[zeroIdx] =
args.
found(
"withZero");
285 <<
"No time specified or available, selecting 'constant'"
305 args.found(
"latestTime")
306 ||
args.found(
"time")
307 ||
args.found(
"constant")
308 ||
args.found(
"noZero")
309 ||
args.found(
"withZero")
324 const bool forceInitial
352 timei = times.size() - 1;
356 const scalar target =
args.
get<scalar>(
"time");
367 (timei >= 0 && timei < times.size()-1)
368 && times[timei].name() ==
"constant"
377 if (timei >= 0 && timei < times.size())
Various functions to operate on Lists.
scalar value() const noexcept
The value (const access).
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void push_back(const T &val)
Append an element at the end of the list.
instantList times() const
Search the case for valid time directories.
static label findClosestTimeIndex(const UList< instant > &timeDirs, const scalar t, const word &constantDirName="constant")
Search instant list for the time index closest to the specified time.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T & front()
Access first element of the list, position [0].
void size(const label n)
Older name for setAddressableSize.
Extract command arguments and options from the supplied argc and argv parameters.
T get(const label index) const
Get a value from the argument at index.
bool found(const word &optName) const
Return true if the named option is found.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static HashTable< string > validOptions
A list of valid options.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Scalar bounds to be used as a unary predicate.
The timeSelector provides a convenient means of selecting multiple times.
static void addOptions_singleTime()
Add single-time timeSelector options to argList::validOptions().
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
static bool setTimeIfPresent(Time &runTime, const argList &args, const bool forceInitial=false)
Set the runTime based on -constant (if present), -time (value), or -latestTime.
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...
bool selected(const instant &t) const
True if value of the instant is within any of the ranges.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times - as per select0() - otherwise return just the cu...
timeSelector() noexcept=default
Default construct.
bool contains(const scalar value) const
True if value is within any of the ranges.
void inplaceSelect(instantList ×) const
Select a list of Time values that are within the ranges.
instantList select(const instantList ×) const
Select a list of Time values that are within the ranges.
A class for handling words, derived from Foam::string.
#define WarningInFunction
Report a warning using Foam::Warning.
Different types of constants.
void inplaceSubset(const BoolListType &select, ListType &input, const bool invert=false)
Inplace extract elements of the input list when select is true.
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
List< instant > instantList
List of instants.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.