44 #ifndef Foam_globalIndex_H 45 #define Foam_globalIndex_H 59 Istream&
operator>>(Istream& is, globalIndex& gi);
87 static void reportOverflowAndExit
90 const label prevOffset = -1,
139 const label comm =
UPstream::worldComm,
140 const
bool parallel =
UPstream::parRun()
148 const label comm = -1
160 const label comm =
UPstream::worldComm
173 const label comm =
UPstream::worldComm
191 inline label
size() const;
269 const label comm =
UPstream::worldComm,
270 const
bool parallel =
UPstream::parRun()
279 const
bool checkOverflow = false
287 const label comm = -1
299 const label comm =
UPstream::worldComm
312 const label comm =
UPstream::worldComm
328 inline label
localStart(const label proci) const;
331 inline label
localEnd(const label proci) const;
334 inline label
localSize(const label proci) const;
343 inline
bool isLocal(const label proci, const label i) const;
346 inline label
toGlobal(const label proci, const label i) const;
364 inline label
toLocal(const label proci, const label i) const;
369 inline label
findProc(const label proci, const label i) const;
374 inline label
findProcAbove(const label proci, const label i) const;
380 inline label
findProcBelow(const label proci, const label i) const;
386 inline label
whichProcID(const label proci, const label i) const;
407 inline
bool isLocal(const label i) const;
410 inline label
toGlobal(const label i) const;
420 inline label
toLocal(const label i) const;
456 inline label index()
const noexcept;
459 inline label start()
const;
462 inline label
size()
const;
518 const label comm =
UPstream::worldComm,
519 const
bool checkOverflow = false
529 const label comm =
UPstream::worldComm,
530 const
bool checkOverflow = false
538 const
bool checkOverflow = false
547 const
bool checkOverflow = false
552 template<class SubListType>
555 const
List<SubListType>& lists,
556 const
bool checkOverflow = false
564 const
bool checkOverflow = false
569 template<class ProcIDsContainer, class Type>
573 const ProcIDsContainer& procIDs,
574 const Type& localValue,
575 List<Type>& allValues,
576 const
int tag =
UPstream::msgType(),
582 template<class ProcIDsContainer, class Type>
587 const ProcIDsContainer& procIDs,
590 const
int tag =
UPstream::msgType(),
596 template<class ProcIDsContainer, class Type, class Addr>
601 const ProcIDsContainer& procIDs,
604 const
int tag =
UPstream::msgType(),
613 template<class ProcIDsContainer, class Type>
618 const ProcIDsContainer& procIDs,
620 const
int tag =
UPstream::msgType(),
627 const int masterProci = procIDs.size() ? procIDs[0] : 0;
630 fld.transfer(allData);
636 template<
class ProcIDsContainer,
class Type>
640 const ProcIDsContainer& procIDs,
647 gather(offsets_, comm, procIDs,
fld, allFld, tag, ct);
653 template<
class ProcIDsContainer,
class Type>
657 const ProcIDsContainer& procIDs,
663 gather(offsets_, comm, procIDs,
fld, tag, ct);
675 const UList<Type>& sendData,
685 template<
class Type,
class Addr>
688 const IndirectListBase<Type, Addr>& sendData,
700 template<
class Type,
class OutputContainer = List<Type>>
703 const UList<Type>& sendData,
713 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
716 const IndirectListBase<Type, Addr>& sendData,
742 template<
class Type,
class OutputContainer = List<Type>>
745 const UList<Type>& sendData,
746 OutputContainer& allData,
761 template<
class Type,
class OutputContainer = List<Type>>
764 const UList<Type>& sendData,
799 template<
class Type,
class OutputContainer = List<Type>>
802 const UList<Type>& sendData,
803 OutputContainer& allData,
816 template<
class Type,
class OutputContainer = List<Type>>
864 template<
class Type,
class Addr>
879 template<
class Type,
class OutputContainer = List<Type>>
893 template<
class Type,
class Addr,
class OutputContainer = List<Type>>
922 template<
class ProcIDsContainer,
class Type>
927 const ProcIDsContainer& procIDs,
938 template<
class ProcIDsContainer,
class Type>
942 const ProcIDsContainer& procIDs,
950 scatter(offsets_, comm, procIDs, allFld,
fld, tag, ct);
971 template<
class Type,
class OutputContainer = List<Type>>
986 template<
class Type,
class CombineOp>
991 const CombineOp& cop,
1008 return !(*
this == rhs);
1014 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)...
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...
static bool less(const vector &x, const vector &y)
To compare normals.
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" : (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.