walberla::domain_decomposition::BlockStorage Class Referenceabstract

Detailed Description

Base class for block storage data structures (the entire simulation space is partitioned into blocks [see class 'IBlock'], and block storage data structures manage these blocks)

The class 'BlockStorage' already provides some basic functionality that every block storage data structure will possess - regardless of the actual implementation of any derived class. Every block storage data structure ...

  • ... possesses an axis-aligned bounding box that covers the entire simulation space/domain.
  • ... holds information about whether or not the simulation is periodic in x-/y-/z-direction.
  • ... provides iterators for traversing all locally allocated blocks (that is all blocks that are assigned to this process).
  • ... provides a mechanism for registering block data handling objects. These objects are used to add any kind of data to blocks.

'BlockStorage' also acts as an interface class which requires every derived class to implement a set of functions that can be used to retrieve locally allocated blocks that match certain criteria (for example all blocks that are contained within a certain region of the simulation space). For more information on which functions must be implemented by a derived class refer to the documentation of the public interface of 'BlockStorage'.

#include <BlockStorage.h>

+ Inheritance diagram for walberla::domain_decomposition::BlockStorage:

Classes

class  const_iterator
 
class  iterator
 

Public Types

using BlockContainerType = std::map< IBlockID::IDType, IBlock * >
 

Public Member Functions

bool isXPeriodic () const
 
bool isYPeriodic () const
 
bool isZPeriodic () const
 
bool isPeriodic (const uint_t index) const
 
void mapToPeriodicDomain (real_t &x, real_t &y, real_t &z) const
 For documentation, see documentation of free function 'void mapPointToPeriodicDomain( const std::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z )'. More...
 
void mapToPeriodicDomain (Vector3< real_t > &p) const
 
bool periodicIntersect (const math::AABB &box1, const math::AABB &box2) const
 For documentation, see documentation of free function 'bool periodicIntersect( const std::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB & box1, const math::AABB & box2 )'. More...
 
bool periodicIntersect (const math::AABB &box1, const math::AABB &box2, const real_t dx) const
 For documentation, see documentation of free function 'bool periodicIntersect( const std::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB & box1, const math::AABB & box2 )'. More...
 
bool operator== (const BlockStorage &rhs) const
 The following members are not used for checking if two BlockStorage objects are equal: iBlocks_. More...
 
bool operator!= (const BlockStorage &rhs) const
 
iterator begin (const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet())
 iterator for traversing all locally allocated blocks More...
 
const_iterator begin (const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet()) const
 iterator for traversing all locally allocated blocks More...
 
bool empty () const
 
void getBlocks (std::vector< const IBlock * > &blocks) const
 inserts all locally allocated blocks into vector 'blocks' More...
 
void getBlocks (std::vector< IBlock * > &blocks)
 inserts all locally allocated blocks into vector 'blocks' More...
 
virtual void getBlocksContainedWithinAABB (std::vector< const IBlock * > &blocks, const AABB &aabb) const =0
 Calling this function causes all locally allocated blocks that are completely contained within the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'. More...
 
virtual void getBlocksContainedWithinAABB (std::vector< IBlock * > &blocks, const AABB &aabb)=0
 Calling this function causes all locally allocated blocks that are completely contained within the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'. More...
 
virtual void getBlocksOverlappedByAABB (std::vector< const IBlock * > &blocks, const AABB &aabb) const =0
 Calling this function causes all locally allocated blocks that intersect with the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'. More...
 
virtual void getBlocksOverlappedByAABB (std::vector< IBlock * > &blocks, const AABB &aabb)=0
 Calling this function causes all locally allocated blocks that intersect with the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'. More...
 
