OOFEM 3.0
Loading...
Searching...
No Matches
oofem::StaticCommunicationBuffer Class Reference

#include <combuff.h>

Inheritance diagram for oofem::StaticCommunicationBuffer:
Collaboration diagram for oofem::StaticCommunicationBuffer:

Public Member Functions

 StaticCommunicationBuffer (MPI_Comm comm, int size, bool dynamic=0)
 StaticCommunicationBuffer (MPI_Comm comm, bool dynamic=0)
 Constructor. Creates empty buffer, using given communicator for packing.
virtual ~StaticCommunicationBuffer ()
 Destructor.
int resize (std::size_t newSize) override
void init () override
void initForPacking () override
 Initialize for packing.
void initForUnpacking () override
 Initialize for Unpacking (data already received).
int write (const int *src, std::size_t n) override
 Writes count integer values from array pointed by data.
int write (const long *src, std::size_t n) override
 Writes count long values from array pointed by data.
int write (const unsigned long *src, std::size_t n) override
 Writes count unsigned long values from array pointed by data.
int write (const double *src, std::size_t n) override
 Writes count double values from array pointed by data.
int write (const char *src, std::size_t n) override
 Writes count char values from array pointed by data.
int read (int *dest, std::size_t n) override
 Reads count integer values into array pointed by data.
int read (long *dest, std::size_t n) override
 Reads count long values into array pointed by data.
int read (unsigned long *dest, std::size_t n) override
 Reads count unsigned long values into array pointed by data.
int read (double *dest, std::size_t n) override
 Reads count double values into array pointed by data.
int read (char *dest, std::size_t n) override
 Reads count char values into array pointed by data.
int iSend (int dest, int tag) override
int iRecv (int source, int tag, std::size_t count=0) override
int testCompletion () override
int testCompletion (int &source, int &tag)
int waitCompletion () override
int bcast (int root) override
int write (bool data) override
 Writes a bool value.
int write (int data)
int write (unsigned long data)
int write (long data)
int write (double data)
int write (char data)
int write (const std ::string &data)
 Reads a string (stored as an int for the length followed by char*).
int write (const char *data)
 Writes a string (wrapper needed, otherwise write(bool) is called ).
int read (bool &data) override
 Reads a bool value from data.
int read (int &data)
int read (unsigned long &data)
int read (long &data)
int read (double &data)
int read (char &data)
int read (std ::string &data)
 Reads a string (stored as an int for the length followed by char*).
Public Member Functions inherited from oofem::CommunicationBuffer
 CommunicationBuffer (MPI_Comm comm, std::size_t size, bool dynamic=0)
 CommunicationBuffer (MPI_Comm comm, bool dynamic=0)
 Constructor. Creates empty buffer, using given communicator for packing.
virtual ~CommunicationBuffer ()
 Destructor.
int givePackSizeOfInt (std::size_t count) override
int givePackSizeOfDouble (std::size_t count) override
int givePackSizeOfChar (std::size_t count) override
int givePackSizeOfBool (std::size_t count) override
int givePackSizeOfLong (std::size_t count) override
int givePackSizeOfSizet (std::size_t count) override
int read (int &data)
int read (unsigned long &data)
int read (long &data)
int read (double &data)
int read (char &data)
int read (std ::string &data)
 Reads a string (stored as an int for the length followed by char*).
int write (int data)
int write (unsigned long data)
int write (long data)
int write (double data)
int write (char data)
int write (const std ::string &data)
 Reads a string (stored as an int for the length followed by char*).
int write (const char *data)
 Writes a string (wrapper needed, otherwise write(bool) is called ).
Public Member Functions inherited from oofem::DataStream
virtual ~DataStream ()
 Destructor.
int read (int &data)
int read (unsigned long &data)
int read (long &data)
int read (double &data)
int read (char &data)
int read (std ::string &data)
 Reads a string (stored as an int for the length followed by char*).
int write (int data)
int write (unsigned long data)
int write (long data)
int write (double data)
int write (char data)
int write (const std ::string &data)
 Reads a string (stored as an int for the length followed by char*).
int write (const char *data)
 Writes a string (wrapper needed, otherwise write(bool) is called ).
Public Member Functions inherited from oofem::MPIBuffer
 MPIBuffer (std::size_t size, bool dynamic=0)
 Constructor. Creates buffer of given size, using given communicator for packing.
 MPIBuffer (bool dynamic=0)
 Constructor. Creates empty buffer, using given communicator for packing.
virtual ~MPIBuffer ()
 Destructor.
int resize (std::size_t newSize)
std::size_t giveSize ()
std::size_t giveAvailableSpace ()
MPI_Request giveRequest ()
int packArray (MPI_Comm communicator, const void *src, std::size_t n, MPI_Datatype type)
int unpackArray (MPI_Comm communicator, void *dest, std::size_t n, MPI_Datatype type)
int givePackSize (MPI_Comm communicator, MPI_Datatype type, std::size_t size)
virtual int iSend (MPI_Comm communicator, int dest, int tag)
virtual int iRecv (MPI_Comm communicator, int source, int tag, std::size_t count=0)
int testCompletion ()
int testCompletion (int &source, int &tag)
int bcast (MPI_Comm communicator, int root)
void dump ()

Additional Inherited Members

Protected Attributes inherited from oofem::CommunicationBuffer
MPI_Comm communicator
Protected Attributes inherited from oofem::MPIBuffer
std::size_t size
 Size and current position in buffer in bytes (sizeof(char)).
std::size_t curr_pos
bool isDynamic
 Dynamic flag (if true, buffer can grow, but reallocation is needed).
ComBuff_BYTE_TYPEbuff
 Buffer. Dynamically allocated.
MPI_Request request

Detailed Description

Definition at line 318 of file combuff.h.

Constructor & Destructor Documentation

◆ StaticCommunicationBuffer() [1/2]

oofem::StaticCommunicationBuffer::StaticCommunicationBuffer ( MPI_Comm comm,
int size,
bool dynamic = 0 )
inline

◆ StaticCommunicationBuffer() [2/2]

oofem::StaticCommunicationBuffer::StaticCommunicationBuffer ( MPI_Comm comm,
bool dynamic = 0 )
inline

Constructor. Creates empty buffer, using given communicator for packing.

Definition at line 324 of file combuff.h.

References oofem::CommunicationBuffer::CommunicationBuffer(), and oofem::MPIBuffer::MPIBuffer().

◆ ~StaticCommunicationBuffer()

virtual oofem::StaticCommunicationBuffer::~StaticCommunicationBuffer ( )
inlinevirtual

Destructor.

Definition at line 326 of file combuff.h.

Member Function Documentation

◆ bcast()

int oofem::StaticCommunicationBuffer::bcast ( int root)
inlineoverridevirtual

Initializes broadcast over collaborating processes. The whole buffer size is broadcasted. All buffers participating in broadcast should have the same size.

Parameters
rootRank of broadcast root.
Returns
MPI_SUCCESS if ok.

Implements oofem::CommunicationBuffer.

Definition at line 373 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

Referenced by oofem::NonlocalMaterialWTP::migrate(), and oofem::ElementCommunicator::setUpCommunicationMaps().

◆ init()

void oofem::StaticCommunicationBuffer::init ( )
inlineoverridevirtual

◆ initForPacking()

void oofem::StaticCommunicationBuffer::initForPacking ( )
inlineoverridevirtual

Initialize for packing.

Implements oofem::CommunicationBuffer.

Definition at line 331 of file combuff.h.

References init().

◆ initForUnpacking()

void oofem::StaticCommunicationBuffer::initForUnpacking ( )
inlineoverridevirtual

Initialize for Unpacking (data already received).

Implements oofem::CommunicationBuffer.

Definition at line 332 of file combuff.h.

References init().

◆ iRecv()

int oofem::StaticCommunicationBuffer::iRecv ( int source,
int tag,
std::size_t count = 0 )
inlineoverridevirtual

Starts standard mode, nonblocking receive. The buffer must be large enough to receive all data.

Parameters
sourceRank of source.
tagMessage tag.
countNumber of elements to receive (bytes). Causes receive buffer to resize to count elements. If zero (default value) buffer is not resized.
Returns
MPI_SUCCESS if ok.

Implements oofem::CommunicationBuffer.

Definition at line 365 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

Referenced by oofem::FETICommunicator::setUpCommunicationMaps().

◆ iSend()

int oofem::StaticCommunicationBuffer::iSend ( int dest,
int tag )
inlineoverridevirtual

Starts standard mode, nonblocking send.

Parameters
destRank of destination.
tagMessage tag.
Returns
MPI_SUCCESS if ok.

Implements oofem::CommunicationBuffer.

Definition at line 363 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ read() [1/12]

int oofem::CommunicationBuffer::read ( bool & data)
overridevirtual

Reads a bool value from data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 258 of file combuff.C.

◆ read() [2/12]

int oofem::DataStream::read ( char & data)
inline

Definition at line 257 of file datastream.h.

◆ read() [3/12]

int oofem::StaticCommunicationBuffer::read ( char * data,
std::size_t count )
inlineoverridevirtual

Reads count char values into array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 355 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ read() [4/12]

int oofem::DataStream::read ( double & data)
inline

Definition at line 257 of file datastream.h.

◆ read() [5/12]

int oofem::StaticCommunicationBuffer::read ( double * data,
std::size_t count )
inlineoverridevirtual

Reads count double values into array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 353 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ read() [6/12]

int oofem::DataStream::read ( int & data)
inline

Definition at line 257 of file datastream.h.

◆ read() [7/12]

int oofem::StaticCommunicationBuffer::read ( int * data,
std::size_t count )
inlineoverridevirtual

Reads count integer values into array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 347 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

Referenced by oofem::NonlocalMaterialWTP::migrate(), and oofem::FETICommunicator::setUpCommunicationMaps().

◆ read() [8/12]

int oofem::DataStream::read ( long & data)
inline

Definition at line 257 of file datastream.h.

◆ read() [9/12]

int oofem::StaticCommunicationBuffer::read ( long * data,
std::size_t count )
inlineoverridevirtual

Reads count long values into array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 349 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ read() [10/12]

int oofem::DataStream::read ( std ::string & data)

Reads a string (stored as an int for the length followed by char*).

Definition at line 257 of file datastream.C.

◆ read() [11/12]

int oofem::DataStream::read ( unsigned long & data)
inline

Definition at line 257 of file datastream.h.

◆ read() [12/12]

int oofem::StaticCommunicationBuffer::read ( unsigned long * data,
std::size_t count )
inlineoverridevirtual

Reads count unsigned long values into array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 351 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ resize()

int oofem::StaticCommunicationBuffer::resize ( std::size_t newSize)
inlineoverridevirtual

Resizes buffer to given size. If buffer size is to be enlarged, then previously packed data are kept in new buffer. Otherwise buffer is cleared using init service. Current implementation only performs buffer growing, request for size decrease is ignored to avoid reallocation if further request for growing is encountered.

Parameters
newSizeNew buffer size in bytes.
Returns
Nonzero if successful.

Implements oofem::CommunicationBuffer.

Definition at line 328 of file combuff.h.

Referenced by oofem::NonlocalMaterialWTP::migrate(), oofem::ElementCommunicator::setUpCommunicationMaps(), and oofem::FETICommunicator::setUpCommunicationMaps().

◆ testCompletion() [1/2]

int oofem::StaticCommunicationBuffer::testCompletion ( )
inlineoverridevirtual

Tests if the operation identified by this->request is complete. In such case, true is returned and if communication was initiated by nonblocking send/receive, then request handle is set to MPI_REQUEST_NULL. Otherwise call returns flag=false.

Returns
Nonzero if operation complete, zero otherwise.

Implements oofem::CommunicationBuffer.

Definition at line 367 of file combuff.h.

Referenced by oofem::FETICommunicator::setUpCommunicationMaps().

◆ testCompletion() [2/2]

int oofem::StaticCommunicationBuffer::testCompletion ( int & source,
int & tag )
inline

Definition at line 369 of file combuff.h.

◆ waitCompletion()

int oofem::StaticCommunicationBuffer::waitCompletion ( )
inlineoverridevirtual

Waits until a completion of a nonblocking communication. The completion of a send operation indicates that the sender is now free to update the locations in the send buffer, the completion of a receive operation indicates that the receive buffer contains the received message, the receiver is now free to access it, and that the status object is set. If the communication object associated with this request was created (nonblocking send or receive call), then the object is deallocated by the call to MPI_WAIT and the request handle is set to MPI_REQUEST_NULL.

Returns
Nonzero if ...

Implements oofem::CommunicationBuffer.

Definition at line 371 of file combuff.h.

◆ write() [1/13]

int oofem::CommunicationBuffer::write ( bool data)
overridevirtual

Writes a bool value.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 261 of file combuff.C.

◆ write() [2/13]

int oofem::DataStream::write ( char data)
inline

Definition at line 260 of file datastream.h.

◆ write() [3/13]

int oofem::DataStream::write ( const char * data)
inline

Writes a string (wrapper needed, otherwise write(bool) is called ).

Definition at line 260 of file datastream.h.

◆ write() [4/13]

int oofem::StaticCommunicationBuffer::write ( const char * data,
std::size_t count )
inlineoverridevirtual

Writes count char values from array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 343 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ write() [5/13]

int oofem::StaticCommunicationBuffer::write ( const double * data,
std::size_t count )
inlineoverridevirtual

Writes count double values from array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 341 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ write() [6/13]

int oofem::StaticCommunicationBuffer::write ( const int * data,
std::size_t count )
inlineoverridevirtual

Writes count integer values from array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 335 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

Referenced by oofem::NonlocalMaterialWTP::migrate().

◆ write() [7/13]

int oofem::StaticCommunicationBuffer::write ( const long * data,
std::size_t count )
inlineoverridevirtual

Writes count long values from array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 337 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ write() [8/13]

int oofem::DataStream::write ( const std ::string & data)

Reads a string (stored as an int for the length followed by char*).

Definition at line 260 of file datastream.C.

◆ write() [9/13]

int oofem::StaticCommunicationBuffer::write ( const unsigned long * data,
std::size_t count )
inlineoverridevirtual

Writes count unsigned long values from array pointed by data.

Reimplemented from oofem::CommunicationBuffer.

Definition at line 339 of file combuff.h.

References oofem::CommunicationBuffer::communicator.

◆ write() [10/13]

int oofem::DataStream::write ( double data)
inline

Definition at line 260 of file datastream.h.

◆ write() [11/13]

int oofem::DataStream::write ( int data)
inline

Definition at line 260 of file datastream.h.

◆ write() [12/13]

int oofem::DataStream::write ( long data)
inline

Definition at line 260 of file datastream.h.

◆ write() [13/13]

int oofem::DataStream::write ( unsigned long data)
inline

Definition at line 260 of file datastream.h.


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011