Public Member Functions | Static Public Member Functions | List of all members
timeSelector Class Reference

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

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

Public Member Functions

 timeSelector ()=default
 
 timeSelector (const std::string &str)
 
bool selected (const instant &value) const
 
List< boolselected (const instantList &times) const
 
instantList select (const instantList &times) const
 
void inplaceSelect (instantList &times) const
 

Static Public Member Functions

static void addOptions (const bool constant=true, const bool withZero=false)
 
static instantList select (const instantList &times, const argList &args, const word &constantName="constant")
 
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 88 of file timeSelector.H.

Constructor & Destructor Documentation

◆ timeSelector() [1/2]

timeSelector ( )
default

◆ timeSelector() [2/2]

timeSelector ( const std::string &  str)
explicit

Definition at line 29 of file timeSelector.C.

Member Function Documentation

◆ selected() [1/2]

bool selected ( const instant value) const

Definition at line 37 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

Definition at line 43 of file timeSelector.C.

References TimePaths::findClosestTimeIndex(), forAll, Foam::name(), and range.

Here is the call graph for this function:

◆ select() [1/2]

Foam::instantList select ( const instantList times) const

Definition at line 82 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

Definition at line 88 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

Definition at line 95 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

Definition at line 141 of file timeSelector.C.

References args, forAll, found, argList::found(), Foam::name(), timeSelector::selected(), Foam::subset(), and argList::validOptions.

Here is the call graph for this function:

◆ select0()

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

Definition at line 228 of file timeSelector.C.

References List::append(), args, TimePaths::constant(), Foam::endl(), 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

Definition at line 259 of file timeSelector.C.

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

Here is the call graph for this function:

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