Loading...
Searching...
No Matches
GlobalOffset< IntType > Class Template Reference

A Foam::OffsetRange (start, size, total) tuple with some additional parallel functionality. A common use case for OffsetRange would be the definition of non-overlapping global addressing. More...

#include <globalOffset.H>

Inheritance diagram for GlobalOffset< IntType >:
Collaboration diagram for GlobalOffset< IntType >:

Public Member Functions

constexpr GlobalOffset () noexcept
 Default construct as (0,0,0).
constexpr GlobalOffset (IntType len) noexcept
 Construct with specified length, starting at zero (0,len,len). No communication.
 GlobalOffset (IntType len, int communicator, bool parallel=UPstream::parRun())
 Construct from local size, with parallel coordination of the offsets and total size.
 GlobalOffset (const OffsetRange< IntType > &range) noexcept
 Copy construct from OffsetRange.
 GlobalOffset (Istream &is)
 Read construct from start/size/total tuple.
IntType localStart () const noexcept
 Same as start() - method name as per globalIndex.
IntType localSize () const noexcept
 Same as size() - method name as per globalIndex.
IntType totalSize () const noexcept
 Same as total() - method name as per globalIndex.
void reset (IntType len) noexcept
 Reset from local size with zero offset.
void reset (IntType len, int communicator, bool parallel=UPstream::parRun())
 Reset from local size, with parallel coordination of the offsets and total size.
void reduce (int communicator=UPstream::worldComm)
 Based on the local input size, determine the globally-consistent start offset and total size.
bool isLocal (IntType i) const noexcept
 Test if index is within the range. Same as contains().
template<class IntType2>
IntType2 toGlobal (IntType2 i) const noexcept
 From local to global index.
template<class IntType2>
List< IntType2 > toGlobal (const UList< IntType2 > &labels) const
 Convert a list from local to global index.
template<class IntType2>
void inplaceToGlobal (UList< IntType2 > &labels) const
 Convert a list (inplace) from local to global index.
template<class IntType2>
IntType2 toLocal (IntType2 i) const
 From global to local.
Public Member Functions inherited from OffsetRange< IntType >
 OffsetRange (const OffsetRange &) noexcept=default
 Copy construct.
 OffsetRange (OffsetRange &&) noexcept=default
 Move construct.
OffsetRangeoperator= (const OffsetRange &) noexcept=default
 Copy assignment.
OffsetRangeoperator= (OffsetRange &&) noexcept=default
 Move assignment.
constexpr OffsetRange () noexcept
 Default construct as (0,0,0).
constexpr OffsetRange (IntType len) noexcept
 Construct with start=0 and specified size, assigns total=size.
constexpr OffsetRange (IntType beg, IntType len, IntType tot) noexcept
 Construct from all components, no checks.
bool empty () const noexcept
 True if zero-sized.
IntType size () const noexcept
 The size.
IntType & size () noexcept
 Non-const access to the size.
IntType start () const noexcept
 The lower value of the range.
IntType & start () noexcept
 Non-const access to start of the range.
IntType total () const noexcept
 The total size.
IntType & total () noexcept
 Non-const access to the total size.
IntRange< IntType > range () const noexcept
 The (state,size) range.
void clear () noexcept
 Reset to zero.
void reset (IntType len) noexcept
 Reset to the specified size, with start=0 and total=size.
void reset (IntType beg, IntType len, IntType tot) noexcept
 Reset all components.
bool equals (const OffsetRange &b) const noexcept
 Test equality of start/size/total.
int compare (const OffsetRange &b) const noexcept
 Compare start/size/total in that order.
void operator= (IntType len) noexcept
 Assign to the specified size, with start=0 and total=size.
template<class IntT2, class = std::enable_if_t <std::is_integral_v<IntT2> && (sizeof(IntT2) <= sizeof(IntType))>>
void operator= (const OffsetRange< IntT2 > &rhs) noexcept
 Assign from an OffsetRange with the same or lower representation.
const_iterator at (IntType i) const
 Return const_iterator to a position within the range, with bounds checking.
constexpr IntType operator[] (IntType i) const noexcept
 Offset dereference, without bounds checking.
bool operator() (IntType i) const noexcept
 True if the value is between the start and size range.
