globalIndex Class Reference

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

Public Member Functions

 globalIndex ()=default
 Construct null. More...
 
 globalIndex (const label localSize)
 Construct from local max size. More...
 
 globalIndex (const label localSize, const int tag, const label comm, const bool parallel)
 Construct from local max size. More...
 
 globalIndex (const labelUList &offsets)
 Copy construct from list of labels. More...
 
 globalIndex (labelList &&offsets)
 Move construct from list of labels. More...
 
 globalIndex (Istream &is)
 Construct from Istream. More...
 
bool empty () const
 Check for null constructed or global sum == 0. More...
 
const labelListoffsets () const
 Const-access to the offsets. More...
 
label size () const
 Global sum of localSizes. More...
 
labelList sizes () const
 The local sizes. More...
 
labelListoffsets ()
 Write-access to the offsets, for changing after construction. More...
 
void reset (const label localSize)
 Reset from local size. More...
 
void reset (const label localSize, const int tag, const label comm, const bool parallel)
 Reset from local size. More...
 
label localStart () const
 My local start. More...
 
label localSize () const
 My local size. More...
 
labelRange range () const
 Return start/size range of local processor data. More...
 
bool isLocal (const label i) const
 Is on local processor. More...
 
label toGlobal (const label i) const
 From local to global index. More...
 
labelList toGlobal (const labelUList &labels) const
 From local to global index. More...
 
void inplaceToGlobal (labelList &labels) const
 From local to global index (inplace) More...
 
label toLocal (const label i) const
 From global to local on current processor. More...
 
label offset (const label proci) const
 Start of proci data. More...
 
label localStart (const label proci) const
 Start of proci data. More...
 
label localSize (const label proci) const
 Size of proci data. More...
 
labelRange range (const label proci) const
 Return start/size range of proci data. More...
 
bool isLocal (const label proci, const label i) const
 Is on processor proci. More...
 
label toGlobal (const label proci, const label i) const
 From local to global on proci. More...
 
labelList toGlobal (const label proci, const labelUList &labels) const
 From local to global on proci. More...
 
void inplaceToGlobal (const label proci, labelList &labels) const
 From local to global index on proci (inplace) More...
 
label toLocal (const label proci, const label i) const
 From global to local on proci. More...
 
label whichProcID (const label i) const
 Which processor does global come from? Binary search. More...
 
template<class Container , class Type >
void gather (const label comm, const Container &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking) const
 Collect data in processor order on master (== procIDs[0]). More...
 
template<class Type >
void gather (const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking) const
 Collect data in processor order on master. More...
 
template<class Container , class Type >
void gather (const label comm, const Container &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 commsType=Pstream::commsTypes::nonBlocking) const
 Inplace collect data in processor order on master. More...
 
template<class Container , class Type >
void scatter (const label comm, const Container &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking) const
 Distribute data in processor order. Requires fld to be sized! More...
 
template<class Type >
void scatter (const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking) const
 Distribute data in processor order. Requires fld to be sized! More...
 
template<class Type , class CombineOp >
void get (List< Type > &allFld, const labelUList &globalIds, const CombineOp &cop, const label comm=Pstream::worldComm, const int tag=UPstream::msgType()) const
 Get (potentially remote) data. Elements required given as. More...
 

Static Public Member Functions

template<class Container , class Type >
static void gather (const labelUList &offsets, const label comm, const Container &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking)
 Collect data in processor order on master (== procIDs[0]). More...
 
template<class Type >
static void gatherOp (const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking)
 Collect data in processor order on master. More...
 
template<class Container , class Type >
static void gather (const labelUList &offsets, const label comm, const Container &procIDs, List< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking)
 
template<class Type >
static void gatherOp (List< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking)
 Inplace collect data in processor order on master. More...
 
template<class Container , class Type >
static void scatter (const labelUList &offsets, const label comm, const Container &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking)
 Distribute data in processor order. Requires fld to be sized! More...
 

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 68 of file globalIndex.H.

Constructor & Destructor Documentation

◆ globalIndex() [1/6]

globalIndex ( )
default

Construct null.

◆ globalIndex() [2/6]

globalIndex ( const label  localSize)
inlineexplicit

Construct from local max size.

Does communication with default communicator and message tag.

Definition at line 34 of file globalIndexI.H.

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

Here is the call graph for this function:

◆ globalIndex() [3/6]

globalIndex ( const label  localSize,
const int  tag,
const label  comm,
const bool  parallel 
)
inline

Construct from local max size.

Does communication with given communicator and message tag

Parameters
tagmessage tag
commcommunicator
paralleluse parallel comms

Definition at line 43 of file globalIndexI.H.

◆ globalIndex() [4/6]

globalIndex ( const labelUList offsets)
inlineexplicit

