48#ifndef Foam_globalOffset_H
49#define Foam_globalOffset_H
71template<
class IntType>
80 template<
class IntegralType>
90 template<
class IntegralType>
146 inline void reset(IntType len)
noexcept;
173 return calculate_impl<IntType>(
localSize, communicator, parallel);
181 class = std::enable_if_t<std::is_integral_v<Int>>
190 return calculate_impl<Int>(
localSize, communicator, parallel);
198 class = std::enable_if_t<std::is_integral_v<Int>>
207 return calculateList_impl<Int>(localSizes, communicator, parallel);
216 bool isLocal(IntType i)
const noexcept
222 template<
class IntType2>
223 IntType2
toGlobal(IntType2 i)
const noexcept
225 return (this->
start() + i);
229 template<
class IntType2>
233 template<
class IntType2>
238 template<
class IntType2>
239 IntType2
toLocal(IntType2 i)
const;
251 #include "globalOffset.txx"
Implementation of IO operators for Foam::OffsetRange.
A Foam::OffsetRange (start, size, total) tuple with some additional parallel functionality....
void reset(IntType len, int communicator, bool parallel=UPstream::parRun())
Reset from local size, with parallel coordination of the offsets and total size.
List< IntType2 > toGlobal(const UList< IntType2 > &labels) const
Convert a list from local to global index.
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.
IntType localSize() const noexcept
Same as size() - method name as per globalIndex.
void inplaceToGlobal(UList< IntType2 > &labels) const
Convert a list (inplace) from local to global index.
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.
IntType2 toGlobal(IntType2 i) const noexcept
From local to global index.
label localStart() const noexcept
constexpr GlobalOffset() noexcept
Default construct as (0,0,0).
IntType2 toLocal(IntType2 i) const
From global to local.
void reduce(int communicator=UPstream::worldComm)
Based on the local input size, determine the globally-consistent start offset and total size.
IntType totalSize() const noexcept
Same as total() - method name as per globalIndex.
bool isLocal(IntType i) const noexcept
Test if index is within the range. Same as contains().
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.
void reset(IntType len) noexcept
Reset from local size with zero offset.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A tuple of integers comprising start, size, total.
IntRange< label > range() const noexcept
OffsetRange(const OffsetRange &) noexcept=default
Copy construct.
IntType start() const noexcept
The lower value of the range.
IntType size() const noexcept
The size.
IntType total() const noexcept
The total size.
bool contains(IntType value) const noexcept
True if the value is between the start and size range range.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Inter-processor communications stream.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
GlobalOffset< label > globalOffset
A GlobalOffset with label for the addressing.