Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
globalIndex Class Reference

Calculates a unique integer (label so might not have enough room - 2G max) for processor + local index. E.g. More...

Classes

class  const_iterator
 

Public Types

enum  accessType : char { OFFSETS, SIZES }
 

Public Member Functions

 globalIndex ()=default
 
 globalIndex (const labelUList &listOffsets)
 
 globalIndex (labelList &&listOffsets)
 
 globalIndex (const labelUList &offsetsOrSizes, enum accessType accType)
 
 globalIndex (const label localSize)
 
 globalIndex (const label localSize, const int tag, const label comm, const bool parallel)
 
 globalIndex (Istream &is)
 
bool empty () const
 
label size () const
 
labelList sizes () const
 
const labelUList localStarts () const
 
label maxSize () const
 
const labelListoffsets () const noexcept
 
label nProcs () const noexcept
 
labelRange allProcs () const noexcept
 
labelRange subProcs () const noexcept
 
labelListoffsets () noexcept
 
void reset (const label localSize)
 
void reset (const label localSize, const int tag, const label comm, const bool parallel)
 
void reset (const labelUList &sizes, const bool checkOverflow=false)
 
void setLocalSize (const label proci, const label len)
 
label localStart () const
 
label localSize () const
 
label maxNonLocalSize () const
 
labelRange range () const
 
List< labelRangeranges () const
 
bool isLocal (const label i) const
 
label toGlobal (const label i) const
 
labelList toGlobal (const labelUList &labels) const
 
void inplaceToGlobal (labelList &labels) const
 
label toLocal (const label i) const
 
label offset (const label proci) const
 
label localStart (const label proci) const
 
label localSize (const label proci) const
 
label maxNonLocalSize (const label proci) const
 
labelRange range (const label proci) const
 
bool isLocal (const label proci, const label i) const
 
label toGlobal (const label proci, const label i) const
 
labelList toGlobal (const label proci, const labelUList &labels) const
 
void inplaceToGlobal (const label proci, labelList &labels) const
 
label toLocal (const label proci, const label i) const
 
label whichProcID (const label i) const
 
const_iterator cbegin () const noexcept
 
const const_iterator cend () const noexcept
 
const_iterator begin () const noexcept
 
const const_iterator end () const noexcept
 
template<class ProcIDsContainer , class Type >
void gather (const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking) const
 
template<class Type >
void gather (const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm) const
 
template<class Type , class Addr >
void gather (const IndirectListBase< Type, Addr > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::scheduled, const label comm=UPstream::worldComm) const
 
template<class ProcIDsContainer , class Type >
void gather (const label comm, const ProcIDsContainer &procIDs, List< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking) const
 
template<class Type >
void gather (List< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm) const
 
template<class Type , class OutputContainer = List<Type>>
void mpiGather (const UList< Type > &sendData, OutputContainer &allValues, const label comm=UPstream::worldComm) const
 
template<class Type , class OutputContainer = List<Type>>
OutputContainer mpiGather (const UList< Type > &sendData, const label comm=UPstream::worldComm) const
 
template<class ProcIDsContainer , class Type >
void scatter (const label comm, const ProcIDsContainer &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking) const
 
template<class Type >
void scatter (const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm) const
 
template<class Type , class CombineOp >
void get (List< Type > &allFld, const labelUList &globalIds, const CombineOp &cop, const label comm=UPstream::worldComm, const int tag=UPstream::msgType()) const
 
template<class SubListType >
Foam::labelList calcListOffsets (const List< SubListType > &lists, const bool checkOverflow)
 

Static Public Member Functions

static labelList calcOffsets (const labelUList &localSizes, const bool checkOverflow=false)
 
template<class SubListType >
static labelList calcListOffsets (const List< SubListType > &lists, const bool checkOverflow=false)
 
static List< labelRangecalcRanges (const labelUList &localSizes, const bool checkOverflow=false)
 
template<class ProcIDsContainer , class Type >
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 Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
 
template<class Type , class Addr >
static void gather (const labelUList &offsets, const label comm, const UList< int > &procIDs, const IndirectListBase< Type, Addr > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::scheduled)
 
