timeSelector Class Reference

A List of scalarRange for selecting times. More...

Inheritance diagram for timeSelector:
[legend]
Collaboration diagram for timeSelector:
[legend]

Public Member Functions

 timeSelector ()=default
 Default construct. More...
 
 timeSelector (const std::string &str)
 Construct by parsing string for time ranges. More...
 
bool selected (const instant &value) const
 Return true if the given instant is within the ranges. More...
 
List< boolselected (const instantList &times) const
 
instantList select (const instantList &times) const
 Select a list of Time values that are within the ranges. More...
 
void inplaceSelect (instantList &times) const
 Select a list of Time values that are within the ranges. More...
 

Static Public Member Functions

static void addOptions (const bool constant=true, const bool withZero=false)
 Add timeSelector options to argList::validOptions. More...
 
static instantList select (const instantList &times, const argList &args, const word &constantName="constant")
 Return the set of times selected based on the argList options. More...
 
static instantList select0 (Time &runTime, const argList &args)
 
static instantList selectIfPresent (Time &runTime, const argList &args)
 

Detailed Description

A List of scalarRange for selecting times.

The timeSelector provides a convenient means of selecting multiple times. A typical use would be the following:

timeSelector::addOptions();
// add other options
#include "setRootCase.H"
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
...
forAll(timeDirs, timei)
{
    ...
}

The result program would receive -time, -latestTime, -constant and -noZero options. The -constant option explicitly includes the constant/ directory in the time list and the -noZero option explicitly excludes the 0/ directory from the time list.

There may however also be many cases in which neither the constant/ directory nor the 0/ directory contain particularly relevant information. This might occur, for example, when post-processing results. In this case, addOptions is called with optional boolean arguments.

timeSelector::addOptions(false, true);

The first argument avoids adding the -constant option. The second argument adds an additional -withZero option and also prevents the 0/ directory from being included in the default time range and in the -latestTime selection.

Source files

Definition at line 92 of file timeSelector.H.

Constructor & Destructor Documentation

◆ timeSelector() [1/2]

timeSelector ( )
default

Default construct.

◆ timeSelector() [2/2]

timeSelector ( const std::string &  str)
explicit

Construct by parsing string for time ranges.

Definition at line 36 of file timeSelector.C.

Member Function Documentation

◆ selected() [1/2]

bool selected ( const instant value) const

Return true if the given instant is within the ranges.

Definition at line 44 of file timeSelector.C.

References scalarRanges::match(), and Instant< T >::value().

Referenced by timeSelector::select().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selected() [2/2]

Foam::List< bool > selected ( const instantList times) const

Return the set of selected instants in the given list that are within the ranges

Definition at line 50 of file timeSelector.C.

References TimePaths::findClosestTimeIndex(), forAll, Foam::name(), range, and UList< T >::size().

Here is the call graph for this function:

◆ select() [1/2]

Foam::instantList select ( const instantList times) const

Select a list of Time values that are within the ranges.

Definition at line 89 of file timeSelector.C.

References Foam::subset().

Referenced by timeSelector::select0().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inplaceSelect()

void inplaceSelect ( instantList times) const

Select a list of Time values that are within the ranges.

Definition at line 95 of file timeSelector.C.

References Foam::inplaceSubset().

Here is the call graph for this function:

◆ addOptions()

void addOptions ( const bool  constant = true,
const bool  withZero = false 
)
static

Add timeSelector options to argList::validOptions.

Parameters
constantAdd the -constant option to include the constant/ directory
withZeroEnable the -withZero option and alter the normal time selection behaviour (and -latestTime behaviour) to exclude the 0/ directory. The 0/ directory will only be included when -withZero is specified. The -noZero option has precedence over the -withZero option.

Definition at line 101 of file timeSelector.C.

References argList::addBoolOption(), and argList::addOption().

Referenced by if().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select() [2/2]

Foam::instantList select ( const instantList times,
const argList args,
const word constantName = "constant" 
)
static

Return the set of times selected based on the argList options.

Definition at line 147 of file timeSelector.C.

References args, forAll, found, argList::found(), Foam::name(), timeSelector::selected(), UList< T >::size(), Foam::subset(), and argList::validOptions.

Here is the call graph for this function:

◆ select0()

Foam::instantList select0 ( Time runTime,
const argList args 
)
static

Return the set of times selected based on the argList options and also set the runTime to the first instance or the constant/ directory if no instances are specified or available

Definition at line 234 of file timeSelector.C.

References List< T >::append(), args, TimePaths::constant(), UList< T >::empty(), Foam::endl(), UList< T >::first(), runTime, timeSelector::select(), Time::setTime(), TimePaths::times(), and WarningInFunction.

Referenced by if().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectIfPresent()

Foam::instantList selectIfPresent ( Time runTime,
const argList args 
)
static

If any time option provided return the set of times (as select0) otherwise return just the current time.

Also set the runTime to the first instance

Definition at line 265 of file timeSelector.C.

References args, argList::found(), runTime, Time::timeName(), and dimensioned< Type >::value().

Here is the call graph for this function:

The documentation for this class was generated from the following files: