44 #ifndef Foam_globalIndex_H 45 #define Foam_globalIndex_H 59 Istream&
operator>>(Istream& is, globalIndex& gi);
94 static void reportOverflowAndExit
97 const label prevOffset = -1,
126 return NullObjectRef<globalIndex>();
156 const label comm =
UPstream::worldComm,
157 const
bool parallel =
UPstream::parRun()
165 const label comm = -1
177 const label comm =
UPstream::worldComm
190 const label comm =
UPstream::worldComm
208 inline label
size() const;
286 const label comm =
UPstream::worldComm,
287 const
bool parallel =
UPstream::parRun()
296 const
bool checkOverflow = false
304 const label comm = -1
316 const label comm =
UPstream::worldComm
329 const label comm =
UPstream::worldComm
345 inline label
localStart(const label proci) const;
348 inline label
localEnd(const label proci) const;
351 inline label
localSize(const label proci) const;
360 inline
bool isLocal(const label proci, const label i) const;
363 inline label
toGlobal(const label proci, const label i) const;
381 inline label
toLocal(const label proci, const label i) const;
386 inline label
findProc(const label proci, const label i) const;
391 inline label
findProcAbove(const label proci, const label i) const;
397 inline label
findProcBelow(const label proci, const label i) const;
403 inline label
whichProcID(const label proci, const label i) const;
424 inline
bool isLocal(const label i) const;
427 inline label
toGlobal(const label i) const;
437 inline label
toLocal(const label i) const;
473 inline label index()
const noexcept;
476 inline label start()
const;
479 inline label
size()
const;
516 inline const_iterator
begin(const label proci) const
noexcept;
535 const label comm =
UPstream::worldComm,
536 const
bool checkOverflow = false
546 const label comm =
UPstream::worldComm,
547 const
bool checkOverflow = false
555 const
bool checkOverflow = false
564 const
bool checkOverflow = false
569 template<class SubListType>
572 const
List<SubListType>& lists,
573 const
bool checkOverflow = false
581 const
bool checkOverflow = false
593 const label communicator =
UPstream::worldComm,
595 const
bool absoluteLocalNodeOffsets = false
604 template<class ProcIDsContainer, class Type>
609 const ProcIDsContainer& procIDs,
610 const Type& localValue,
611 const
int tag =
UPstream::msgType(),
617 template<class ProcIDsContainer, class Type>
622 const ProcIDsContainer& procIDs,
626 const
int tag =
UPstream::msgType(),
632 template<class ProcIDsContainer, class Type, class Addr>
637 const ProcIDsContainer& procIDs,
641 const
int tag =
UPstream::msgType(),
646 template<class ProcIDsContainer, class Type>
651 const ProcIDsContainer& procIDs,
653 const
int tag =
UPstream::msgType(),
659 template<class ProcIDsContainer, class Type>
663 const ProcIDsContainer& procIDs,
667 const
int tag =
UPstream::msgType(),
673 template<class ProcIDsContainer, class Type>
677 const ProcIDsContainer& procIDs,
679 const
int tag =
UPstream::msgType(),
707 template<
class Type,
class Addr>
724 template<
class Type,
class OutputContainer = List<Type>>
738 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
766 template<
class Type,
class OutputContainer = List<Type>>
771 OutputContainer& allData,
786 template<
class Type,
class OutputContainer = List<Type>>
826 template<
class Type,
class OutputContainer = List<Type>>
830 OutputContainer& allData,
843 template<
class Type,
class OutputContainer = List<Type>>
890 template<
class Type,
class Addr>
906 template<
class Type,
class OutputContainer = List<Type>>
921 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
952 template<
class ProcIDsContainer,
class Type>
957 const ProcIDsContainer& procIDs,
968 template<
class ProcIDsContainer,
class Type>
972 const ProcIDsContainer& procIDs,
979 scatter(offsets_, comm, procIDs, allFld,
fld, tag, commsType);
1000 template<
class Type,
class OutputContainer = List<Type>>
1016 template<
class Type,
class CombineOp>
1021 const CombineOp& cop,
1038 return !(*
this == rhs);
1044 return (this->
offsets() < rhs.offsets());
1101 #include "globalIndex.txx" 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 const globalIndex & null() noexcept
Return a null globalIndex (reference to a nullObject). Behaves like an empty globalIndex.
static void mpiGatherOp(const UList< Type > &sendData, OutputContainer &allData, const label comm=UPstream::worldComm, UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking, const int tag=UPstream::msgType())
Use MPI_Gatherv call to collect contiguous data when possible (in serial: performs a simple copy)...
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 void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, UList< Type > &allFld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
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.
static void gatherInplaceOp(List< Type > &fld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm)
Inplace collect data in processor order on master (in serial: a no-op).
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.
static List< Type > listGatherValues(const label comm, const ProcIDsContainer &procIDs, const Type &localValue, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Collect single values in processor order on master (== procIDs[0]).
bool single() const noexcept
True if local-only content (ie, nProcs == 1). Such content is often created with gatherNone.
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...
static void mpiGatherInplaceOp(List< Type > &fld, const label comm=UPstream::worldComm, UPstream::commsTypes commsType=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 totalSize() const noexcept
The total addressed size, which corresponds to the end offset and also the sum of all localSizes...
void mpiGatherInplace(List< Type > &fld, const label comm=UPstream::worldComm, UPstream::commsTypes commsType=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)...
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.
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.
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 gatherOp(const UList< Type > &sendData, List< Type > &allData, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm)
Collect data in processor order on master (in serial: performs a simple copy).
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)
bool splitNodeOffsets(labelList &interNodeOffsets, labelList &localNodeOffsets, const label communicator=UPstream::worldComm, const bool absoluteLocalNodeOffsets=false) const
Split the top-level offsets into inter-node and local-node components suitable to a two-stage hierarc...
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)
static void gatherInplace(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, List< Type > &fld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Inplace collect in processor order on master (== procIDs[0]).
label toGlobal(const label proci, const label i) const
From local to global on proci.
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)
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.
label localStart() const
Local start on myProcNo()
const const_iterator cend() const noexcept
A const_iterator set to beyond the end.
static void scatter(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Distribute data in processor order.
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 mpiGather(const UList< Type > &sendData, OutputContainer &allData, const label comm=UPstream::worldComm, UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking, const int tag=UPstream::msgType()) const
Use MPI_Gatherv call for contiguous data when possible (in serial: performs a simple copy)...
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...
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.