virtual const IBlockgetBlock (const IBlockID &id) const =0
 Returns the block associated with block ID 'id' (returns 'NULL' if the block doesn't exist locally!). More...
 
const IBlockgetBlock (const IBlockID::IDType &id) const
 
virtual IBlockgetBlock (const IBlockID &id)=0
 Returns the block associated with block ID 'id' (returns 'NULL' if the block doesn't exist locally!). More...
 
IBlockgetBlock (const IBlockID::IDType &id)
 
virtual const IBlockgetBlock (const real_t x, const real_t y, const real_t z) const =0
 Returns the block located at position (x,y,z) (returns 'NULL' if the block doesn't exist locally!). More...
 
const IBlockgetBlock (const Vector3< real_t > &p) const
 
virtual IBlockgetBlock (const real_t x, const real_t y, const real_t z)=0
 Returns the block located at position (x,y,z) (returns 'NULL' if the block doesn't exist locally!). More...
 
IBlockgetBlock (const Vector3< real_t > &p)
 
virtual bool containsGlobalBlockInformation () const =0
 Indicates whether or not information about remote blocks (blocks that reside on other processes) is available. More...
 
virtual void getAllBlocks (std::vector< shared_ptr< IBlockID > > &blocks) const =0
 Returns the block ID of every block in the simulation (global and remote). More...
 
virtual bool blockExists (const real_t x, const real_t y, const real_t z) const =0
 Returns true if there exists a block at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'. More...
 
bool blockExists (const Vector3< real_t > &p) const
 
virtual bool blockExistsLocally (const real_t x, const real_t y, const real_t z) const =0
 Returns true if locally there exists a block at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'. More...
 
bool blockExistsLocally (const Vector3< real_t > &p) const
 
virtual bool blockExistsRemotely (const real_t x, const real_t y, const real_t z) const =0
 Returns true if remotely there exists a block at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'. More...
 
bool blockExistsRemotely (const Vector3< real_t > &p) const
 
virtual bool blockExists (const IBlockID &id) const =0
 Returns true if there exists a block with block ID 'id'. More...
 
virtual bool blockExistsLocally (const IBlockID &id) const =0
 Returns true if locally there exists a block with block ID 'id'. More...
 
virtual bool blockExistsRemotely (const IBlockID &id) const =0
 Returns true if remotely there exists a block with block ID 'id'. More...
 
virtual void getBlockID (IBlockID &id, const real_t x, const real_t y, const real_t z) const =0
 Returns the block ID that corresponds to the block located at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'. More...
 
void getBlockID (IBlockID &id, const Vector3< real_t > &p) const
 
virtual uint_t getLevel (const IBlock &) const
 must return the level the block "block" is assigned to (must be an unsigned integer in the range [0,'number-of-levels') ) More...
 
virtual void getAABB (AABB &aabb, const IBlockID &id) const =0
 Returns the axis-aligned bounding box that corresponds to the block with ID 'id'. More...
 
AABB getAABB (const IBlockID &id) const
 
virtual void getState (Set< SUID > &state, const IBlockID &id) const =0
 Returns the block state that corresponds to the block with ID 'id'. More...
 
Set< SUID > getState (const IBlockID &id) const
 
virtual void getProcessRank (uint_t &rank, const IBlockID &id) const =0
 Returns the rank of the process the block with ID 'id' resides on. More...
 
uint_t getProcessRank (const IBlockID &id) const
 
bool atDomainXMinBorder (const IBlock &block) const
 Returns true if the block 'block' is located at the lower x-axis border of the domain. More...
 
bool atDomainXMaxBorder (const IBlock &block) const
 Returns true if the block 'block' is located at the upper x-axis border of the domain. More...
 
bool atDomainYMinBorder (const IBlock &block) const
 Returns true if the block 'block' is located at the lower y-axis border of the domain. More...
 
bool atDomainYMaxBorder (const IBlock &block) const
 Returns true if the block 'block' is located at the upper y-axis border of the domain. More...
 
bool atDomainZMinBorder (const IBlock &block) const
 Returns true if the block 'block' is located at the lower z-axis border of the domain. More...
 
bool atDomainZMaxBorder (const IBlock &block) const
 Returns true if the block 'block' is located at the upper z-axis border of the domain. More...
 
bool atDomainMinBorder (const uint_t index, const IBlock &block) const
 
bool atDomainMaxBorder (const uint_t index, const IBlock &block) const
 
virtual const std::vector< uint_t > & getNeighboringProcesses () const =0
 Returns all neighboring process IDs. More...
 
virtual std::map< uint_t, std::vector< Vector3< real_t > > > getNeighboringProcessOffsets () const =0
 For every neighboring process one or more offsets must be returned. More...
 
internal::BlockDataHandlingAdder addBlockData (const std::string &identifier=std::string())
 Must be used if multiple block data handling objects with different selection attributes are registered for initializing the same block data "item". More...
 
template<typename T >
BlockDataID addBlockData (const shared_ptr< T > &dataHandling, const std::string &identifier=std::string(), const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet())
 This function can be used for initializing a new block data "item". More...
 
template<typename T >
BlockDataID addBlockData (std::function< T *(IBlock *const block) > function, const std::string &identifier=std::string(), const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet())
 This function can be used for initializing a new block data "item". More...
 
BlockDataID addBlockData (const internal::SelectableBlockDataHandlingWrapper &dataHandling, const std::string &identifier=std::string())
 After registering one/multiple block data handling objects, this function is called for actually adding data to the blocks. More...
 
template<typename T >
BlockDataID loadBlockData (const std::string &file, const shared_ptr< T > &dataHandling, const std::string &identifier=std::string(), const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet())
 This function can be used for initializing a new block data "item" by loading the data from file. More...
 
BlockDataID loadBlockData (const std::string &file, const internal::SelectableBlockDataHandlingWrapper &dataHandling, const std::string &identifier=std::string())
 After registering one/multiple block data handling objects, this function is called for actually adding data to the blocks by loading the data from file. More...
 
void saveBlockData (const std::string &file, const BlockDataID &id)
 This function can be used to store the data that corresponds to 'id' to file, so that later (probably when restarting a simulation) the data can be loaded by using the member function 'loadBlockData'. More...
 
void serializeBlockData (const BlockDataID &id, mpi::SendBuffer &buffer)
 This function serializes the block data into a sendbuffer. More...
 
void deserializeBlockData (const BlockDataID &id, mpi::RecvBuffer &buffer)
 Deserializes data form a recv buffer into existing block data Only deserialize data, that has be serialized with serializeBlockData. More...
 
void clearBlockData (const BlockDataID &id)
 This function can be used for removing all data that corresponds to block data ID 'id'. More...
 
uint_t numberOfBlockDataItems () const
 
std::vector< std::string > getBlockDataIdentifiers () const
 
const std::string & getBlockDataIdentifier (const ConstBlockDataID &id) const
 
void rebuildProcessesWithBlocksCommunicator ()
 
MPI_Comm processesWithBlocksCommunicator ()
 Returns a MPI communicator that only contains processes that possess blocks. More...
 

Protected Member Functions

 BlockStorage (const AABB &domain, const bool xPeriodic, const bool yPeriodic, const bool zPeriodic)
 Every derived class must call this constructor! More...
 
virtual ~BlockStorage ()
 Must not be made public! No one should be allowed to delete a variable of type 'BlockStorage*'. More...
 
virtual bool equal (const BlockStorage *rhs) const =0
 
void addBlockData (IBlock *const block, const BlockDataID &index, internal::BlockData *const data)
 

Protected Attributes

AABB domain_
 axis-aligned bounding box for the entire simulation space/domain More...
 
bool periodic_ [3]
 periodicity flags More...
 
std::vector< internal::BlockDataItemblockDataItem_
 

Private Member Functions

 BlockStorage ()
 Must not be made public or protected! Derived classes must call one of the available public/protected constructors. More...
 
void registerBlock (const std::pair< IBlockID::IDType, IBlock * > &block)
 This function is called every time a new local block that belongs to this block storage data structure is created (see the constructor of 'IBlock'). More...
 
void removeBlock (const IBlock *block)
 This function is called every time a block that belongs to this block storage data structure is destroyed (see the destructor of 'IBlock'). More...
 
void removeBlock (const IBlockID::IDType &blockID)
 This function is called every time a block that belongs to this block storage data structure is destroyed (see the destructor of 'IBlock'). More...
 
- Private Member Functions inherited from walberla::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Private Attributes

BlockContainerType iBlocks_
 holds pointers to all locally allocated blocks More...
 
bool rebuildProcessesWithBlocksCommunicator_
 
MPI_Comm processesWithBlocksCommunicator_
 MPI communicator that only contains processes that possess blocks. More...
 

Friends

class IBlock
 
class StructuredBlockStorage
 

Member Typedef Documentation

◆ BlockContainerType

Constructor & Destructor Documentation

◆ BlockStorage() [1/2]

walberla::domain_decomposition::BlockStorage::BlockStorage ( const AABB &  domain,
const bool  xPeriodic,
const bool  yPeriodic,
const bool  zPeriodic 
)
inlineprotected

Every derived class must call this constructor!

◆ ~BlockStorage()

walberla::domain_decomposition::BlockStorage::~BlockStorage ( )
inlineprotectedvirtual

Must not be made public! No one should be allowed to delete a variable of type 'BlockStorage*'.

◆ BlockStorage() [2/2]

walberla::domain_decomposition::BlockStorage::BlockStorage ( )
private

Must not be made public or protected! Derived classes must call one of the available public/protected constructors.

Member Function Documentation

◆ addBlockData() [1/5]

BlockDataID walberla::domain_decomposition::BlockStorage::addBlockData ( const internal::SelectableBlockDataHandlingWrapper dataHandling,
const std::string &  identifier = std::string() 
)

After registering one/multiple block data handling objects, this function is called for actually adding data to the blocks.

◆ addBlockData() [2/5]

template<typename T >
BlockDataID walberla::domain_decomposition::BlockStorage::addBlockData ( const shared_ptr< T > &  dataHandling,
const std::string &  identifier = std::string(),
const Set< SUID > &  requiredSelectors = Set<SUID>::emptySet(),
const Set< SUID > &  incompatibleSelectors = Set<SUID>::emptySet() 
)
inline

This function can be used for initializing a new block data "item".

A 'BlockDataID' that corresponds to this block data "item" is returned. This block data ID must be used to access/retrieve block data (see function 'getData' of class 'IBlock'). If multiple block data handling objects with different selection attributes shall be used for initializing the same block data "item" see member function "addBlockData( const std::string & identifier )"

◆ addBlockData() [3/5]

internal::BlockDataHandlingAdder walberla::domain_decomposition::BlockStorage::addBlockData ( const std::string &  identifier = std::string())
inline

Must be used if multiple block data handling objects with different selection attributes are registered for initializing the same block data "item".

A 'BlockDataID' that corresponds to this block data "item" is returned.

Usage: BlockDataID id = blockStorage.addBlockData( "[optional block data identifier]" ) << BlockDataCreator( ... ) << BlockDataCreator( ... ) << ... ;

◆ addBlockData() [4/5]

void walberla::domain_decomposition::BlockStorage::addBlockData ( IBlock *const  block,
const BlockDataID index,
internal::BlockData *const  data 
)
inlineprotected

◆ addBlockData() [5/5]

template<typename T >
BlockDataID walberla::domain_decomposition::BlockStorage::addBlockData ( std::function< T *(IBlock *const block) >  function,
const std::string &  identifier = std::string(),
const Set< SUID > &  requiredSelectors = Set<SUID>::emptySet(),
const Set< SUID > &  incompatibleSelectors = Set<SUID>::emptySet() 
)
inline

This function can be used for initializing a new block data "item".

A 'BlockDataID' that corresponds to this block data "item" is returned. This block data ID must be used to access/retrieve block data (see function 'getData' of class 'IBlock'). If multiple initialization functions with different selection attributes shall be used for initializing the same block data "item" see member function "addBlockData( const std::string & identifier )"

◆ atDomainMaxBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainMaxBorder ( const uint_t  index,
const IBlock block 
) const
inline

◆ atDomainMinBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainMinBorder ( const uint_t  index,
const IBlock block 
) const
inline

◆ atDomainXMaxBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainXMaxBorder ( const IBlock block) const
inline

Returns true if the block 'block' is located at the upper x-axis border of the domain.

◆ atDomainXMinBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainXMinBorder ( const IBlock block) const
inline

Returns true if the block 'block' is located at the lower x-axis border of the domain.

◆ atDomainYMaxBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainYMaxBorder ( const IBlock block) const
inline

Returns true if the block 'block' is located at the upper y-axis border of the domain.

◆ atDomainYMinBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainYMinBorder ( const IBlock block) const
inline

Returns true if the block 'block' is located at the lower y-axis border of the domain.

◆ atDomainZMaxBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainZMaxBorder ( const IBlock block) const
inline

Returns true if the block 'block' is located at the upper z-axis border of the domain.

◆ atDomainZMinBorder()

bool walberla::domain_decomposition::BlockStorage::atDomainZMinBorder ( const IBlock block) const
inline

Returns true if the block 'block' is located at the lower z-axis border of the domain.

◆ begin() [1/2]

iterator walberla::domain_decomposition::BlockStorage::begin ( const Set< SUID > &  requiredSelectors = Set<SUID>::emptySet(),
const Set< SUID > &  incompatibleSelectors = Set<SUID>::emptySet() 
)
inline

iterator for traversing all locally allocated blocks

◆ begin() [2/2]

const_iterator walberla::domain_decomposition::BlockStorage::begin ( const Set< SUID > &  requiredSelectors = Set<SUID>::emptySet(),
const Set< SUID > &  incompatibleSelectors = Set<SUID>::emptySet() 
) const
inline

iterator for traversing all locally allocated blocks

◆ blockExists() [1/3]

virtual bool walberla::domain_decomposition::BlockStorage::blockExists ( const IBlockID id) const
pure virtual

Returns true if there exists a block with block ID 'id'.

This member function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'.

Implemented in walberla::blockforest::BlockForest.

◆ blockExists() [2/3]

virtual bool walberla::domain_decomposition::BlockStorage::blockExists ( const real_t  x,
const real_t  y,
const real_t  z 
) const
pure virtual

Returns true if there exists a block at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'.

]. This member function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'.

Implemented in walberla::blockforest::BlockForest.

◆ blockExists() [3/3]

bool walberla::domain_decomposition::BlockStorage::blockExists ( const Vector3< real_t > &  p) const
inline

◆ blockExistsLocally() [1/3]

virtual bool walberla::domain_decomposition::BlockStorage::blockExistsLocally ( const IBlockID id) const
pure virtual

Returns true if locally there exists a block with block ID 'id'.

This member function is always guaranteed to work properly, even if 'containsGlobalBlockInformation() == false'.

Implemented in walberla::blockforest::BlockForest.

◆ blockExistsLocally() [2/3]

virtual bool walberla::domain_decomposition::BlockStorage::blockExistsLocally ( const real_t  x,
const real_t  y,
const real_t  z 
) const
pure virtual

Returns true if locally there exists a block at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'.

]. This member function is always guaranteed to work properly, even if 'containsGlobalBlockInformation() == false'.

Implemented in walberla::blockforest::BlockForest.

◆ blockExistsLocally() [3/3]

bool walberla::domain_decomposition::BlockStorage::blockExistsLocally ( const Vector3< real_t > &  p) const
inline

◆ blockExistsRemotely() [1/3]

virtual bool walberla::domain_decomposition::BlockStorage::blockExistsRemotely ( const IBlockID id) const
pure virtual

Returns true if remotely there exists a block with block ID 'id'.

This member function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'.

Implemented in walberla::blockforest::BlockForest.

◆ blockExistsRemotely() [2/3]

virtual bool walberla::domain_decomposition::BlockStorage::blockExistsRemotely ( const real_t  x,
const real_t  y,
const real_t  z 
) const
pure virtual

Returns true if remotely there exists a block at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'.

]. This member function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'.

Implemented in walberla::blockforest::BlockForest.

◆ blockExistsRemotely() [3/3]

bool walberla::domain_decomposition::BlockStorage::blockExistsRemotely ( const Vector3< real_t > &  p) const
inline

◆ clearBlockData()

void walberla::domain_decomposition::BlockStorage::clearBlockData ( const BlockDataID id)
inline

This function can be used for removing all data that corresponds to block data ID 'id'.

Please note: The block data ID 'id' will still be valid, but blocks won't return anything anymore, they will only return NULL for 'id'.

◆ containsGlobalBlockInformation()

virtual bool walberla::domain_decomposition::BlockStorage::containsGlobalBlockInformation ( ) const
pure virtual

Indicates whether or not information about remote blocks (blocks that reside on other processes) is available.

This information includes the process rank, the state, and the axis-aligned bounding box of any block (local or remote).

Implemented in walberla::blockforest::BlockForest.

◆ deserializeBlockData()

void walberla::domain_decomposition::BlockStorage::deserializeBlockData ( const BlockDataID id,
mpi::RecvBuffer buffer 
)

Deserializes data form a recv buffer into existing block data Only deserialize data, that has be serialized with serializeBlockData.

◆ empty()

bool walberla::domain_decomposition::BlockStorage::empty ( ) const
inline

◆ equal()

virtual bool walberla::domain_decomposition::BlockStorage::equal ( const BlockStorage rhs) const
protectedpure virtual

◆ getAABB() [1/2]

virtual void walberla::domain_decomposition::BlockStorage::getAABB ( AABB &  aabb,
const IBlockID id 
) const
pure virtual

Returns the axis-aligned bounding box that corresponds to the block with ID 'id'.

For local blocks, this function is always guaranteed to work. For remote blocks, this function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'. If the request cannot be satisfied, the simulation must be aborted and the call to this function must not return!

Implemented in walberla::blockforest::BlockForest.

◆ getAABB() [2/2]

AABB walberla::domain_decomposition::BlockStorage::getAABB ( const IBlockID id) const
inline

◆ getAllBlocks()

virtual void walberla::domain_decomposition::BlockStorage::getAllBlocks ( std::vector< shared_ptr< IBlockID > > &  blocks) const
pure virtual

Returns the block ID of every block in the simulation (global and remote).

This member function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'.

Implemented in walberla::blockforest::BlockForest.

◆ getBlock() [1/8]

virtual const IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const IBlockID id) const
pure virtual