bool contains (IntType value) const noexcept
 True if the value is between the start and size range range.
IntType begin_value () const noexcept
 The value at the beginning of the start/size range - same as start().
IntType end_value () const noexcept
 The value 1 beyond the end of the start/size range.
IntType rbegin_value () const noexcept
 The max value of the start/size range.
IntType rend_value () const noexcept
 The value 1 before the begin of start/size range.
const_iterator begin () const noexcept
 A const_iterator set to the beginning of the range.
const_iterator cbegin () const noexcept
 A const_iterator set to the beginning of the range.
const_iterator cend () const noexcept
 A const_iterator set to 1 beyond the end of the range.
const_iterator end () const noexcept
 A const_iterator set to 1 beyond the end of the range.
const_reverse_iterator rbegin () const noexcept
 A const_reverse_iterator set to 1 before the end of range.
const_reverse_iterator crbegin () const noexcept
 A const_reverse_iterator set to 1 before the end of range.
const_reverse_iterator rend () const noexcept
 A const_reverse_iterator set to 1 before the begin of range.
const_reverse_iterator crend () const noexcept
 A const_reverse_iterator set to 1 before the begin of range.

Static Public Member Functions

static OffsetRange< IntType > calculate (IntType localSize, int communicator=UPstream::worldComm, bool parallel=UPstream::parRun())
 Calculate a globally-consistent set of start/size/total based on the given local input size.
template<class Int, class = std::enable_if_t<std::is_integral_v<Int>>>
static OffsetRange< Int > calculate (IntType localSize, int communicator=UPstream::worldComm, bool parallel=UPstream::parRun())
 Calculate a globally-consistent set of start/size/total based on the given local input size.
template<class Int, class = std::enable_if_t<std::is_integral_v<Int>>>
static List< OffsetRange< Int > > calculate (const UList< Int > &localSizes, int communicator=UPstream::worldComm, bool parallel=UPstream::parRun())
 Return a list of globally-consistent start/size/total ranges based on the given local input sizes.

Additional Inherited Members

Public Types inherited from OffsetRange< IntType >
typedef IntType value_type
 Type of values contained.
typedef IntType size_type
 The type that can represent the size.
using const_iterator = IndexIterator<IntType>
 Input iterator with const access.
using const_reverse_iterator = ReverseIndexIterator<IntType>
 Reverse input iterator with const access.

Detailed Description

template<class IntType>
class Foam::GlobalOffset< IntType >

A Foam::OffsetRange (start, size, total) tuple with some additional parallel functionality. A common use case for OffsetRange would be the definition of non-overlapping global addressing.

OffsetRange is used for the addressing information, and GlobalOffset for creating and managing that addressing.

Note
In contrast to Foam::globalIndex, both GlobalOffset and OffsetRange only have their own local addressing information (and total size) without additional information about other ranks.
Source files

Definition at line 69 of file globalOffset.H.

Constructor & Destructor Documentation

◆ GlobalOffset() [1/5]

template<class IntType>
GlobalOffset ( )
inlineconstexprnoexcept

Default construct as (0,0,0).

Definition at line 24 of file globalOffsetI.H.

References Foam::noexcept, and OffsetRange< IntType >::OffsetRange().

Here is the call graph for this function:

◆ GlobalOffset() [2/5]

template<class IntType>
GlobalOffset ( IntType len)
inlineconstexprnoexcept

Construct with specified length, starting at zero (0,len,len). No communication.

Definition at line 31 of file globalOffsetI.H.

References Foam::noexcept, and OffsetRange< IntType >::OffsetRange().

Here is the call graph for this function:

◆ GlobalOffset() [3/5]

template<class IntType>
GlobalOffset ( IntType len,
int communicator,
bool parallel = UPstream::parRun() )
inline

Construct from local size, with parallel coordination of the offsets and total size.

Parameters
communicatorcommunicator
paralleluse parallel comms

Definition at line 38 of file globalOffsetI.H.

References OffsetRange< IntType >::OffsetRange(), and reduce().

Here is the call graph for this function:

◆ GlobalOffset() [4/5]

template<class IntType>
GlobalOffset ( const OffsetRange< IntType > & range)
inlinenoexcept

Copy construct from OffsetRange.

