walberla::communication::UniformPackInfo Class Referenceabstract

Detailed Description

UniformPackInfo encapsulates information on how to extract data from blocks, that should be communicated (see packData() ) to neighboring blocks and how to inject this data in a receiving block (see unpackData() )

Another special method exists for communication between two blocks, which are allocated on the same process. In this case the data does not have be communicated via a buffer, but can be copied directly.

Data that is packed in direction "dir" at one block is unpacked in direction "stencil::inverseDir[dir]" at the neighboring block. This behavior must be implemented in "communicateLocal"!

#include <UniformPackInfo.h>

+ Inheritance diagram for walberla::communication::UniformPackInfo:

Public Member Functions

virtual bool constantDataExchange () const =0
 Should return true if the amount of data that is packed for a given block in direction "dir" is guaranteed to remain constant over time. More...
 
virtual bool threadsafeReceiving () const =0
 Must return false if calling unpackData and/or communicateLocal is not thread-safe. More...
 
void packData (const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &buffer) const
 Packs data from a block into a send buffer. More...
 
virtual void unpackData (IBlock *receiver, stencil::Direction dir, mpi::RecvBuffer &buffer)=0
 Unpacks received Data. More...
 
virtual void communicateLocal (const IBlock *sender, IBlock *receiver, stencil::Direction dir)=0
 Function to copy data from one local block to another local block. More...
 
virtual void beforeStartCommunication ()
 This function is called once before the communication is started by the UniformBufferedScheme. More...
 
virtual void afterStartCommunication ()
 This function is called once after the communication has been started by the UniformBufferedScheme. More...
 
virtual void beforeWait ()
 This function is called once before the UniformBufferedScheme waits for the communication to finish. More...
 
virtual void afterWait ()
 This function is called once after the communication has been finished by the UniformBufferedScheme. More...
 
Construction & Destruction
 UniformPackInfo ()
 
virtual ~UniformPackInfo ()
 

Protected Member Functions

virtual void packDataImpl (const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &buffer) const =0
 Packs data from a block into a send buffer. More...
 

Protected Attributes

std::map< const IBlock *, std::map< stencil::Direction, size_t > > bufferSize_
 

Constructor & Destructor Documentation

walberla::communication::UniformPackInfo::UniformPackInfo ( )
inline
virtual walberla::communication::UniformPackInfo::~UniformPackInfo ( )
inlinevirtual

Member Function Documentation

virtual void walberla::communication::UniformPackInfo::afterStartCommunication ( )
inlinevirtual

This function is called once after the communication has been started by the UniformBufferedScheme.

virtual void walberla::communication::UniformPackInfo::afterWait ( )
inlinevirtual

This function is called once after the communication has been finished by the UniformBufferedScheme.

virtual void walberla::communication::UniformPackInfo::beforeStartCommunication ( )
inlinevirtual

This function is called once before the communication is started by the UniformBufferedScheme.

virtual void walberla::communication::UniformPackInfo::beforeWait ( )
inlinevirtual

This function is called once before the UniformBufferedScheme waits for the communication to finish.

virtual void walberla::communication::UniformPackInfo::communicateLocal ( const IBlock *  sender,
IBlock *  receiver,
stencil::Direction  dir 
)
pure virtual

Function to copy data from one local block to another local block.

Both blocks are allocated on the current process. If NOT thread-safe, threadsafeReceiving must return false!

Parameters
senderid of block where the data should be copied from
receiverid of block where the data should be copied to
dirthe direction of the communication ( from sender to receiver )

Implemented in walberla::cuda::communication::GPUPackInfo< GPUField_T >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, and walberla::boundary::HandlingPackInfo< Handling_T >.

virtual bool walberla::communication::UniformPackInfo::constantDataExchange ( ) const
pure virtual

Should return true if the amount of data that is packed for a given block in direction "dir" is guaranteed to remain constant over time.

False otherwise. If you are not sure what to return, return false! Returning false is always save. Falsely return true will lead to errors! However, if the data can be guaranteed to remain constant over time, returning true enables performance optimizations during the communication.

Implemented in walberla::cuda::communication::GPUPackInfo< GPUField_T >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, and walberla::boundary::HandlingPackInfo< Handling_T >.

void walberla::communication::UniformPackInfo::packData ( const IBlock *  sender,
stencil::Direction  dir,
mpi::SendBuffer buffer 
) const
inline

Packs data from a block into a send buffer.

Must be thread-safe! Calls packDataImpl.

Parameters
senderthe block whose data should be packed into a buffer
dirpack data for neighbor in this direction
bufferbuffer for writing the data into
virtual void walberla::communication::UniformPackInfo::packDataImpl ( const IBlock *  sender,
stencil::Direction  dir,
mpi::SendBuffer buffer 
) const
protectedpure virtual
virtual bool walberla::communication::UniformPackInfo::threadsafeReceiving ( ) const
pure virtual

Must return false if calling unpackData and/or communicateLocal is not thread-safe.

True otherwise. If you are not sure what to return, return false! Returning false is always save. Falsely return true will most likely lead to errors! However, if both unpackData AND communicateLocal are thread-safe, returning true can lead to performance improvements.

Implemented in walberla::cuda::communication::GPUPackInfo< GPUField_T >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, and walberla::boundary::HandlingPackInfo< Handling_T >.

virtual void walberla::communication::UniformPackInfo::unpackData ( IBlock *  receiver,
stencil::Direction  dir,
mpi::RecvBuffer buffer 
)
pure virtual

Member Data Documentation

std::map< const IBlock *, std::map< stencil::Direction, size_t > > walberla::communication::UniformPackInfo::bufferSize_
mutableprotected

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