waLBerla 7.3
Loading...
Searching...
No Matches
walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T > Class Template Reference

Detailed Description

template<typename PdfField_T>
class walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >

Pack Info class template for lattice Boltzmann PDF fields.

Relies on a code-generated class providing kernel implementations for packing, unpacking and local copying of data.

This template relies on a PackingKernels implementation generated by lbmpy_walberla.packing_kernels. The code generated part provides the kernels for transferring data between communication buffers and fields. The iteration slices are constructed by this class.

The code-generated substructure enables the usage of arbitrary, in particular in-place streaming patterns.

Template Parameters
PackingKernels_TType of a PackingKernels implementation generated using lbmpy_walberla.generate_packing_kernels.

#include <UniformGeneratedPdfPackInfo.h>

Inheritance diagram for walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >:

Public Types

using LatticeStorageSpecification_T = typename PdfField_T::LatticeStorageSpecification
using PackingKernels_T = typename LatticeStorageSpecification_T::PackKernels
using Stencil = typename LatticeStorageSpecification_T::Stencil

Public Member Functions

 UniformGeneratedPdfPackInfo (const BlockDataID pdfFieldID, cell_idx_t cellLayersToSend=1, bool sendAll=false)
 Constructor.
bool constantDataExchange () const override
 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.
bool threadsafeReceiving () const override
 Must return false if calling unpackData and/or communicateLocal is not thread-safe.
void unpackData (IBlock *receiver, Direction dir, mpi::RecvBuffer &buffer) override
 Unpack received Data.
void communicateLocal (const IBlock *sender, IBlock *receiver, Direction dir) override
 Copy data from one local block to another local block.
 UniformPackInfo ()=default
virtual ~UniformPackInfo ()=default
void packData (const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &buffer) const
 Pack data from a block into a send buffer.
virtual void beforeStartCommunication ()
 This function is called once before the communication is started by the UniformBufferedScheme.
virtual void afterStartCommunication ()
 This function is called once after the communication has been started by the UniformBufferedScheme.
virtual void beforeWait ()
 This function is called once before the UniformBufferedScheme waits for the communication to finish.
virtual void afterWait ()
 This function is called once after the communication has been finished by the UniformBufferedScheme.

Protected Member Functions

void packDataImpl (const IBlock *sender, Direction dir, mpi::SendBuffer &buffer) const override
 Pack data from a block into a send buffer.

Private Attributes

const BlockDataID pdfFieldID_
internal::UniformPackingKernelsWrapper< PdfField_T, LatticeStorageSpecification_T::inplace > kernels_
cell_idx_t ghostLayersToSend_
bool sendAll_

Additional Inherited Members

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

Member Typedef Documentation

◆ LatticeStorageSpecification_T

template<typename PdfField_T>
using walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::LatticeStorageSpecification_T = typename PdfField_T::LatticeStorageSpecification

◆ PackingKernels_T

template<typename PdfField_T>
using walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::PackingKernels_T = typename LatticeStorageSpecification_T::PackKernels

◆ Stencil

template<typename PdfField_T>
using walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::Stencil = typename LatticeStorageSpecification_T::Stencil

Constructor & Destructor Documentation

◆ UniformGeneratedPdfPackInfo()

template<typename PdfField_T>
walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::UniformGeneratedPdfPackInfo ( const BlockDataID pdfFieldID,
cell_idx_t cellLayersToSend = 1,
bool sendAll = false )
inline

Constructor.

Parameters
pdfFieldIDID of the associated walberla::lbm::PdfField
cellLayersToSendThe amount of cell layers that should be communicated
sendAllIf true, instead of only those populations streaming in subdirections of the communication direction, all populations will always be communicated.
Warning
Be careful when using this option with any streaming pattern other than the pull pattern. Other patterns store at least some of their post-collision populations in neighbouring cells. This might lead to out-of-bounds errors when copying to the outermost ghost layer! Solve this by adding an additional ghost layer as a safety margin.

Member Function Documentation

◆ communicateLocal()

template<typename PdfField_T>
void walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::communicateLocal ( const IBlock * sender,
IBlock * receiver,
Direction dir )
overridevirtual

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 )

Implements walberla::communication::UniformPackInfo.

◆ constantDataExchange()

template<typename PdfField_T>
bool walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::constantDataExchange ( ) const
inlineoverridevirtual

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 safe. Falsely returning 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.

Implements walberla::communication::UniformPackInfo.

◆ packDataImpl()

template<typename PdfField_T>
void walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::packDataImpl ( const IBlock * sender,
Direction dir,
mpi::SendBuffer & buffer ) const
overrideprotectedvirtual

Pack data from a block into a send buffer.

Must be thread-safe!

Implementations must reserve extra space and advance the send buffer pointer according to the alignment of the ghost layer data type! The buffer is char-aligned.

Parameters
senderthe block whose data should be packed into a buffer
dirpack data for neighbor in this direction
bufferbuffer for writing the data into

Implements walberla::communication::UniformPackInfo.

◆ threadsafeReceiving()

template<typename PdfField_T>
bool walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::threadsafeReceiving ( ) const
inlineoverridevirtual

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 safe. Falsely returning true will most likely lead to errors! However, if both unpackData AND communicateLocal are thread-safe, returning true can lead to performance improvements.

Implements walberla::communication::UniformPackInfo.

◆ unpackData()

template<typename PdfField_T>
void walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::unpackData ( IBlock * receiver,
Direction dir,
mpi::RecvBuffer & buffer )
overridevirtual

Unpack received Data.

If NOT thread-safe, threadsafeReceiving must return false!

Implementations must reserve extra space and advance the send buffer pointer according to the alignment of the ghost layer data type! The buffer is char-aligned.

Parameters
receiverthe block where the unpacked data should be stored into
dirreceive data from neighbor in this direction
bufferbuffer for reading the data from

Implements walberla::communication::UniformPackInfo.

Member Data Documentation

◆ ghostLayersToSend_

template<typename PdfField_T>
cell_idx_t walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::ghostLayersToSend_
private

◆ kernels_

template<typename PdfField_T>
internal::UniformPackingKernelsWrapper< PdfField_T, LatticeStorageSpecification_T::inplace > walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::kernels_
private

◆ pdfFieldID_

◆ sendAll_

template<typename PdfField_T>
bool walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >::sendAll_
private

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