Copy construct from list of labels.

Definition at line 56 of file globalIndexI.H.

◆ globalIndex() [5/6]

globalIndex ( labelList &&  offsets)
inlineexplicit

Move construct from list of labels.

Definition at line 62 of file globalIndexI.H.

◆ globalIndex() [6/6]

globalIndex ( Istream is)
explicit

Construct from Istream.

Definition at line 33 of file globalIndex.C.

Member Function Documentation

◆ empty()

bool empty ( ) const
inline

Check for null constructed or global sum == 0.

Definition at line 70 of file globalIndexI.H.

◆ offsets() [1/2]

const Foam::labelList & offsets ( ) const
inline

Const-access to the offsets.

Definition at line 76 of file globalIndexI.H.

◆ size()

Foam::label size ( ) const
inline

Global sum of localSizes.

Definition at line 88 of file globalIndexI.H.

Referenced by nearWallFields::calcAddressing(), distributedTriSurfaceMesh::globalSize(), regionSplit::nRegions(), SprayCloud< Foam::DSMCCloud >::penetration(), and internalMeshWriter::writeProcIDs().

Here is the caller graph for this function:

◆ sizes()

Foam::labelList sizes ( ) const

The local sizes.

Definition at line 140 of file globalIndex.C.

References Foam::HashTableOps::values().

Here is the call graph for this function:

◆ offsets() [2/2]

Foam::labelList & offsets ( )
inline

Write-access to the offsets, for changing after construction.

Definition at line 82 of file globalIndexI.H.

◆ reset() [1/2]

void reset ( const label  localSize)
inline

Reset from local size.

Does communication with default communicator and message tag.

Definition at line 94 of file globalIndexI.H.

References UPstream::msgType(), and UPstream::worldComm.

Referenced by globalMeshData::globalEdgeNumbering(), globalIndex::globalIndex(), globalMeshData::globalPointNumbering(), and distributedTriSurfaceMesh::globalTris().

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

◆ reset() [2/2]

void reset ( const label  localSize,
const int  tag,
const label  comm,
const bool  parallel 
)

Reset from local size.

Does communication with given communicator and message tag

Parameters
tagmessage tag
commcommunicator
paralleluse parallel comms

Definition at line 102 of file globalIndex.C.