template<class ProcIDsContainer , class Type >
static void gather (const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, List< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
 
template<class Type >
static void gatherOp (const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
 
template<class Type >
static void gatherOp (List< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
 
template<class ProcIDsContainer , class Type >
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 Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
 

Friends

Istreamoperator>> (Istream &is, globalIndex &gi)
 
Ostreamoperator<< (Ostream &os, const globalIndex &gi)
 

Detailed Description

Calculates a unique integer (label so might not have enough room - 2G max) for processor + local index. E.g.

globalIndex globalFaces(mesh.nFaces()); label globalFacei = globalFaces.toGlobal(facei);

Source files

Definition at line 64 of file globalIndex.H.

Member Enumeration Documentation

◆ accessType

enum accessType : char
Enumerator
OFFSETS 
SIZES 

Definition at line 89 of file globalIndex.H.

Constructor & Destructor Documentation

◆ globalIndex() [1/7]

globalIndex ( )
default

◆ globalIndex() [2/7]

globalIndex ( const labelUList listOffsets)
inlineexplicit

Definition at line 28 of file globalIndexI.H.

References UList::size().

Here is the call graph for this function:

◆ globalIndex() [3/7]

globalIndex ( labelList &&  listOffsets)
inlineexplicit

Definition at line 40 of file globalIndexI.H.

References UList::size().

Here is the call graph for this function:

◆ globalIndex() [4/7]

globalIndex ( const labelUList offsetsOrSizes,
enum accessType  accType 
)
inline

Definition at line 56 of file globalIndexI.H.

References reset(), and UList::size().

Here is the call graph for this function:

◆ globalIndex() [5/7]

globalIndex ( const label  localSize)
inlineexplicit

Definition at line 73 of file globalIndexI.H.

References globalIndex::localSize(), and globalIndex::reset().

Here is the call graph for this function:

◆ globalIndex() [6/7]

globalIndex ( const label  localSize,
const int  tag,
const label  comm,
const bool  parallel 
)
inline
Parameters
tagmessage tag
commcommunicator
paralleluse parallel comms

Definition at line 80 of file globalIndexI.H.

References reset().

Here is the call graph for this function:

◆ globalIndex() [7/7]

globalIndex ( Istream is)
explicit

Definition at line 104 of file globalIndex.C.

Member Function Documentation

◆ empty()

bool empty ( ) const
inline

Definition at line 93 of file globalIndexI.H.

◆ size()

Foam::label size ( ) const
inline

◆ sizes()

Foam::labelList sizes ( ) const

Definition at line 258 of file globalIndex.C.

References List::resize(), and Foam::HashTableOps::values().

Referenced by PatchTools::gatherAndMerge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ localStarts()

const Foam::labelUList localStarts ( ) const
inline

Definition at line 134 of file globalIndexI.H.

References UList::null().

Here is the call graph for this function:

◆ maxSize()

Foam::label maxSize ( ) const
inline

Definition at line 186 of file globalIndexI.H.

Referenced by Foam::ensightOutput::writeCloudPositions(), and Foam::ensightOutput::Detail::writeFieldContent().

Here is the caller graph for this function:

◆ offsets() [1/2]

Foam::labelList & offsets ( ) const
inlinenoexcept

Definition at line 122 of file globalIndexI.H.

◆ nProcs()

Foam::label nProcs ( ) const
inlinenoexcept

Definition at line 99 of file globalIndexI.H.

Referenced by globalIndex::mpiGather().

Here is the caller graph for this function:

◆ allProcs()

Foam::labelRange allProcs ( ) const
inlinenoexcept

Definition at line 106 of file globalIndexI.H.

◆ subProcs()

Foam::labelRange subProcs ( ) const
inlinenoexcept

◆ offsets() [2/2]

labelList& offsets ( )
inlinenoexcept

◆ reset() [1/3]

void reset ( const label  localSize)
inline

◆ reset() [2/3]

void reset ( const label  localSize,
const int  tag,
const label  comm,
const bool  parallel 
)
Parameters
tagmessage tag
commcommunicator
paralleluse parallel comms

Definition at line 173 of file globalIndex.C.

References Pstream::gatherList(), UPstream::myProcNo(), UPstream::nProcs(), reset(), Pstream::scatterList(), and Foam::Zero.

Here is the call graph for this function:

◆ reset() [3/3]

void reset ( const labelUList sizes,
const bool  checkOverflow = false 
)

Definition at line 204 of file globalIndex.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::flatOutput(), Foam::labelMax, Foam::nl, and UList::size().

Here is the call graph for this function:

◆ setLocalSize()

void setLocalSize ( const label  proci,
const label  len 
)

Definition at line 240 of file globalIndex.C.

References delta.

◆ localStart() [1/2]

Foam::label localStart ( ) const
inline

◆ localSize() [1/2]

Foam::label localSize ( ) const
inline

◆ maxNonLocalSize() [1/2]

Foam::label maxNonLocalSize ( ) const
inline

Definition at line 193 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by Foam::ensightOutput::writeCloudField(), Foam::vtk::writeListParallel(), and Foam::vtk::writeListsParallel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ range() [1/2]

Foam::labelRange range ( ) const
inline

Definition at line 205 of file globalIndexI.H.

References UPstream::myProcNo(), and range.

Here is the call graph for this function:

◆ ranges()

Foam::List< Foam::labelRange > ranges ( ) const

Definition at line 281 of file globalIndex.C.

References List::resize(), and Foam::HashTableOps::values().

Here is the call graph for this function:

◆ isLocal() [1/2]

bool isLocal ( const label  i) const
inline

◆ toGlobal() [1/4]

Foam::label toGlobal ( const label  i) const
inline

◆ toGlobal() [2/4]

Foam::labelList toGlobal ( const labelUList labels) const
inline

Definition at line 253 of file globalIndexI.H.

References UPstream::myProcNo().

Here is the call graph for this function:

◆ inplaceToGlobal() [1/2]

void inplaceToGlobal ( labelList labels) const
inline

Definition at line 276 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by faceAreaWeightAMI2D::calculate(), faceAreaWeightAMI::calculate(), and cyclicAMIPolyPatch::setAMIFaces().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toLocal() [1/2]

Foam::label toLocal ( const label  i) const
inline

◆ offset()

Foam::label offset ( const label  proci) const
inline

Definition at line 156 of file globalIndexI.H.

Referenced by simpleGeomDecomp::decompose(), metisLikeDecomp::decomposeGeneral(), SprayCloud::penetration(), and Foam::vtk::writeListParallel().

Here is the caller graph for this function:

◆ localStart() [2/2]

Foam::label localStart ( const label  proci) const
inline

Definition at line 162 of file globalIndexI.H.

◆ localSize() [2/2]

Foam::label localSize ( const label  proci) const
inline

Definition at line 174 of file globalIndexI.H.

◆ maxNonLocalSize() [2/2]

Foam::label maxNonLocalSize ( const label  proci) const

Definition at line 307 of file globalIndex.C.

References Foam::max().

Here is the call graph for this function:

◆ range() [2/2]

Foam::labelRange range ( const label  proci) const
inline

Definition at line 199 of file globalIndexI.H.

◆ isLocal() [2/2]

bool isLocal ( const label  proci,
const label  i 
) const
inline

Definition at line 211 of file globalIndexI.H.

◆ toGlobal() [3/4]

Foam::label toGlobal ( const label  proci,
const label  i 
) const
inline

Definition at line 224 of file globalIndexI.H.

◆ toGlobal() [4/4]

Foam::labelList toGlobal ( const label  proci,
const labelUList labels 
) const
inline

Definition at line 240 of file globalIndexI.H.

◆ inplaceToGlobal() [2/2]

void inplaceToGlobal ( const label  proci,
labelList labels 
) const
inline

Definition at line 262 of file globalIndexI.H.

◆ toLocal() [2/2]

Foam::label toLocal ( const label  proci,
const label  i 
) const
inline

Definition at line 283 of file globalIndexI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.

Here is the call graph for this function:

◆ whichProcID()

Foam::label whichProcID ( const label  i) const
inline

◆ cbegin()

Foam::globalIndex::const_iterator cbegin ( ) const
inlinenoexcept

Definition at line 430 of file globalIndexI.H.

◆ cend()

const Foam::globalIndex::const_iterator cend ( ) const
inlinenoexcept

Definition at line 437 of file globalIndexI.H.

◆ begin()

Foam::globalIndex::const_iterator begin ( ) const
inlinenoexcept

Definition at line 444 of file globalIndexI.H.

◆ end()

const Foam::globalIndex::const_iterator end ( ) const
inlinenoexcept

Definition at line 451 of file globalIndexI.H.

◆ calcOffsets()

Foam::labelList calcOffsets ( const labelUList localSizes,
const bool  checkOverflow = false 
)
static

Definition at line 29 of file globalIndex.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::flatOutput(), Foam::labelMax, Foam::nl, List::resize(), UList::size(), and Foam::HashTableOps::values().

Here is the call graph for this function:

◆ calcListOffsets() [1/2]

static labelList calcListOffsets ( const List< SubListType > &  lists,
const bool  checkOverflow = false 
)
static

◆ calcRanges()

Foam::List< Foam::labelRange > calcRanges ( const labelUList localSizes,
const bool  checkOverflow = false 
)
static

Definition at line 67 of file globalIndex.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::flatOutput(), Foam::labelMax, Foam::nl, List::resize(), UList::size(), and Foam::HashTableOps::values().

Here is the call graph for this function:

◆ gather() [1/8]

void gather ( const labelUList offsets,
const label  comm,
const ProcIDsContainer &  procIDs,
const UList< Type > &  fld,
List< Type > &  allFld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
)
static
Parameters
commcommunicator

Definition at line 68 of file globalIndexTemplates.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, fld, UList::last(), Foam::blockMeshTools::read(), List::resize_nocopy(), and Foam::vtk::write().

Referenced by globalIndex::gather(), PatchTools::gatherAndMerge(), globalIndex::gatherOp(), and GAMGAgglomeration::procAgglomerateRestrictAddressing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gather() [2/8]

void gather ( const labelUList offsets,
const label  comm,
const UList< int > &  procIDs,
const IndirectListBase< Type, Addr > &  fld,
List< Type > &  allFld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::scheduled 
)
static
Parameters
commcommunicator

Definition at line 223 of file globalIndexTemplates.C.

References Foam::exit(), Foam::FatalError, fld, UList::last(), List::resize_nocopy(), UList::size(), and WarningInFunction.

Here is the call graph for this function:

◆ gather() [3/8]

void gather ( const label  comm,
const ProcIDsContainer &  procIDs,
const UList< Type > &  fld,
List< Type > &  allFld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
) const
inline
Parameters
commcommunicator

Definition at line 409 of file globalIndex.H.

References fld, and globalIndex::gather().

Here is the call graph for this function:

◆ gather() [4/8]

void gather ( const UList< Type > &  fld,
List< Type > &  allFld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking,
const label  comm = UPstream::worldComm 
) const
Parameters
commcommunicator

Definition at line 287 of file globalIndexTemplates.C.

References fld.

◆ gather() [5/8]

void gather ( const IndirectListBase< Type, Addr > &  fld,
List< Type > &  allFld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::scheduled,
const label  comm = UPstream::worldComm 
) const
Parameters
commcommunicator

Definition at line 309 of file globalIndexTemplates.C.

References fld.

◆ gather() [6/8]

void gather ( const labelUList offsets,
const label  comm,
const ProcIDsContainer &  procIDs,
List< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
)
static
Parameters
commcommunicator

Definition at line 332 of file globalIndexTemplates.C.

References fld.

◆ gather() [7/8]

void gather ( const label  comm,
const ProcIDsContainer &  procIDs,
List< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
) const
inline
Parameters
commcommunicator

Definition at line 463 of file globalIndex.H.

References fld, and globalIndex::gather().

Here is the call graph for this function:

◆ gather() [8/8]

void gather ( List< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking,
const label  comm = UPstream::worldComm 
) const
Parameters
commcommunicator

Definition at line 354 of file globalIndexTemplates.C.

References fld.

◆ mpiGather() [1/2]

void mpiGather ( const UList< Type > &  sendData,
OutputContainer &  allValues,
const label  comm = UPstream::worldComm 
) const

◆ mpiGather() [2/2]

OutputContainer mpiGather ( const UList< Type > &  sendData,
const label  comm = UPstream::worldComm 
) const
Parameters
commcommunicator

Definition at line 452 of file globalIndexTemplates.C.

◆ gatherOp() [1/2]

void gatherOp ( const UList< Type > &  fld,
List< Type > &  allFld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
)
static

Definition at line 465 of file globalIndexTemplates.C.

References fld, and globalIndex::gather().

Referenced by sampledSet::gather(), mergedSurf::merge(), and surfaceWriter::mergeFieldTemplate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gatherOp() [2/2]

void gatherOp ( List< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
)
static

Definition at line 478 of file globalIndexTemplates.C.

References fld, and globalIndex::gather().

Here is the call graph for this function:

◆ scatter() [1/3]

void scatter ( const labelUList offsets,
const label  comm,
const ProcIDsContainer &  procIDs,
const UList< Type > &  allFld,
UList< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
)
static
Parameters
commcommunicator

Definition at line 490 of file globalIndexTemplates.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, fld, Foam::blockMeshTools::read(), and Foam::vtk::write().

Referenced by globalIndex::scatter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scatter() [2/3]

void scatter ( const label  comm,
const ProcIDsContainer &  procIDs,
const UList< Type > &  allFld,
UList< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
) const
inline
Parameters
commcommunicator

Definition at line 550 of file globalIndex.H.

References fld, and globalIndex::scatter().

Here is the call graph for this function:

◆ scatter() [3/3]

void scatter ( const UList< Type > &  allFld,
UList< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking,
const label  comm = UPstream::worldComm 
) const
Parameters
commcommunicator

Definition at line 642 of file globalIndexTemplates.C.

References fld.

◆ get()

void get ( List< Type > &  allFld,
const labelUList globalIds,
const CombineOp &  cop,
const label  comm = UPstream::worldComm,
const int  tag = UPstream::msgType() 
) const
Parameters
commcommunicator

Definition at line 665 of file globalIndexTemplates.C.

References PstreamBuffers::finishedSends(), fld, forAll, CompactListList::offsets(), os(), List::resize_nocopy(), and UList::size().

Here is the call graph for this function:

◆ calcListOffsets() [2/2]

Foam::labelList calcListOffsets ( const List< SubListType > &  lists,
const bool  checkOverflow 
)

Definition at line 29 of file globalIndexTemplates.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::labelMax, Foam::nl, List::resize(), and Foam::HashTableOps::values().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream is,
globalIndex gi 
)
friend

◆ operator<<

Ostream& operator<< ( Ostream os,
const globalIndex gi 
)
friend

The documentation for this class was generated from the following files: