Public Member Functions | Static Public Member Functions | Protected Attributes
Pstream Class Reference

Inter-processor communications stream. More...

Inheritance diagram for Pstream:
Inheritance graph
[legend]
Collaboration diagram for Pstream:
Collaboration graph
[legend]

Public Member Functions

 ClassName ("Pstream")
 
 Pstream (const commsTypes commsType, const label bufSize=0)
 Construct given optional buffer size. More...
 
- Public Member Functions inherited from UPstream
 ClassName ("UPstream")
 
 UPstream (const commsTypes commsType)
 Construct given optional buffer size. More...
 
commsTypes commsType () const
 Get the communications type of the stream. More...
 
commsTypes commsType (const commsTypes ct)
 Set the communications type of the stream. More...
 

Static Public Member Functions

template<class T , class BinaryOp >
static void gather (const List< commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
 Gather data. Apply bop to combine Value. More...
 
template<class T , class BinaryOp >
static void gather (T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void scatter (const List< commsStruct > &comms, T &Value, const int tag, const label comm)
 Scatter data. Distribute without modification. Reverse of gather. More...
 
template<class T >
static void scatter (T &Value, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T , class CombineOp >
static void combineGather (const List< commsStruct > &comms, T &Value, const CombineOp &cop, const int tag, const label comm)
 
template<class T , class CombineOp >
static void combineGather (T &Value, const CombineOp &cop, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void combineScatter (const List< commsStruct > &comms, T &Value, const int tag, const label comm)
 Scatter data. Reverse of combineGather. More...
 
template<class T >
static void combineScatter (T &Value, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T , class CombineOp >
static void listCombineGather (const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
 
template<class T , class CombineOp >
static void listCombineGather (List< T > &Value, const CombineOp &cop, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void listCombineScatter (const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
 Scatter data. Reverse of combineGather. More...
 
template<class T >
static void listCombineScatter (List< T > &Value, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class Container , class CombineOp >
static void mapCombineGather (const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
 
template<class Container , class CombineOp >
static void mapCombineGather (Container &Values, const CombineOp &cop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class Container >
static void mapCombineScatter (const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
 Scatter data. Reverse of combineGather. More...
 
template<class Container >
static void mapCombineScatter (Container &Values, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void gatherList (const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
 Gather data but keep individual values separate. More...
 
template<class T >
static void gatherList (List< T > &Values, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void scatterList (const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
 Scatter data. Reverse of gatherList. More...
 
template<class T >
static void scatterList (List< T > &Values, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class Container , class T >
static void exchange (const List< Container > &, List< Container > &, labelListList &sizes, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool block=true)
 Exchange data. Sends sendData, receives into recvData, sets. More...
 
- Static Public Member Functions inherited from UPstream
static label allocateCommunicator (const label parent, const labelList &subRanks, const bool doPstream=true)
 Allocate a new communicator. More...
 
static void freeCommunicator (const label communicator, const bool doPstream=true)
 Free a previously allocated communicator. More...
 
static void freeCommunicators (const bool doPstream)
 Free all communicators. More...
 
static int baseProcNo (const label myComm, const int procID)
 Return physical processor number (i.e. processor number in. More...
 
static label procNo (const label comm, const int baseProcID)
 Return processor number in communicator (given physical processor. More...
 
static label procNo (const label myComm, const label currentComm, const int currentProcID)
 Return processor number in communicator (given processor number. More...
 
static void addValidParOptions (HashTable< string > &validParOptions)
 Add the valid option this type of communications library. More...
 
static bool init (int &argc, char **&argv)
 Initialisation function called from main. More...
 
static label nRequests ()
 Get number of outstanding requests. More...
 
static void resetRequests (const label sz)
 Truncate number of outstanding requests. More...
 
static void waitRequests (const label start=0)
 Wait until all requests (from start onwards) have finished. More...
 
static void waitRequest (const label i)
 Wait until request i has finished. More...
 
static bool finishedRequest (const label i)
 Non-blocking comms: has request i finished? More...
 
static int allocateTag (const char *)
 
static int allocateTag (const word &)
 
static void freeTag (const char *, const int tag)
 
static void freeTag (const word &, const int tag)
 
static bool & parRun ()
 Is this a parallel run? More...
 
static void setParRun (const label nProcs)
 Set data for parallel running. Special case nProcs=0 to switch off. More...
 
static label nProcs (const label communicator=0)
 Number of processes in parallel run. More...
 
static int masterNo ()
 Process index of the master. More...
 
static bool master (const label communicator=0)
 Am I the master process. More...
 
static int myProcNo (const label communicator=0)
 Number of this process (starting from masterNo() = 0) More...
 
static label parent (const label communicator)
 
static List< int > & procID (label communicator)
 Process ID of given process index. More...
 
static int firstSlave ()
 Process index of first slave. More...
 
static int lastSlave (const label communicator=0)
 Process index of last slave. More...
 
static const List< commsStruct > & linearCommunication (const label communicator=0)
 Communication schedule for linear all-to-master (proc 0) More...
 
static const List< commsStruct > & treeCommunication (const label communicator=0)
 Communication schedule for tree all-to-master (proc 0) More...
 
static int & msgType ()
 Message tag of standard messages. More...
 
static void exit (int errnum=1)
 Exit program. More...
 
static void abort ()
 Abort program. More...
 

Protected Attributes

DynamicList< char > buf_
 Transfer buffer. More...
 
- Protected Attributes inherited from UPstream
commsTypes commsType_
 Communications type of this stream. More...
 

Additional Inherited Members

- Public Types inherited from UPstream
enum  commsTypes { blocking, scheduled, nonBlocking }
 Types of communications. More...
 
- Static Public Attributes inherited from UPstream
static const NamedEnum< commsTypes, 3 > commsTypeNames
 
static bool floatTransfer
 Should compact transfer be used in which floats replace doubles. More...
 
static int nProcsSimpleSum
 Number of processors at which the sum algorithm changes from linear. More...
 
static commsTypes defaultCommsType
 Default commsType. More...
 
static int nPollProcInterfaces
 Number of polling cycles in processor updates. More...
 
static label worldComm
 Default communicator (all processors) More...
 
static label warnComm
 Debugging: warn for use of any communicator differing from warnComm. More...
 

Detailed Description

Inter-processor communications stream.

Source files

Definition at line 53 of file Pstream.H.

Constructor & Destructor Documentation

◆ Pstream()

Pstream ( const commsTypes  commsType,
const label  bufSize = 0 
)
inline

Construct given optional buffer size.

Definition at line 75 of file Pstream.H.

References Pstream::buf_, and DynamicList::setCapacity().

Here is the call graph for this function:

Member Function Documentation

◆ ClassName()

ClassName ( "Pstream"  )

◆ gather() [1/2]

void gather ( const List< commsStruct > &  comms,
T Value,
const BinaryOp &  bop,
const int  tag,
const label  comm 
)
static

Gather data. Apply bop to combine Value.

from different processors

Definition at line 47 of file gatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), UIPstream::read(), UPstream::scheduled, Foam::T(), and UOPstream::write().

Referenced by Foam::reduce().

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

◆ gather() [2/2]

void gather ( T Value,
const BinaryOp &  bop,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 127 of file gatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ scatter() [1/2]

void scatter ( const List< commsStruct > &  comms,
T Value,
const int  tag,
const label  comm 
)
static

◆ scatter() [2/2]

void scatter ( T Value,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 221 of file gatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, Pstream::scatter(), and UPstream::treeCommunication().

Here is the call graph for this function:

◆ combineGather() [1/2]

void combineGather ( const List< commsStruct > &  comms,
T Value,
const CombineOp &  cop,
const int  tag,
const label  comm 
)
static

Definition at line 50 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, Foam::T(), and UOPstream::write().

Referenced by Foam::combineReduce().

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

◆ combineGather() [2/2]

void combineGather ( T Value,
const CombineOp &  cop,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 144 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ combineScatter() [1/2]

void combineScatter ( const List< commsStruct > &  comms,
T Value,
const int  tag,
const label  comm 
)
static

Scatter data. Reverse of combineGather.

Definition at line 178 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, Foam::T(), and UOPstream::write().

Referenced by Foam::combineReduce().

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

◆ combineScatter() [2/2]

void combineScatter ( T Value,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 259 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ listCombineGather() [1/2]

void listCombineGather ( const List< commsStruct > &  comms,
List< T > &  Value,
const CombineOp &  cop,
const int  tag,
const label  comm 
)
static

◆ listCombineGather() [2/2]

void listCombineGather ( List< T > &  Value,
const CombineOp &  cop,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 383 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ listCombineScatter() [1/2]

void listCombineScatter ( const List< commsStruct > &  comms,
List< T > &  Value,
const int  tag,
const label  comm 
)
static

◆ listCombineScatter() [2/2]

void listCombineScatter ( List< T > &  Value,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 498 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ mapCombineGather() [1/2]

void mapCombineGather ( const List< commsStruct > &  comms,
Container &  Values,
const CombineOp &  cop,
const int  tag,
const label  comm 
)
static

Definition at line 535 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, and UPstream::scheduled.

Referenced by extractSurface(), extrudePatchMesh::extrudeMesh(), and meshRefinement::zonify().

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

◆ mapCombineGather() [2/2]

void mapCombineGather ( Container &  Values,
const CombineOp &  cop,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 602 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ mapCombineScatter() [1/2]

void mapCombineScatter ( const List< commsStruct > &  comms,
Container &  Values,
const int  tag,
const label  comm 
)
static

Scatter data. Reverse of combineGather.

Definition at line 636 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, and UPstream::scheduled.

Referenced by extractSurface(), extrudePatchMesh::extrudeMesh(), and meshRefinement::zonify().

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

◆ mapCombineScatter() [2/2]

void mapCombineScatter ( Container &  Values,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 687 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ gatherList() [1/2]

void gatherList ( const List< commsStruct > &  comms,
List< T > &  Values,
const int  tag,
const label  comm 
)
static

Gather data but keep individual values separate.

Definition at line 49 of file gatherScatterList.C.

References Foam::abort(), UPstream::commsStruct::above(), UPstream::commsStruct::allBelow(), UPstream::commsStruct::below(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, List::size(), and UOPstream::write().

Referenced by surfaceZonesInfo::addCellZonesToMesh(), surfaceZonesInfo::addFaceZonesToMesh(), meshSurfaceEngine::calcGlobalBoundaryEdgeLabels(), meshSurfaceEngine::calcGlobalBoundaryFaceLabels(), meshSurfaceEngine::calcGlobalBoundaryPointLabels(), polyMeshGenAddressing::calcGlobalCellLabels(), polyMeshGenAddressing::calcGlobalEdgeLabels(), polyMeshGenAddressing::calcGlobalFaceLabels(), meshOctreeAddressing::calcGlobalLeafLabels(), meshOctreeAddressing::calcGlobalPointLabels(), polyMeshGenAddressing::calcGlobalPointLabels(), distributedTriSurfaceMesh::calcLocalQueries(), meshRefinement::checkCoupledFaceZones(), polyBoundaryMesh::checkParallelSync(), fieldValue::combineFields(), faceSource::combineMeshGeometry(), partTriMesh::createParallelAddressing(), partTetMesh::createParallelAddressing(), createReconstructMap(), globalIndexAndTransform::determineTransforms(), fvMeshDistribute::distribute(), distributedTriSurfaceMesh::distribute(), distributedTriSurfaceMesh::distributedTriSurfaceMesh(), distributedTriSurfaceMesh::distributeSegments(), extractSurface(), boundaryLayers::findPatchesToBeTreatedTogether(), Pstream::gatherList(), globalIndex::globalIndex(), Foam::help::groupMarking(), viewFactor::initialise(), meshOctreeModifier::loadDistribution(), main(), fvMeshDistribute::mergeWordList(), InflationInjection< CloudType >::parcelsToInject(), printMeshData(), distributedTriSurfaceMesh::read(), fvMeshSubset::setLargeCellSubset(), ParSortableList< Type >::sort(), cyclicPeriodicAMIPolyPatch::syncTransforms(), meshOctreeModifier::updateCommunicationPattern(), and externalCoupledFunctionObject::writeGeometry().

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

◆ gatherList() [2/2]

void gatherList ( List< T > &  Values,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 190 of file gatherScatterList.C.

References Pstream::gatherList(), UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ scatterList() [1/2]

void scatterList ( const List< commsStruct > &  comms,
List< T > &  Values,
const int  tag,
const label  comm 
)
static

Scatter data. Reverse of gatherList.

Definition at line 205 of file gatherScatterList.C.

References Foam::abort(), UPstream::commsStruct::above(), UPstream::commsStruct::allNotBelow(), UPstream::commsStruct::below(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, List::size(), and UOPstream::write().

Referenced by surfaceZonesInfo::addCellZonesToMesh(), surfaceZonesInfo::addFaceZonesToMesh(), meshSurfaceEngine::calcGlobalBoundaryEdgeLabels(), meshSurfaceEngine::calcGlobalBoundaryFaceLabels(), meshSurfaceEngine::calcGlobalBoundaryPointLabels(), polyMeshGenAddressing::calcGlobalCellLabels(), polyMeshGenAddressing::calcGlobalEdgeLabels(), polyMeshGenAddressing::calcGlobalFaceLabels(), meshOctreeAddressing::calcGlobalLeafLabels(), meshOctreeAddressing::calcGlobalPointLabels(), polyMeshGenAddressing::calcGlobalPointLabels(), distributedTriSurfaceMesh::calcLocalQueries(), meshRefinement::checkCoupledFaceZones(), polyBoundaryMesh::checkParallelSync(), fieldValue::combineFields(), partTriMesh::createParallelAddressing(), partTetMesh::createParallelAddressing(), fvMeshDistribute::distribute(), distributedTriSurfaceMesh::distribute(), distributedTriSurfaceMesh::distributedTriSurfaceMesh(), distributedTriSurfaceMesh::distributeSegments(), boundaryLayers::findPatchesToBeTreatedTogether(), globalIndex::globalIndex(), Foam::help::groupMarking(), meshOctreeModifier::loadDistribution(), main(), fvMeshDistribute::mergeWordList(), distributedTriSurfaceMesh::read(), Pstream::scatterList(), fvMeshSubset::setLargeCellSubset(), cyclicPeriodicAMIPolyPatch::syncTransforms(), and meshOctreeModifier::updateCommunicationPattern().

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

◆ scatterList() [2/2]

void scatterList ( List< T > &  Values,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 325 of file gatherScatterList.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, Pstream::scatterList(), and UPstream::treeCommunication().

Here is the call graph for this function:

◆ exchange()

void exchange ( const List< Container > &  sendBufs,
List< Container > &  recvBufs,
labelListList sizes,
const int  tag = UPstream::msgType(),
const label  comm = UPstream::worldComm,
const bool  block = true 
)
static

Exchange data. Sends sendData, receives into recvData, sets.

sizes (not bytes). sizes[p0][p1] is what processor p0 has sent to p1. Continuous data only. If block=true will wait for all transfers to finish.

Definition at line 38 of file exchange.C.

References Foam::abort(), Foam::combineReduce(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::read(), List::setSize(), List::size(), T, and write().

Here is the call graph for this function:

Field Documentation

◆ buf_

DynamicList<char> buf_
protected

Transfer buffer.

Definition at line 63 of file Pstream.H.

Referenced by Pstream::Pstream().


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