44#ifndef Foam_UPstreamReduceOffsets_H
45#define Foam_UPstreamReduceOffsets_H
62template<
class IntType>
66 const int communicator
72 IntType work =
range.size();
103 const int communicator,
104 std::index_sequence<Is...>,
105 OffsetRanges&... items
114 std::array<IntType,
sizeof...(items)> work{ (items.size())... };
123 ((items.start() = work[Is]), ...);
130 ((work[Is] += items.size()), ...);
135 ((items.total() = work[Is]), ...);
155template<
class IntType>
188 class = std::enable_if_t
191 std::is_integral_v<typename OffsetRangeT::value_type>
194 && (std::is_base_of_v
201 const int communicator,
208 using IntType =
typename OffsetRangeT::value_type;
210 if constexpr (
sizeof...(rest) == 0)
225 std::make_index_sequence<1 +
sizeof...(rest)>{},
244 class = std::enable_if_t
247 std::is_integral_v<typename OffsetRangeT::value_type>
255 const int communicator,
260 const auto len = ranges.
size();
273 using IntType =
typename OffsetRangeT::value_type;
280 for (label i = 0; i < len; ++i)
282 work[i] = ranges[i].
size();
293 for (label i = 0; i < len; ++i)
295 ranges[i].start() = work[i];
296 work[i] += ranges[i].
size();
304 for (label i = 0; i < len; ++i)
306 ranges[i].total() = work[i];
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.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static void mpiExscan_sum(T values[], int count, const int communicator)
Exclusive sum scan (in-place).
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
@ broadcast
broadcast [MPI]
Implementation details for UPstream/Pstream/MPI etc.
void reduce_offsetRanges(const int communicator, std::index_sequence< Is... >, OffsetRanges &... items)
void reduce_offsetRange(Foam::OffsetRange< IntType > &range, const int communicator)
void reduceOffset(Foam::OffsetRange< IntType > &range, const int communicator=UPstream::worldComm)
Parallel reduction of OffsetRange (eg, GlobalOffset) on its size value to yield the globally-consiste...
void reduceOffsets(const int communicator, OffsetRangeT &first, Rest &... rest)
Parallel reduction of multiple OffsetRange (eg, GlobalOffset) items.