Returns the block associated with block ID 'id' (returns 'NULL' if the block doesn't exist locally!).

The behavior of this function is identical to:

for( const_iterator block = begin(); block != end(); ++block )
if( block->getId() == id ) return *block;
return NULL;

Implemented in walberla::blockforest::BlockForest.

◆ getBlock() [2/8]

virtual IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const IBlockID id)
pure virtual

Returns the block associated with block ID 'id' (returns 'NULL' if the block doesn't exist locally!).

The behavior of this function is identical to:

for( iterator block = begin(); block != end(); ++block )
if( block->getId() == id ) return *block;
return NULL;

Implemented in walberla::blockforest::BlockForest.

◆ getBlock() [3/8]

IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const IBlockID::IDType id)
inline

◆ getBlock() [4/8]

const IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const IBlockID::IDType id) const
inline

◆ getBlock() [5/8]

virtual const IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const real_t  x,
const real_t  y,
const real_t  z 
) const
pure virtual

Returns the block located at position (x,y,z) (returns 'NULL' if the block doesn't exist locally!).

The behavior of this function is identical to:

for( const_iterator block = begin(); block != end(); ++block )
if( block->getAABB().contains(x,y,z) ) return *block;
return NULL;

Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'.

Implemented in walberla::blockforest::BlockForest.

◆ getBlock() [6/8]

virtual IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const real_t  x,
const real_t  y,
const real_t  z 
)
pure virtual

