PstreamBuffers Class Reference

Buffers for inter-processor communications streams (UOPstream, UIPstream). More...

Public Member Functions

 PstreamBuffers (const UPstream::commsTypes commsType, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
 Construct given comms type, communication options, IO format. More...
 
 ~PstreamBuffers ()
 Destructor - checks that all data have been consumed. More...
 
int tag () const noexcept
 The transfer message type. More...
 
label comm () const noexcept
 Communicator. More...
 
void finishedSends (const bool block=true)
 Mark all sends as having been done. More...
 
void finishedSends (labelList &recvSizes, const bool block=true)
 Mark all sends as having been done. More...
 
void clear ()
 Reset (clear) individual buffers and reset state. More...
 

Friends

class UOPstream
 
class UIPstream
 

Detailed Description

Buffers for inter-processor communications streams (UOPstream, UIPstream).

Use UOPstream to stream data into buffers, call finishedSends() to notify that data is in buffers and then use IUPstream to get data out of received buffers. Works with both blocking and nonBlocking. Does not make much sense with scheduled since there you would not need these explicit buffers.

Example usage:

for (const int proci : Pstream::allProcs())
{
if (proci != Pstream::myProcNo())
{
someObject vals;
UOPstream send(proci, pBufs);
send << vals;
}
}
pBufs.finishedSends(); // no-op for blocking
for (const int proci : Pstream::allProcs())
{
if (proci != Pstream::myProcNo())
{
UIPstream recv(proci, pBufs);
someObject vals(recv);
}
}
Source files

Definition at line 88 of file PstreamBuffers.H.

Constructor & Destructor Documentation

◆ PstreamBuffers()

PstreamBuffers ( const UPstream::commsTypes  commsType,
const int  tag = UPstream::msgType(),
const label  comm = UPstream::worldComm,
IOstreamOption::streamFormat  fmt = IOstreamOption::BINARY 
)
explicit

Construct given comms type, communication options, IO format.

Definition at line 34 of file PstreamBuffers.C.

◆ ~PstreamBuffers()

Destructor - checks that all data have been consumed.

Definition at line 54 of file PstreamBuffers.C.

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

Here is the call graph for this function:

Member Function Documentation

◆ tag()

int tag ( ) const
inlinenoexcept

The transfer message type.

Definition at line 141 of file PstreamBuffers.H.

◆ comm()

label comm ( ) const
inlinenoexcept

Communicator.

Definition at line 147 of file PstreamBuffers.H.

Referenced by processorPolyPatch::initGeometry(), processorPolyPatch::initUpdateMesh(), and syncObjects::sync().

Here is the caller graph for this function:

◆ finishedSends() [1/2]

void finishedSends ( const bool  block = true)

◆ finishedSends() [2/2]

void finishedSends ( labelList recvSizes,
const bool  block = true 
)

Mark all sends as having been done.

Same as above but also returns sizes (bytes) received.

Note
currently only valid for non-blocking.

Definition at line 92 of file PstreamBuffers.C.

References UPstream::commsTypeNames, Foam::endl(), Pstream::exchangeSizes(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, and UPstream::nonBlocking.

Here is the call graph for this function:

◆ clear()

void clear ( )

Reset (clear) individual buffers and reset state.

Does not clear buffer storage

Definition at line 125 of file PstreamBuffers.C.

Referenced by fvMeshDistribute::distribute(), trackingInverseDistance::markDonors(), inverseDistance::markDonors(), trackingInverseDistance::markPatchesAsHoles(), inverseDistance::markPatchesAsHoles(), RecycleInteraction< CloudType >::postEvolve(), and surfaceNoise::readSurfaceData().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ UOPstream

friend class UOPstream
friend

Definition at line 90 of file PstreamBuffers.H.

◆ UIPstream

friend class UIPstream
friend

Definition at line 91 of file PstreamBuffers.H.


The documentation for this class was generated from the following files:
Foam::PstreamBuffers::UOPstream
friend class UOPstream
Definition: PstreamBuffers.H:90
Foam::PstreamBuffers::UIPstream
friend class UIPstream
Definition: PstreamBuffers.H:91
Foam::PstreamBuffers::PstreamBuffers
PstreamBuffers(const UPstream::commsTypes commsType, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given comms type, communication options, IO format.
Definition: PstreamBuffers.C:34
Foam::UPstream::allProcs
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
Definition: UPstream.H:508
Foam::UPstream::commsTypes::nonBlocking
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:463