39 if (listOffsets.
size() > 1)
41 offsets_ = listOffsets;
51 if (listOffsets.size() > 1)
53 offsets_.transfer(listOffsets);
68 if (accType == accessType::SIZES)
70 reset(offsetsOrSizes);
72 else if (offsetsOrSizes.
size() > 1)
75 offsets_ = offsetsOrSizes;
82 const label localSize,
87 reset(localSize, comm, parallel);
93 const label localSize,
105 const label localSize,
121 return offsets_.empty() || offsets_.last() == 0;
127 const label len = (offsets_.size() - 1);
128 return (len < 1) ?
static_cast<label
>(0) : offsets_[len];
146 const label len = (offsets_.size() - 1);
147 return (len < 1) ?
static_cast<label
>(0) : len;
154 const label len = (offsets_.size() - 1);
162 const label len = (offsets_.size() - 2);
181 const label len = (offsets_.size() - 1);
191 return offsets_[proci];
203 return offsets_[proci+1] - offsets_[proci];
216 return maxNonLocalSize(-1);
228 return labelRange(offsets_[proci], offsets_[proci+1] - offsets_[proci]);
240 return i >= offsets_[proci] && i < offsets_[proci+1];
256 return i + offsets_[proci];
273 inplaceToGlobal(proci, result);
294 const label off = offsets_[proci];
296 for (label& val : labels)
312 const label locali = i - offsets_[proci];
314 if (locali < 0 || i >= offsets_[proci+1])
317 <<
"Global " << i <<
" does not belong on processor "
318 << proci <<
nl <<
"Offsets:" << offsets_
331inline Foam::label Foam::globalIndex::whichProcID(
const label i)
const
333 if (i < 0 || i >= totalSize())
336 <<
"Global " << i <<
" does not belong on any processor."
337 <<
" Offsets:" << offsets_
343 return isLocal(proci, i) ? proci :
findLower(offsets_, i+1);
349inline Foam::globalIndex::const_iterator::
352 const globalIndex* globalIdx,
361inline Foam::label Foam::globalIndex::const_iterator::
368inline Foam::label Foam::globalIndex::const_iterator::
371 return (*parent_).localStart(proci_);
375inline Foam::label Foam::globalIndex::const_iterator::
378 return (*parent_).localSize(proci_);
385 return (*parent_).range(proci_);
392 return this->
range();
397Foam::globalIndex::const_iterator::
406Foam::globalIndex::const_iterator::
409 const_iterator old(*
this);
416Foam::globalIndex::const_iterator::
425Foam::globalIndex::const_iterator::
428 const_iterator old(*
this);
435Foam::globalIndex::const_iterator::
438 const const_iterator& iter
441 return (proci_ == iter.proci_);
446Foam::globalIndex::const_iterator::
449 const const_iterator& iter
452 return (proci_ != iter.proci_);
461 return const_iterator(
this);
468 return const_iterator(
this, this->nProcs());
475 return const_iterator(
this);
480Foam::globalIndex::end() const
noexcept
482 return const_iterator(
this, this->nProcs());
Various functions to operate on Lists.
SubList< label > subList
Declare type of subList.
static const UList< label > & null()
Return a UList reference to a nullObject.
void size(const label n)
Older name for setAddressableSize.
static List< T > listGatherValues(const T &localValue, const label communicator=worldComm)
Gather individual values into list locations.
A const_iterator for iterating across on values.
const edgeFaceCirculator cend() const
edgeFaceCirculator cbegin() const
edgeFaceCirculator begin() const
Iterator set to the beginning face. For internal edges this is.
label maxSize() const
Global max of localSizes.
globalIndex()=default
Default construct.
label localSize() const
My local size.
accessType
Disambiguation tag (list construction dispatch)
labelRange range() const
Return start/size range of local processor data.
label size() const
Global sum of localSizes. Same as totalSize()
label localStart() const
My local start.
bool empty() const
Check for default constructed or global sum == 0.
label nProcs() const noexcept
The number of processors covered by the offsets.
label toGlobal(const label i) const
From local to global index.
const labelUList localStarts() const
The local starts.
void inplaceToGlobal(labelUList &labels) const
From local to global index (inplace)
labelRange subProcs() const noexcept
Range of process indices for addressed sub-offsets (processes)
label maxNonLocalSize() const
The max of localSizes, excluding current processor.
label totalSize() const
Global sum of localSizes.
labelList sizes() const
The local sizes. Same as localSizes()
labelRange allProcs() const noexcept
Range of process indices for all addressed offsets (processes)
label toLocal(const label i) const
From global to local on current processor.
const labelList & offsets() const noexcept
Const-access to the offsets.
bool isLocal(const label i) const
Is on local processor.
A range or interval of labels defined by a start and a size.
int myProcNo() const noexcept
Return processor number.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
errorManip< error > abort(error &err)
constexpr char nl
The newline '\n' character (0x0a)