Returns the block located at position (x,y,z) (returns 'NULL' if the block doesn't exist locally!).

The behavior of this function is identical to:

for( iterator block = begin(); block != end(); ++block )
if( block->getAABB().contains(x,y,z) ) return *block;
return NULL;

Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'.

Implemented in walberla::blockforest::BlockForest.

◆ getBlock() [7/8]

IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const Vector3< real_t > &  p)
inline

◆ getBlock() [8/8]

const IBlock* walberla::domain_decomposition::BlockStorage::getBlock ( const Vector3< real_t > &  p) const
inline

◆ getBlockDataIdentifier()

const std::string & walberla::domain_decomposition::BlockStorage::getBlockDataIdentifier ( const ConstBlockDataID id) const
inline

◆ getBlockDataIdentifiers()

std::vector< std::string > walberla::domain_decomposition::BlockStorage::getBlockDataIdentifiers ( ) const
inline

◆ getBlockID() [1/2]

virtual void walberla::domain_decomposition::BlockStorage::getBlockID ( IBlockID id,
const real_t  x,
const real_t  y,
const real_t  z 
) const
pure virtual

Returns the block ID that corresponds to the block located at position (x,y,z) [Periodicity is not considered! For mapping points to the periodic simulation space see 'mapToPeriodicDomain'.

]. For local blocks, this function is always guaranteed to work. For remote blocks, this function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'. If the request cannot be satisfied (for example if no block exists at location (x,y,z)), the simulation must be aborted and the call to this function must not return!

