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 '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)
229 selectTimes = timeSelector(
args[
"time"]).selected(times);
235 selectTimes[latestIdx] =
true;
238 if (constantIdx >= 0)
241 selectTimes[constantIdx] =
args.
found(
"constant");
250 selectTimes[zeroIdx] =
false;
255 selectTimes[zeroIdx] =
args.
found(
"withZero");
259 return subset(selectTimes, times);
285 <<
"No time specified or available, selecting 'constant'" 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())
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.
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.
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 label findClosestTimeIndex(const UList< instant > &timeDirs, const scalar t, const word &constantDirName="constant")
Search instantList for the time index closest to the specified time.
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 expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
Extract command arguments and options from the supplied argc and argv parameters. ...
static void addOptions_singleTime()
Add single-time timeSelector options to argList::validOptions()
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 per select0() - otherwise return just the cu...
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 a time name for the given scalar time value 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.
T get(const label index) const
Get a value from the argument at index.
#define WarningInFunction
Report a warning using Foam::Warning.
bool contains(const scalar value) const
True if the value is contained by any of the sub-ranges.
List< instant > instantList
List of instants.
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.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...