44#ifndef Foam_globalIndex_H
45#define Foam_globalIndex_H
60Istream&
operator>>(Istream& is, globalIndex& gi);
89 static void reportOverflowAndExit
156 const label
comm = -1
167 inline bool empty()
const;
170 inline label
size()
const;
234 const
bool checkOverflow = false
261 inline
bool isLocal(const label i) const;
264 inline label
toGlobal(const label i) const;
274 inline label
toLocal(const label i) const;
280 inline label
localStart(const label proci) const;
283 inline label
localSize(const label proci) const;
292 inline
bool isLocal(const label proci, const label i) const;
295 inline label
toGlobal(const label proci, const label i) const;
313 inline label
toLocal(const label proci, const label i) const;
319 inline label whichProcID(const label i) const;
339 explicit const_iterator
342 const label proci = 0
349 inline label proci() const
noexcept;
352 inline label start() const;
355 inline label
size() const;
363 inline const_iterator& operator++();
364 inline const_iterator operator++(
int);
366 inline const_iterator& operator--();
367 inline const_iterator operator--(
int);
369 inline
bool operator==(const const_iterator& iter) const
noexcept;
370 inline
bool operator!=(const const_iterator& iter) const
noexcept;
375 inline const_iterator cbegin() const
noexcept;
378 inline const const_iterator cend() const
noexcept;
381 inline const_iterator begin() const
noexcept;
384 inline const const_iterator end() const
noexcept;
394 const
bool checkOverflow = false
399 template<class SubListType>
402 const
List<SubListType>& lists,
403 const
bool checkOverflow = false
411 const
bool checkOverflow = false
416 template<class ProcIDsContainer, class Type>
420 const ProcIDsContainer& procIDs,
421 const Type& localValue,
422 List<Type>& allValues,
429 template<class ProcIDsContainer, class Type>
434 const ProcIDsContainer& procIDs,
443 template<class Type, class Addr>
448 const
UList<
int>& procIDs,
460 template<class ProcIDsContainer, class Type>
465 const ProcIDsContainer& procIDs,
475 fld.transfer(allData);
481 template<
class ProcIDsContainer,
class Type>
485 const ProcIDsContainer& procIDs,
498 template<
class ProcIDsContainer,
class Type>
502 const ProcIDsContainer& procIDs,
530 template<
class Type,
class Addr>
545 template<
class Type,
class OutputContainer = List<Type>>
558 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
587 template<
class Type,
class OutputContainer = List<Type>>
591 OutputContainer& allData,
606 template<
class Type,
class OutputContainer = List<Type>>
644 template<
class Type,
class OutputContainer = List<Type>>
648 OutputContainer& allData,
661 template<
class Type,
class OutputContainer = List<Type>>
709 template<
class Type,
class Addr>
724 template<
class Type,
class OutputContainer = List<Type>>
738 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
767 template<
class ProcIDsContainer,
class Type>
772 const ProcIDsContainer& procIDs,
783 template<
class ProcIDsContainer,
class Type>
787 const ProcIDsContainer& procIDs,
816 template<
class Type,
class OutputContainer = List<Type>>
831 template<
class Type,
class CombineOp>
836 const CombineOp& cop,
880 label offset(const label proci)
const {
return localStart(proci); }
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Inter-processor communications stream.
commsTypes
Types of communications.
@ nonBlocking
"nonBlocking"
static int & msgType() noexcept
Message tag of standard messages.
static label worldComm
Default communicator (all processors)
static bool & parRun() noexcept
Test if this a parallel run.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
void gather(const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const UPstream::commsTypes ct=UPstream::commsTypes::nonBlocking) const
Collect data in processor order on master (== procIDs[0]).
static void gatherInplaceOp(List< Type > &fld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm)
Inplace collect data in processor order on master (in serial: a no-op).
static void mpiGatherInplaceOp(List< Type > &fld, const label comm=UPstream::worldComm, const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const int tag=UPstream::msgType())
Use MPI_Gatherv call to inplace collect contiguous data when possible. (in serial: a no-op).
label maxSize() const
Global max of localSizes.
globalIndex()=default
Default construct.
label localSize() const
My local size.
accessType
Disambiguation tag (list construction dispatch)
void get(List< Type > &allFld, const labelUList &globalIds, const CombineOp &cop, const label comm=UPstream::worldComm, const int tag=UPstream::msgType()) const
Get (potentially remote) data. Elements required given as global indices.
friend Ostream & operator<<(Ostream &os, const globalIndex &gi)
labelRange range() const
Return start/size range of local processor data.
label size() const
Global sum of localSizes. Same as totalSize()
void reset(const label localSize, const label comm=UPstream::worldComm, const bool parallel=UPstream::parRun())
FOAM_DEPRECATED_FOR(2022-03, "construct without message tag") globalIndex(const label localSize
Construct from local size, using gather/broadcast with default/specified communicator if parallel.
List< labelRange > ranges() const
Return start/size ranges for all data.
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.
labelList & offsets() noexcept
Write-access to the offsets, for changing after construction.
FOAM_DEPRECATED_FOR(2022-02, "use localStart()") label offset(const label proci) const
Prefer localStart() to avoid confusing with offsets()
label toGlobal(const label i) const
From local to global index.
const labelUList localStarts() const
The local starts.
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
void inplaceToGlobal(labelUList &labels) const
From local to global index (inplace)
void gatherInplace(List< Type > &fld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm) const
Inplace collect data in processor order on master (in serial: a no-op).
static void scatter(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Distribute data in processor order.
const int const label comm
labelRange subProcs() const noexcept
Range of process indices for addressed sub-offsets (processes)
label maxNonLocalSize() const
The max of localSizes, excluding current processor.
void gather(const label comm, const ProcIDsContainer &procIDs, List< Type > &fld, const int tag=UPstream::msgType(), const UPstream::commsTypes ct=UPstream::commsTypes::nonBlocking) const
Inplace collect in processor order on master (== procIDs[0]).
void setLocalSize(const label proci, const label len)
Alter local size for given processor.
void mpiGather(const UList< Type > &sendData, OutputContainer &allData, const label comm=UPstream::worldComm, const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const int tag=UPstream::msgType()) const
Use MPI_Gatherv call for contiguous data when possible (in serial: performs a simple copy).
static void mpiGatherOp(const UList< Type > &sendData, OutputContainer &allData, const label comm=UPstream::worldComm, const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const int tag=UPstream::msgType())
Use MPI_Gatherv call to collect contiguous data when possible (in serial: performs a simple copy).
label totalSize() const
Global sum of localSizes.
FOAM_DEPRECATED_FOR(2022-03, "reset without message tag") void reset(const label localSize
Reset from local size, using gather/broadcast with default/specified communicator if parallel.
labelList sizes() const
The local sizes. Same as localSizes()
const int const label const bool parallel
static void gatherOp(const UList< Type > &sendData, List< Type > &allData, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm)
Collect data in processor order on master (in serial: performs a simple copy).
labelList localSizes() const
The local sizes.
labelRange allProcs() const noexcept
Range of process indices for all addressed offsets (processes)
void scatter(const label comm, const ProcIDsContainer &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const UPstream::commsTypes ct=UPstream::commsTypes::nonBlocking) const
Distribute data in processor order.
label toLocal(const label i) const
From global to local on current processor.
friend Istream & operator>>(Istream &is, globalIndex &gi)
static void gatherValues(const label comm, const ProcIDsContainer &procIDs, const Type &localValue, List< Type > &allValues, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Which processor does global id come from?
void mpiGatherInplace(List< Type > &fld, const label comm=UPstream::worldComm, const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const int tag=UPstream::msgType()) const
Use MPI_Gatherv call to inplace collect contiguous data when possible. (in serial: a no-op).
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.
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Istream & operator>>(Istream &, directionInfo &)
#define FOAM_DEPRECATED_FOR(since, replacement)