Implemented in walberla::blockforest::BlockForest.

◆ getBlockID() [2/2]

void walberla::domain_decomposition::BlockStorage::getBlockID ( IBlockID id,
const Vector3< real_t > &  p 
) const
inline

◆ getBlocks() [1/2]

void walberla::domain_decomposition::BlockStorage::getBlocks ( std::vector< const IBlock * > &  blocks) const
inline

inserts all locally allocated blocks into vector 'blocks'

◆ getBlocks() [2/2]

void walberla::domain_decomposition::BlockStorage::getBlocks ( std::vector< IBlock * > &  blocks)
inline

inserts all locally allocated blocks into vector 'blocks'

◆ getBlocksContainedWithinAABB() [1/2]

virtual void walberla::domain_decomposition::BlockStorage::getBlocksContainedWithinAABB ( std::vector< const IBlock * > &  blocks,
const AABB &  aabb 
) const
pure virtual

Calling this function causes all locally allocated blocks that are completely contained within the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'.

The behavior of this function is identical to:

for( const_iterator block = begin(); block != end(); ++block )
if( aabb.contains( block->getAABB() ) ) blocks.push_back( *block );

Implemented in walberla::blockforest::BlockForest.

◆ getBlocksContainedWithinAABB() [2/2]

virtual void walberla::domain_decomposition::BlockStorage::getBlocksContainedWithinAABB ( std::vector< IBlock * > &  blocks,
const AABB &  aabb 
)
pure virtual