References UPstream::allProcs(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Pstream::gatherList(), Foam::labelMax, UPstream::myProcNo(), UPstream::nProcs(), Pstream::scatterList(), and Foam::Zero.

Here is the call graph for this function:

◆ localStart() [1/2]

Foam::label localStart ( ) const
inline

My local start.

Definition at line 112 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by viewFactor::calculate(), cellCellStencil::globalCellCells(), indirectPatchWriter::writeGeometry(), surfaceWriter::writeGeometry(), patchMeshWriter::writeGeometry(), and patchMeshWriter::writePolys().

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

◆ localSize() [1/2]

Foam::label localSize ( ) const
inline

My local size.

Definition at line 124 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by createShellMesh::calcPointRegions(), viewFactor::calculate(), mapDistributeBase::exchangeAddressing(), cellCellStencil::globalCellCells(), globalIndex::globalIndex(), regionSplit::nLocalRegions(), SprayCloud< Foam::DSMCCloud >::penetration(), and patchMeshWriter::writeProcIDs().

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

◆ range() [1/2]

Foam::labelRange range ( ) const
inline

Return start/size range of local processor data.

Definition at line 136 of file globalIndexI.H.

References UPstream::myProcNo(), and range.

Here is the call graph for this function:

◆ isLocal() [1/2]

bool isLocal ( const label  i) const
inline

Is on local processor.

Definition at line 148 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by decompositionMethod::calcCellCells(), mapDistributeBase::calcCompactAddressing(), addPatchCellLayer::calcExtrudeInfo(), and mapDistributeBase::renumber().

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

◆ toGlobal() [1/4]

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

From local to global index.

Definition at line 164 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by nearWallFields::calcAddressing(), decompositionMethod::calcCellCells(), createShellMesh::calcPointRegions(), viewFactor::calculate(), cellCellStencil::globalCellCells(), addPatchCellLayer::globalEdgeFaces(), viewFactor::insertMatrixElements(), inverseDistance::markDonors(), globalMeshData::mergePoints(), MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration(), regionSplit2D::regionSplit2D(), addPatchCellLayer::setRefinement(), and cellVolumeWeight::update().

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

◆ toGlobal() [2/4]

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

From local to global index.

Definition at line 184 of file globalIndexI.H.

References UPstream::myProcNo().

Here is the call graph for this function:

◆ inplaceToGlobal() [1/2]

void inplaceToGlobal ( labelList labels) const
inline

From local to global index (inplace)

Definition at line 207 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by faceAreaWeightAMI::calculate().

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

From global to local on current processor.

FatalError if not on local processor.

Definition at line 229 of file globalIndexI.H.

References UPstream::myProcNo().

Referenced by fvMeshPrimitiveLduAddressing::addAddressing(), decompositionMethod::calcCellCells(), mapDistributeBase::calcCompactAddressing(), addPatchCellLayer::calcExtrudeInfo(), distributedTriSurfaceMesh::localQueries(), and mapDistributeBase::renumber().

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

◆ offset()

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

Start of proci data.

Definition at line 100 of file globalIndexI.H.

Referenced by SprayCloud< Foam::DSMCCloud >::penetration(), and Foam::vtk::writeListParallel().

Here is the caller graph for this function:

◆ localStart() [2/2]

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

Start of proci data.

Definition at line 106 of file globalIndexI.H.

◆ localSize() [2/2]

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

Size of proci data.

Definition at line 118 of file globalIndexI.H.

◆ range() [2/2]

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

Return start/size range of proci data.

Definition at line 130 of file globalIndexI.H.

◆ isLocal() [2/2]

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

Is on processor proci.

Definition at line 142 of file globalIndexI.H.

◆ toGlobal() [3/4]

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

From local to global on proci.

Definition at line 155 of file globalIndexI.H.

◆ toGlobal() [4/4]

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

From local to global on proci.

Definition at line 171 of file globalIndexI.H.

◆ inplaceToGlobal() [2/2]

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

From local to global index on proci (inplace)

Definition at line 193 of file globalIndexI.H.

◆ toLocal() [2/2]

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

From global to local on proci.

Definition at line 214 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

Which processor does global come from? Binary search.

Definition at line 235 of file globalIndexI.H.

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

Referenced by fvMeshPrimitiveLduAddressing::addAddressing(), mapDistributeBase::calcCompactAddressing(), addPatchCellLayer::calcExtrudeInfo(), distributedTriSurfaceMesh::findNearest(), distributedTriSurfaceMesh::localQueries(), and mapDistributeBase::renumber().

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

◆ gather() [1/6]

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

Collect data in processor order on master (== procIDs[0]).

Needs offsets only on master.

Definition at line 35 of file globalIndexTemplates.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, fld, UList< T >::last(), Foam::blockMeshTools::read(), List< T >::setSize(), and Foam::vtk::write().

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

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

◆ gather() [2/6]

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

Collect data in processor order on master (== procIDs[0]).

Needs offsets only on master.

Definition at line 246 of file globalIndex.H.

References fld, and globalIndex::gather().

Here is the call graph for this function:

◆ gather() [3/6]

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

Collect data in processor order on master.

Does communication with default communicator and message tag.

Definition at line 187 of file globalIndexTemplates.C.

References fld.

◆ 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

Collect data in processor order on master.

Does communication with default communicator and message tag.

Definition at line 208 of file globalIndexTemplates.C.

References fld.

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

Here is the caller graph for this function:

◆ gather() [4/6]

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

Inplace collect in processor order on master (== procIDs[0]). Needs offsets only on master.

Definition at line 221 of file globalIndexTemplates.C.

References fld.

◆ gather() [5/6]

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

Inplace collect in processor order on master (== procIDs[0]). Needs offsets only on master.

Definition at line 302 of file globalIndex.H.

References fld, and globalIndex::gather().

Here is the call graph for this function:

◆ gather() [6/6]

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

Inplace collect data in processor order on master.

Does communication with default communicator and message tag. After the gather, the field is zero-sized on the slaves.

Definition at line 243 of file globalIndexTemplates.C.

References fld.

◆ gatherOp() [2/2]

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

Inplace collect data in processor order on master.

Does communication with default communicator and message tag. After the gather, the field is zero-sized on the slaves.

Definition at line 274 of file globalIndexTemplates.C.

References fld.

◆ scatter() [1/3]

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

Distribute data in processor order. Requires fld to be sized!

Definition at line 286 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 Container &  procIDs,
const UList< Type > &  allFld,
UList< Type > &  fld,
const int  tag = UPstream::msgType(),
const Pstream::commsTypes  commsType = Pstream::commsTypes::nonBlocking 
) const
inline

Distribute data in processor order. Requires fld to be sized!

Definition at line 356 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

Distribute data in processor order. Requires fld to be sized!

Does communication with default communicator and message tag.

Definition at line 445 of file globalIndexTemplates.C.

References fld.

◆ get()

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

Get (potentially remote) data. Elements required given as.

global indices

Definition at line 467 of file globalIndexTemplates.C.

References PstreamBuffers::finishedSends(), fld, forAll, CompactListList< T, Container >::offsets(), List< T >::setSize(), and UList< T >::size().

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: