44 #ifndef Foam_globalIndex_H 45 #define Foam_globalIndex_H 59 Istream&
operator>>(Istream& is, globalIndex& gi);
95 static void reportOverflowAndExit
98 const label prevOffset = -1,
127 return NullObjectRef<globalIndex>();
157 const label comm =
UPstream::worldComm,
158 const
bool parallel =
UPstream::parRun()
166 const label comm = -1
178 const label comm =
UPstream::worldComm
191 const label comm =
UPstream::worldComm
209 inline label
size() const;
287 const label comm =
UPstream::worldComm,
288 const
bool parallel =
UPstream::parRun()
297 const
bool checkOverflow = false
305 const label comm = -1
317 const label comm =
UPstream::worldComm
330 const label comm =
UPstream::worldComm
346 inline label
localStart(const label proci) const;
349 inline label
localEnd(const label proci) const;
352 inline label
localSize(const label proci) const;
361 inline
bool isLocal(const label proci, const label i) const;
364 inline label
toGlobal(const label proci, const label i) const;
382 inline label
toLocal(const label proci, const label i) const;
387 inline label
findProc(const label proci, const label i) const;
392 inline label
findProcAbove(const label proci, const label i) const;
398 inline label
findProcBelow(const label proci, const label i) const;
404 inline label
whichProcID(const label proci, const label i) const;
425 inline
bool isLocal(const label i) const;
428 inline label
toGlobal(const label i) const;
438 inline label
toLocal(const label i) const;
474 inline label index()
const noexcept;
477 inline label start()
const;
480 inline label
size()
const;
517 inline const_iterator
begin(const label proci) const
noexcept;
536 const label comm =
UPstream::worldComm,
537 const
bool checkOverflow = false
547 const label comm =
UPstream::worldComm,
548 const
bool checkOverflow = false
556 const
bool checkOverflow = false
565 const
bool checkOverflow = false
570 template<class SubListType>
573 const
List<SubListType>& lists,
574 const
bool checkOverflow = false
582 const
bool checkOverflow = false
587 template<class ProcIDsContainer, class Type>
591 const ProcIDsContainer& procIDs,
592 const Type& localValue,
593 List<Type>& allValues,
594 const
int tag =
UPstream::msgType(),
600 template<class ProcIDsContainer, class Type>
605 const ProcIDsContainer& procIDs,
608 const
int tag =
UPstream::msgType(),
614 template<class ProcIDsContainer, class Type, class Addr>
619 const ProcIDsContainer& procIDs,
622 const
int tag =
UPstream::msgType(),
631 template<class ProcIDsContainer, class Type>
636 const ProcIDsContainer& procIDs,
638 const
int tag =
UPstream::msgType(),
645 const int masterProci = procIDs.size() ? procIDs[0] : 0;
648 fld.transfer(allData);
654 template<
class ProcIDsContainer,
class Type>
658 const ProcIDsContainer& procIDs,
665 gather(offsets_, comm, procIDs,
fld, allFld, tag, ct);
671 template<
class ProcIDsContainer,
class Type>
675 const ProcIDsContainer& procIDs,
681 gather(offsets_, comm, procIDs,
fld, tag, ct);
693 const UList<Type>& sendData,
703 template<
class Type,
class Addr>
706 const IndirectListBase<Type, Addr>& sendData,
718 template<
class Type,
class OutputContainer = List<Type>>
721 const UList<Type>& sendData,
731 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
734 const IndirectListBase<Type, Addr>& sendData,
759 template<
class Type,
class OutputContainer = List<Type>>
762 const UList<Type>& sendData,
764 OutputContainer& allData,
779 template<
class Type,
class OutputContainer = List<Type>>
782 const UList<Type>& sendData,
818 template<
class Type,
class OutputContainer = List<Type>>
821 const UList<Type>& sendData,
822 OutputContainer& allData,
835 template<
class Type,
class OutputContainer = List<Type>>
881 template<
class Type,
class Addr>
897 template<
class Type,
class OutputContainer = List<Type>>
911 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
941 template<
class ProcIDsContainer,
class Type>
946 const ProcIDsContainer& procIDs,
957 template<
class ProcIDsContainer,
class Type>
961 const ProcIDsContainer& procIDs,
969 scatter(offsets_, comm, procIDs, allFld,
fld, tag, ct);
990 template<
class Type,
class OutputContainer = List<Type>>
1005 template<
class Type,
class CombineOp>
1010 const CombineOp& cop,
1027 return !(*
this == rhs);
1033 return (this->
offsets() < rhs.offsets());
label toLocal(const label proci, const label i) const
From global to local on proci.
static labelList calcOffsets(const labelUList &counts, const bool checkOverflow=false)
Calculate offsets from a list of local sizes, with optional check for label overflow.
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...
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)...
static const globalIndex & null() noexcept
Return a null globalIndex (reference to a nullObject). Behaves like an empty globalIndex.
commsTypes
Communications types.
List< labelRange > ranges() const
Return start/size ranges for all data.
A range or interval of labels defined by a start and a size.
bool operator<(const globalIndex &rhs) const
Compare for less-than - uses the offsets.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
label whichProcID(const label proci, const label i) const
Which processor does global id come from? Checks proci first (assumed to occur reasonably frequently)...
friend Ostream & operator<<(Ostream &os, const globalIndex &gi)
static List< labelRange > calcRanges(const labelUList &counts, const bool checkOverflow=false)
Calculate ranges (offset/size) from a list of local sizes, with optional check for label overflow...
Dispatch tag: Construct 'one-sided' from local sizes, using gather but no broadcast.
bool contains(const label i) const noexcept
True if contained within the offsets range.
label end_value() const noexcept
The value corresponding to the last offset (end offset), which is 1 beyond the end of the range...
label begin_value() const noexcept
The value corresponding to the first offset.
static int & msgType() noexcept
Message tag of standard messages.
label span() const noexcept
The span size covered by the offsets, zero if empty.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
friend Istream & operator>>(Istream &is, globalIndex &gi)
labelList localSizes() const
The local sizes.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
void inplaceToGlobal(const label proci, labelUList &labels) const
From local to global index on proci (inplace)
labelRange range() const
Return start/size range of local (myProcNo) data.
label findProcAbove(const label proci, const label i) const
Find processor above proci with specified global id - binary search.
label nProcs() const noexcept
The number of processors covered by the offsets, same as the primary length()
globalIndex() noexcept=default
Default construct (empty)
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
const labelList & offsets() const noexcept
Const-access to the offsets.
bool single() const noexcept
True if local-only content (ie, nProcs == 1). Such content is often created with gatherNone.
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)...
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label totalSize() const noexcept
The total addressed size, which corresponds to the end offset and also the sum of all localSizes...
Dispatch tag: Construct with a single (local size) entry, no communication.
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
bool operator==(const globalIndex &rhs) const
Compare for equality - uses the offsets.
static labelList calcListOffsets(const List< SubListType > &lists, const bool checkOverflow=false)
Calculate offsets from list of lists, with optional check for label overflow.
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)...
Forward input iterator with const access that is used to iterate across the globalIndex offsets() tab...
const_iterator cbegin() const noexcept
A const_iterator set to the beginning.
label offset(const label proci) const
Prefer localStart() to avoid confusing with offsets()
const_iterator begin() const noexcept
A const_iterator set to the beginning.
label length() const noexcept
The number of items covered by the offsets.
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)...
Istream & operator>>(Istream &, directionInfo &)
label size() const
Global sum of localSizes. Same as totalSize()
void setLocalSize(const label proci, const label len)
Alter local size for given processor.
bool isLocal(const label proci, const label i) const
Is on processor proci.
#define FOAM_DEPRECATED_STRICT(since, replacement)
A packed storage of objects of type <T> using an offset table for access.
labelList sizes() const
The local sizes. Same as localSizes()
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)
Collect single values in processor order on master (== procIDs[0]).
label findProc(const label proci, const label i) const
Find processor with specified global id. Check proci first, followed by binary search.
OBJstream os(runTime.globalPath()/outputName)
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)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
label toGlobal(const label proci, const label i) const
From local to global on proci.
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).
label findProcBelow(const label proci, const label i) const
Find processor below proci with specified global id - binary search.
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
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 labelRange calcRange(const label localSize, const label comm=UPstream::worldComm, const bool checkOverflow=false)
Calculate globally-consistent local range (offset/size) based on the local input size(s).
bool empty() const noexcept
Check for default constructed or total-size == 0.
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]).
label localStart() const
Local start on myProcNo()
const const_iterator cend() const noexcept
A const_iterator set to beyond the end.
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).
labelRange back() const
The last offset range. It is (0,0) if globalIndex is empty.
static label calcOffset(const label localSize, const label comm=UPstream::worldComm, const bool checkOverflow=false)
Calculate globally-consistent local start offset based on the local input size(s).
label maxSize() const
Global max of localSizes.
Inter-processor communications stream.
void clear()
Reset to be empty (no offsets)
bool operator!=(const globalIndex &rhs) const
Compare for inequality - uses the offsets.
label localEnd() const
Local end on myProcNo()
Dispatch tag: Construct 'one-sided' from the non-master local sizes using gather but no broadcast...
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.
label maxNonLocalSize() const
The max of localSizes, excluding current (myProcNo) rank.
void resize(const label n)
Change the number of entries (nProcs) in the offsets table. Extending will fill with empty local size...
label localSize() const
Local size on myProcNo()
const labelUList localStarts() const
The local starts.
labelRange front() const
The first offset range. It is (0,0) if globalIndex is empty.