Calling this function causes all locally allocated blocks that are completely contained within the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'.

The behavior of this function is identical to:

for( iterator block = begin(); block != end(); ++block )
if( aabb.contains( block->getAABB() ) ) blocks.push_back( *block );

Implemented in walberla::blockforest::BlockForest.

◆ getBlocksOverlappedByAABB() [1/2]

virtual void walberla::domain_decomposition::BlockStorage::getBlocksOverlappedByAABB ( std::vector< const IBlock * > &  blocks,
const AABB &  aabb 
) const
pure virtual

Calling this function causes all locally allocated blocks that intersect with the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'.

The behavior of this function is identical to:

for( const_iterator block = begin(); block != end(); ++block )
if( aabb.intersects( block->getAABB() ) ) blocks.push_back( *block );

Implemented in walberla::blockforest::BlockForest.

◆ getBlocksOverlappedByAABB() [2/2]

virtual void walberla::domain_decomposition::BlockStorage::getBlocksOverlappedByAABB ( std::vector< IBlock * > &  blocks,
const AABB &  aabb 
)
pure virtual

Calling this function causes all locally allocated blocks that intersect with the axis-aligned bounding box 'aabb' to be inserted at the end of vector 'blocks'.

The behavior of this function is identical to:

for( iterator block = begin(); block != end(); ++block )
if( aabb.intersects( block->getAABB() ) ) blocks.push_back( *block );

Implemented in walberla::blockforest::BlockForest.

◆ getLevel()

virtual uint_t walberla::domain_decomposition::BlockStorage::getLevel ( const IBlock ) const
inlinevirtual

must return the level the block "block" is assigned to (must be an unsigned integer in the range [0,'number-of-levels') )

Reimplemented in walberla::blockforest::BlockForest.

◆ getNeighboringProcesses()