Should be left as implicit to allow assignment from the results of the calculate() method

Definition at line 55 of file globalOffsetI.H.

References Foam::noexcept, OffsetRange< IntType >::OffsetRange(), and OffsetRange< IntType >::range().

Here is the call graph for this function:

◆ GlobalOffset() [5/5]

template<class IntType>
GlobalOffset ( Istream & is)
explicit

Read construct from start/size/total tuple.

Member Function Documentation

◆ localStart()

template<class IntType>
IntType localStart ( ) const
inlinenoexcept

Same as start() - method name as per globalIndex.

Definition at line 148 of file globalOffset.H.

◆ localSize()

template<class IntType>
IntType localSize ( ) const
inlinenoexcept

Same as size() - method name as per globalIndex.

Definition at line 153 of file globalOffset.H.

◆ totalSize()

template<class IntType>
IntType totalSize ( ) const
inlinenoexcept

Same as total() - method name as per globalIndex.

Definition at line 158 of file globalOffset.H.

◆ reset() [1/2]

template<class IntType>
void reset ( IntType len)
inlinenoexcept

Reset from local size with zero offset.

Definition at line 67 of file globalOffsetI.H.

References OffsetRange< IntType >::reset().

Here is the call graph for this function:

◆ reset() [2/2]

template<class IntType>
void reset ( IntType len,
int communicator,
bool parallel = UPstream::parRun() )
inline

Reset from local size, with parallel coordination of the offsets and total size.

Parameters
communicatorcommunicator
paralleluse parallel comms

Definition at line 74 of file globalOffsetI.H.

References Foam::reduce(), and OffsetRange< IntType >::reset().

Here is the call graph for this function:

◆ reduce()

template<class IntType>
void reduce ( int communicator = UPstream::worldComm)

Based on the local input size, determine the globally-consistent start offset and total size.

Referenced by GlobalOffset().

Here is the caller graph for this function:

◆ calculate() [1/3]

template<class IntType>
OffsetRange< IntType > calculate ( IntType localSize,
int communicator = UPstream::worldComm,
bool parallel = UPstream::parRun() )
inlinestatic

Calculate a globally-consistent set of start/size/total based on the given local input size.

Parameters
communicatorcommunicator
paralleluse parallel comms

Definition at line 192 of file globalOffset.H.

◆ calculate() [2/3]

template<class IntType>
template<class Int, class = std::enable_if_t<std::is_integral_v<Int>>>
OffsetRange< Int > calculate ( IntType localSize,
int communicator = UPstream::worldComm,
bool parallel = UPstream::parRun() )
inlinestatic

Calculate a globally-consistent set of start/size/total based on the given local input size.

Parameters
communicatorcommunicator
paralleluse parallel comms

Definition at line 211 of file globalOffset.H.

◆ calculate() [3/3]

template<class IntType>
template<class Int, class = std::enable_if_t<std::is_integral_v<Int>>>
List< OffsetRange< Int > > calculate ( const UList< Int > & localSizes,
int communicator = UPstream::worldComm,
bool parallel = UPstream::parRun() )
inlinestatic

Return a list of globally-consistent start/size/total ranges based on the given local input sizes.

Parameters
communicatorcommunicator
paralleluse parallel comms

Definition at line 230 of file globalOffset.H.

◆ isLocal()

template<class IntType>
bool isLocal ( IntType i) const
inlinenoexcept

Test if index is within the range. Same as contains().

Definition at line 248 of file globalOffset.H.

◆ toGlobal() [1/2]

template<class IntType>
template<class IntType2>
IntType2 toGlobal ( IntType2 i) const
inlinenoexcept

From local to global index.

Definition at line 257 of file globalOffset.H.

◆ toGlobal() [2/2]

template<class IntType>
template<class IntType2>
List< IntType2 > toGlobal ( const UList< IntType2 > & labels) const

Convert a list from local to global index.

◆ inplaceToGlobal()

template<class IntType>
template<class IntType2>
void inplaceToGlobal ( UList< IntType2 > & labels) const

Convert a list (inplace) from local to global index.

◆ toLocal()

template<class IntType>
template<class IntType2>
IntType2 toLocal ( IntType2 i) const

From global to local.

FatalError for an out-of-range value


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