Public Member Functions | Static Public Member Functions
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 ()
 Construct Null. More...
 
 timeSelector (Istream &)
 Construct from Istream. More...
 
bool selected (const instant &) const
 Return true if the given instant is within the ranges. More...
 
List< bool > selected (const instantList &) const
 Return the set of selected instants in the given list that are. More...
 
instantList select (const instantList &) const
 Select a list of Time values that are within the ranges. More...
 
void inplaceSelect (instantList &) const
 Select a list of Time values that are within the ranges. More...
 
- Public Member Functions inherited from scalarRanges
 scalarRanges ()
 Construct Null. More...
 
 scalarRanges (Istream &)
 Construct from Istream. More...
 
bool selected (const scalar) const
 Return true if the given value is within the ranges. More...
 
List< bool > selected (const List< scalar > &) const
 Return the set of selected entries in the given list. More...
 
List< scalar > select (const List< scalar > &) const
 Select a list of values that are within the ranges. More...
 
void inplaceSelect (List< scalar > &) const
 Select a list of values that are within the ranges. More...
 
- Public Member Functions inherited from List< scalarRange >
label size () const
 Return the number of elements in the UList. More...
 
 List ()
 Null constructor. More...
 
 List (const label)
 Construct with given size. More...
 
 List (const label, const T &)
 Construct with given size and value for all elements. More...
 
 List (const List< T > &)
 Copy constructor. More...
 
 List (const Xfer< List< T > > &)
 Construct by transferring the parameter contents. More...
 
 List (List< T > &, bool reUse)
 Construct as copy or re-use as specified. More...
 
 List (const UList< T > &, const labelUList &mapAddressing)
 Construct as subset. More...
 
 List (InputIterator first, InputIterator last)
 Construct given start and end iterators. More...
 
 List (const FixedList< T, Size > &)
 Construct as copy of FixedList<T, Size> More...
 
 List (const PtrList< T > &)
 Construct as copy of PtrList<T> More...
 
 List (const SLList< T > &)
 Construct as copy of SLList<T> More...
 
 List (const UIndirectList< T > &)
 Construct as copy of UIndirectList<T> More...
 
 List (const BiIndirectList< T > &)
 Construct as copy of BiIndirectList<T> More...
 
 List (Istream &)
 Construct from Istream. More...
 
 List (const label s)
 
 List (const label s, const T &a)
 
 List (const List< T > &a)
 
 List (const Xfer< List< T > > &lst)
 
 List (List< T > &a, bool reUse)
 
 List (const UList< T > &a, const labelUList &map)
 
 List (const PtrList< T > &lst)
 
 List (const SLList< T > &lst)
 
 List (const UIndirectList< T > &lst)
 
 List (const BiIndirectList< T > &lst)
 
 List ()
 
 List (Istream &is)
 
autoPtr< List< T > > clone () const
 Clone. More...
 
 ~List ()
 Destructor. More...
 
void resize (const label)
 Alias for setSize(const label) More...
 
void resize (const label, const T &)
 Alias for setSize(const label, const T&) More...
 
void setSize (const label)
 Reset size of List. More...
 
void setSize (const label, const T &)
 Reset size of List and value for new elements. More...
 
void clear ()
 Clear the list, i.e. set size to zero. More...
 
void append (const T &)
 Append an element at the end of the list. More...
 
void append (const UList< T > &)
 Append a List at the end of this list. More...
 
void append (const UIndirectList< T > &)
 Append a UIndirectList at the end of this list. More...
 
void transfer (List< T > &)
 Transfer the contents of the argument List into this list. More...
 
void transfer (DynamicList< T, SizeInc, SizeMult, SizeDiv > &)
 Transfer the contents of the argument List into this list. More...
 
void transfer (SortableList< T > &)
 Transfer the contents of the argument List into this list. More...
 
void transfer (List< T > &a)
 
void transfer (SortableList< T > &a)
 
Xfer< List< T > > xfer ()
 Transfer contents to the Xfer container. More...
 
TnewElmt (const label)
 Return subscript-checked element of UList. More...
 
void operator= (const UList< T > &)
 Assignment from UList operator. Takes linear time. More...
 
void operator= (const List< T > &)
 Assignment operator. Takes linear time. More...
 
void operator= (const SLList< T > &)
 Assignment from SLList operator. Takes linear time. More...
 
void operator= (const UIndirectList< T > &)
 Assignment from UIndirectList operator. Takes linear time. More...
 
void operator= (const BiIndirectList< T > &)
 Assignment from BiIndirectList operator. Takes linear time. More...
 
void operator= (const T &)
 Assignment of all entries to the given value. More...
 

Static Public Member Functions

static void addOptions (const bool constant=true, const bool withZero=false)
 Add the options handled by timeSelector to argList::validOptions. More...
 
static instantList select (const instantList &, 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)
 Return the set of times selected based on the argList options. More...
 
static instantList selectIfPresent (Time &runTime, const argList &args)
 If any time option provided return the set of times (as select0) More...
 
static instantList select (Time &runTime, const argList &args, const word &fName)
 Return the set of times selected based on the argList options. More...
 
- Static Public Member Functions inherited from List< scalarRange >
static const List< T > & null ()
 Return a null List. More...
 

Additional Inherited Members

- Public Types inherited from List< scalarRange >
typedef SubList< TsubList
 Declare type of subList. More...
 
- Protected Member Functions inherited from List< scalarRange >
void size (const label)
 Override size to be inconsistent with allocated storage. More...
 

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 89 of file timeSelector.H.

Constructor & Destructor Documentation

◆ timeSelector() [1/2]

Construct Null.

Definition at line 34 of file timeSelector.C.

◆ timeSelector() [2/2]

timeSelector ( Istream is)

Construct from Istream.

Definition at line 40 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 48 of file timeSelector.C.

References scalarRanges::selected(), and instant::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 54 of file timeSelector.C.

References Foam::diff(), forAll, Foam::name(), and List::size().

Here is the call graph for this function:

◆ select() [1/3]

Foam::instantList select ( const instantList Times) const

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

Definition at line 100 of file timeSelector.C.

References Foam::subset().

Referenced by main(), and 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 107 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 the options handled by timeSelector 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 114 of file timeSelector.C.

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

Referenced by main().

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

◆ select() [2/3]

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

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

Definition at line 161 of file timeSelector.C.

References args, forAll, found, Foam::name(), argList::optionFound(), argList::optionLookup(), timeSelector::selected(), List::size(), Foam::subset(), timeDirs, 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.

also set the runTime to the first instance or the constant/ directory if no instances are specified or available

Definition at line 253 of file timeSelector.C.

References List::append(), args, TimePaths::constant(), Foam::endl(), timeSelector::select(), Time::setTime(), timeDirs, Time::times(), and WarningInFunction.

Referenced by main(), and timeSelector::select().

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 284 of file timeSelector.C.

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

Referenced by main().

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

◆ select() [3/3]

Foam::instantList select ( Time runTime,
const argList args,
const word fName 
)
static

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

including support for -newTimes in which times are selected if the file 'fName' does not exist in the time directory. Also set the runTime to the first instance or the constant/ directory if no instances are specified or available

Definition at line 309 of file timeSelector.C.

References args, Foam::exists(), forAll, argList::optionFound(), Time::path(), timeSelector::select0(), List::size(), Foam::subset(), and timeDirs.

Here is the call graph for this function:

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