virtual const std::vector< uint_t >& walberla::domain_decomposition::BlockStorage::getNeighboringProcesses ( ) const
pure virtual

Returns all neighboring process IDs.

Implemented in walberla::blockforest::BlockForest.

◆ getNeighboringProcessOffsets()

virtual std::map< uint_t, std::vector< Vector3<real_t> > > walberla::domain_decomposition::BlockStorage::getNeighboringProcessOffsets ( ) const
pure virtual

For every neighboring process one or more offsets must be returned.

Normally, for every neighboring process exactly one offset is returned: (0,0,0). Only in case of periodicity this offset can be different from (0,0,0)! If the offset is different from (0,0,0), the x-component must be identical to either 0 or +/- the x-width of the domain. The same applies for y and z. What this offset is supposed to do: Each block in 3D has 26 neighborhood regions. Suppose we leave block A in direction (-1,0,0) and enter the neighboring block B, which is stored on another process. If A is located at the x-min border of the domain and the simulation is only periodic in x-direction, block B must be located at the x-max border of the domain and the corresponding offset to block B - or more precisely to the process storing block B - is (+ x-width of the domain, 0, 0). Since each process can store multiple blocks and a simulation can be periodic in more than just one direction, there may be multiple offsets to another process - hence the std::vector. For an actual implementation of "getNeighboringProcessOffsets()" see BlockForest.cpp.

Implemented in walberla::blockforest::BlockForest.

◆ getProcessRank() [1/2]

uint_t walberla::domain_decomposition::BlockStorage::getProcessRank ( const IBlockID id) const
inline

◆ getProcessRank() [2/2]

virtual void walberla::domain_decomposition::BlockStorage::getProcessRank ( uint_t rank,
const IBlockID id 
) const
pure virtual

Returns the rank of the process the block with ID 'id' resides on.

For local blocks, this function is always guaranteed to work. For remote blocks, this function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'. If the request cannot be satisfied, the simulation must be aborted and the call to this function must not return!

Implemented in walberla::blockforest::BlockForest.

◆ getState() [1/2]

Set<SUID> walberla::domain_decomposition::BlockStorage::getState ( const IBlockID id) const
inline

◆ getState() [2/2]

virtual void walberla::domain_decomposition::BlockStorage::getState ( Set< SUID > &  state,
const IBlockID id 
) const
pure virtual

Returns the block state that corresponds to the block with ID 'id'.

For local blocks, this function is always guaranteed to work. For remote blocks, this function is guaranteed to work properly only if 'containsGlobalBlockInformation() == true'. If the request cannot be satisfied, the simulation must be aborted and the call to this function must not return!

Implemented in walberla::blockforest::BlockForest.

◆ isPeriodic()

bool walberla::domain_decomposition::BlockStorage::isPeriodic ( const uint_t  index) const
inline

◆ isXPeriodic()

bool walberla::domain_decomposition::BlockStorage::isXPeriodic ( ) const
inline

◆ isYPeriodic()

bool walberla::domain_decomposition::BlockStorage::isYPeriodic ( ) const
inline

◆ isZPeriodic()

bool walberla::domain_decomposition::BlockStorage::isZPeriodic ( ) const
inline

◆ loadBlockData() [1/2]

BlockDataID walberla::domain_decomposition::BlockStorage::loadBlockData ( const std::string &  file,
const internal::SelectableBlockDataHandlingWrapper dataHandling,
const std::string &  identifier = std::string() 
)

After registering one/multiple block data handling objects, this function is called for actually adding data to the blocks by loading the data from file.

ATTENTION: If the data was previously saved to file during a parallel run, the current run must also be in parallel with the exact same block structure (same blocks, same block states, etc.) and the same number of processes. Analogously, data saved during a serial run can only be loaded during another serial run.

◆ loadBlockData() [2/2]

template<typename T >
BlockDataID walberla::domain_decomposition::BlockStorage::loadBlockData ( const std::string &  file,
const shared_ptr< T > &  dataHandling,
const std::string &  identifier = std::string(),
const Set< SUID > &  requiredSelectors = Set<SUID>::emptySet(),
const Set< SUID > &  incompatibleSelectors = Set<SUID>::emptySet() 
)
inline

This function can be used for initializing a new block data "item" by loading the data from file.

A 'BlockDataID' that corresponds to this block data "item" is returned. This block data ID must be used to access/retrieve block data (see function 'getData' of class 'IBlock').

◆ mapToPeriodicDomain() [1/2]

void walberla::domain_decomposition::BlockStorage::mapToPeriodicDomain ( real_t x,
real_t y,
real_t z 
) const

For documentation, see documentation of free function 'void mapPointToPeriodicDomain( const std::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z )'.

◆ mapToPeriodicDomain() [2/2]

void walberla::domain_decomposition::BlockStorage::mapToPeriodicDomain ( Vector3< real_t > &  p) const
inline

