38 if (listOffsets.
size() > 1)
40 offsets_ = listOffsets;
50 if (listOffsets.
size() > 1)
52 offsets_.transfer(listOffsets);
67 if (accType == accessType::SIZES)
69 reset(offsetsOrSizes);
71 else if (offsetsOrSizes.size() > 1)
74 offsets_ = offsetsOrSizes;
81 const label localSize,
86 reset(localSize, comm, parallel);
93 const label localSize,
100 offsets_[1] = localSize;
107 const label localSize,
119 const label localSize,
139 return offsets_.empty() || offsets_.back() == 0;
145 const label len = (offsets_.size() - 1);
146 return (len < 1) ? 0 : offsets_[len];
164 const label len = (offsets_.size() - 1);
165 return (len < 1) ? 0 : len;
172 const label len = (offsets_.size() - 1);
180 const label len = (offsets_.size() - 2);
205 const label len = (offsets_.size() - 1);
215 return offsets_[proci];
227 return offsets_[proci+1] - offsets_[proci];
240 return maxNonLocalSize(-1);
252 return labelRange(offsets_[proci], offsets_[proci+1] - offsets_[proci]);
264 return i >= offsets_[proci] && i < offsets_[proci+1];
280 return i + offsets_[proci];
297 inplaceToGlobal(proci, result);
318 const label off = offsets_[proci];
320 for (label& val : labels)
336 const label locali = i - offsets_[proci];
338 if (locali < 0 || i >= offsets_[proci+1])
341 <<
"Global " << i <<
" does not belong on processor " 342 << proci <<
nl <<
"Offsets:" << offsets_
357 if (i < 0 || i >= totalSize())
360 <<
"Global " << i <<
" does not belong on any processor." 361 <<
" Offsets:" << offsets_
367 return isLocal(proci, i) ? proci :
findLower(offsets_, i+1);
374 const label localSize,
378 offsets_.resize_nocopy(2);
380 offsets_[1] = localSize;
387 const label localSize,
399 const label localSize,
439 return (*parent_).localStart(proci_);
446 return (*parent_).localSize(proci_);
453 return (*parent_).range(proci_);
460 return this->
range();
503 Foam::globalIndex::const_iterator::
509 return (proci_ == iter.proci_);
514 Foam::globalIndex::const_iterator::
520 return (proci_ != iter.proci_);
550 return const_iterator(
this, this->nProcs());
bool isLocal(const label i) const
Is on local processor.
void reset(const label localSize, const label comm=UPstream::worldComm, const bool parallel=UPstream::parRun())
Reset from local size, using gather/broadcast with default/specified communicator if parallel...
void size(const label n)
Older name for setAddressableSize.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A range or interval of labels defined by a start and a size.
constexpr char nl
The newline '\n' character (0x0a)
static List< T > listGatherValues(const T &localValue, const label communicator=worldComm)
Gather individual values into list locations.
Dispatch tag. Construct 'one-sided' from local sizes, using gather but no broadcast.
SubList< label > subList
Declare type of subList.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
void inplaceToGlobal(labelUList &labels) const
From local to global index (inplace)
label proci() const noexcept
The associated local proc.
UList< label > labelUList
A UList of labels.
labelRange range() const
Return start/size range of local processor data.
label nProcs() const noexcept
The number of processors covered by the offsets.
Various functions to operate on Lists.
globalIndex() noexcept=default
Default construct (empty)
const labelList & offsets() const noexcept
Const-access to the offsets.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Dispatch tag. Construct with a single (local size) entry, no communication.
Forward input iterator with const access.
const_iterator cbegin() const noexcept
A const_iterator set to the beginning.
const_iterator begin() const noexcept
A const_iterator set to the beginning.
label size() const
Global sum of localSizes. Same as totalSize()
labelRange range() const
The local range.
label toLocal(const label i) const
From global to local on current processor.
label whichProcID(const label i) const
Which processor does global id come from?
labelRange operator*() const
The local range.
errorManip< error > abort(error &err)
label size() const
The local size.
labelList sizes() const
The local sizes. Same as localSizes()
static const UList< label > & null()
Return a UList reference to a nullObject.
const const_iterator end() const noexcept
A const_iterator set to beyond the end.
labelRange subProcs() const noexcept
Range of process indices for addressed sub-offsets (processes)
labelRange allProcs() const noexcept
Range of process indices for all addressed offsets (processes)
label toGlobal(const label i) const
From local to global index.
const_iterator & operator++()
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
accessType
Disambiguation tag (list construction dispatch)
label localStart() const
My local start.
bool empty() const
Check for default constructed or global sum == 0.
const const_iterator cend() const noexcept
A const_iterator set to beyond the end.
List< label > labelList
A List of labels.
label start() const
The local start.
const_iterator & operator--()
label maxSize() const
Global max of localSizes.
void clear()
Reset to be empty (no offsets)
Dispatch tag. Construct 'one-sided' from the non-master local sizes using gather but no broadcast...
label totalSize() const
Global sum of localSizes.
const_iterator(const globalIndex *globalIdx, const label proci=0) noexcept
Construct from globalIndex list at given index.
label maxNonLocalSize() const
The max of localSizes, excluding current processor.
label localSize() const
My local size.
const labelUList localStarts() const
The local starts.