◆ numberOfBlockDataItems()

uint_t walberla::domain_decomposition::BlockStorage::numberOfBlockDataItems ( ) const
inline

◆ operator!=()

bool walberla::domain_decomposition::BlockStorage::operator!= ( const BlockStorage rhs) const
inline

◆ operator==()

bool walberla::domain_decomposition::BlockStorage::operator== ( const BlockStorage rhs) const
inline

The following members are not used for checking if two BlockStorage objects are equal: iBlocks_.

◆ periodicIntersect() [1/2]

bool walberla::domain_decomposition::BlockStorage::periodicIntersect ( const math::AABB box1,
const math::AABB box2 
) const

◆ periodicIntersect() [2/2]

bool walberla::domain_decomposition::BlockStorage::periodicIntersect ( const math::AABB box1,
const math::AABB box2,
const real_t  dx 
) const

◆ processesWithBlocksCommunicator()

MPI_Comm walberla::domain_decomposition::BlockStorage::processesWithBlocksCommunicator ( )

Returns a MPI communicator that only contains processes that possess blocks.

ATTENTION: This function must always be called by ALL processes, otherwise the mpi::allGather call will stall! Also, the MPI communicator returned by this function must not be stored outside of this BlockStorage class. Every time a MPI communicator that only contains processes that possess blocks is needed, this member function of class BlockStorage must be called - only by doing so you are guaranteed to receive a valid MPI communicator. If blocks have moved between processes, an updated MPI communicator will be returned, otherwise a still valid, internally stored communicator is returned.

◆ rebuildProcessesWithBlocksCommunicator()

void walberla::domain_decomposition::BlockStorage::rebuildProcessesWithBlocksCommunicator ( )
inline

◆ registerBlock()

void walberla::domain_decomposition::BlockStorage::registerBlock ( const std::pair< IBlockID::IDType, IBlock * > &  block)
inlineprivate

This function is called every time a new local block that belongs to this block storage data structure is created (see the constructor of 'IBlock').

By doing so, the base class 'BlockStorage' is able to provide iterators for traversing all locally allocated blocks.

◆ removeBlock() [1/2]

void walberla::domain_decomposition::BlockStorage::removeBlock ( const IBlock block)
inlineprivate

This function is called every time a block that belongs to this block storage data structure is destroyed (see the destructor of 'IBlock').

By doing so, the base class 'BlockStorage' is able to provide iterators for traversing all locally allocated blocks.

◆ removeBlock() [2/2]

void walberla::domain_decomposition::BlockStorage::removeBlock ( const IBlockID::IDType blockID)
inlineprivate

This function is called every time a block that belongs to this block storage data structure is destroyed (see the destructor of 'IBlock').

By doing so, the base class 'BlockStorage' is able to provide iterators for traversing all locally allocated blocks.

◆ saveBlockData()

void walberla::domain_decomposition::BlockStorage::saveBlockData ( const std::string &  file,
const BlockDataID id 
)

This function can be used to store the data that corresponds to 'id' to file, so that later (probably when restarting a simulation) the data can be loaded by using the member function 'loadBlockData'.

◆ serializeBlockData()

void walberla::domain_decomposition::BlockStorage::serializeBlockData ( const BlockDataID id,
mpi::SendBuffer buffer 
)

This function serializes the block data into a sendbuffer.

Friends And Related Function Documentation

◆ IBlock

friend class IBlock
friend

◆ StructuredBlockStorage

friend class StructuredBlockStorage
friend

Member Data Documentation

◆ blockDataItem_

std::vector< internal::BlockDataItem > walberla::domain_decomposition::BlockStorage::blockDataItem_
protected

◆ domain_

AABB walberla::domain_decomposition::BlockStorage::domain_
protected

axis-aligned bounding box for the entire simulation space/domain

◆ iBlocks_

BlockContainerType walberla::domain_decomposition::BlockStorage::iBlocks_
private

holds pointers to all locally allocated blocks

◆ periodic_

bool walberla::domain_decomposition::BlockStorage::periodic_[3]
protected

periodicity flags

◆ processesWithBlocksCommunicator_

MPI_Comm walberla::domain_decomposition::BlockStorage::processesWithBlocksCommunicator_
private

MPI communicator that only contains processes that possess blocks.

◆ rebuildProcessesWithBlocksCommunicator_

bool walberla::domain_decomposition::BlockStorage::rebuildProcessesWithBlocksCommunicator_
private

The documentation for this class was generated from the following files:
iterator begin(const Set< SUID > &requiredSelectors=Set< SUID >::emptySet(), const Set< SUID > &incompatibleSelectors=Set< SUID >::emptySet())
iterator for traversing all locally allocated blocks
Definition: BlockStorage.h:193
Iterator end()
Definition: Create.h:71