Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | List of all members
shambase::DistributedDataShared< T > Class Template Reference

Container for objects shared between two distributed data elements. More...

#include <shambase/include/shambase/DistributedDataShared.hpp>

Public Member Functions

std::multimap< std::pair< u64, u64 >, T > & get_native ()
 Get direct access to the underlying multimap container.
 
const std::multimap< std::pair< u64, u64 >, T > & get_native () const
 const version
 
auto begin ()
 iterator forwarding
 
auto end ()
 iterator forwarding
 
auto begin () const
 iterator forwarding
 
auto end () const
 iterator forwarding
 
auto cbegin () const
 iterator forwarding
 
auto cend () const
 iterator forwarding
 
iterator add_obj (u64 left_id, u64 right_id, T &&obj)
 Add an object associated with a patch pair.
 
void for_each (std::function< void(u64, u64, T &)> &&f)
 Apply a function to all stored objects.
 
void for_each (std::function< void(u64, u64, const T &)> &&f) const
 const version
 
void tranfer_all (std::function< bool(u64, u64)> cd, DistributedDataShared &other)
 Transfer objects to another container based on a condition.
 
bool has_key (u64 left_id, u64 right_id) const
 Check if a patch pair exists in the container.
 
u64 get_element_count () const
 Get the total number of objects in the container.
 
template<class Tmap >
DistributedDataShared< Tmapmap (std::function< Tmap(u64, u64, T &)> map_func)
 Transform all objects to a new type using a mapping function.
 
template<class Tmap >
DistributedDataShared< Tmapmap (std::function< Tmap(u64, u64, const T &)> map_func) const
 const version
 
void reset ()
 Clear all objects from the container.
 
bool is_empty () const
 Check if the container is empty.
 

Detailed Description

template<class T>
class shambase::DistributedDataShared< T >

Container for objects shared between two distributed data elements.

This class manages objects that are associated with pairs of patch identifiers, typically representing interfaces or shared boundaries between computational domains. It uses a multimap to allow multiple objects for the same patch pair (typically for ghost zones with periodic boundaries).

Template Parameters
TType of objects to be stored in the container
// Create a container for shared boundary data
// Add objects for patch pairs
boundaries.add_obj(2, 3, other_boundary);
// Iterate over all shared objects
boundaries.for_each([](u64 left, u64 right, BoundaryInfo& data) {
// Process boundary data between patches left and right
});
std::uint64_t u64
64 bit unsigned integer
Container for objects shared between two distributed data elements.
iterator add_obj(u64 left_id, u64 right_id, T &&obj)
Add an object associated with a patch pair.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.

Definition at line 52 of file DistributedDataShared.hpp.

Member Function Documentation

◆ add_obj()

template<class T >
iterator shambase::DistributedDataShared< T >::add_obj ( u64  left_id,
u64  right_id,
T &&  obj 
)
inline

Add an object associated with a patch pair.

Parameters
left_idIdentifier of the first patch
right_idIdentifier of the second patch
objObject to be associated with the patch pair (moved)
Returns
Iterator pointing to the inserted element

Definition at line 95 of file DistributedDataShared.hpp.

+ Here is the call graph for this function:

◆ begin() [1/2]

template<class T >
auto shambase::DistributedDataShared< T >::begin ( )
inline

iterator forwarding

Definition at line 70 of file DistributedDataShared.hpp.

◆ begin() [2/2]

template<class T >
auto shambase::DistributedDataShared< T >::begin ( ) const
inline

iterator forwarding

Definition at line 74 of file DistributedDataShared.hpp.

◆ cbegin()

template<class T >
auto shambase::DistributedDataShared< T >::cbegin ( ) const
inline

iterator forwarding

Definition at line 78 of file DistributedDataShared.hpp.

◆ cend()

template<class T >
auto shambase::DistributedDataShared< T >::cend ( ) const
inline

iterator forwarding

Definition at line 80 of file DistributedDataShared.hpp.

◆ end() [1/2]

template<class T >
auto shambase::DistributedDataShared< T >::end ( )
inline

iterator forwarding

Definition at line 72 of file DistributedDataShared.hpp.

◆ end() [2/2]

template<class T >
auto shambase::DistributedDataShared< T >::end ( ) const
inline

iterator forwarding

Definition at line 76 of file DistributedDataShared.hpp.

◆ for_each() [1/2]

template<class T >
void shambase::DistributedDataShared< T >::for_each ( std::function< void(u64, u64, const T &)> &&  f) const
inline

const version

Definition at line 117 of file DistributedDataShared.hpp.

+ Here is the call graph for this function:

◆ for_each() [2/2]

template<class T >
void shambase::DistributedDataShared< T >::for_each ( std::function< void(u64, u64, T &)> &&  f)
inline

Apply a function to all stored objects.

Parameters
fFunction to apply, receives (left_id, right_id, object_reference)
container.for_each([](u64 left, u64 right, DataType& obj) {
// Process each object with its associated patch pair
});

Definition at line 110 of file DistributedDataShared.hpp.

+ Here is the call graph for this function:

◆ get_element_count()

template<class T >
u64 shambase::DistributedDataShared< T >::get_element_count ( ) const
inline

Get the total number of objects in the container.

Returns
Number of stored objects across all patch pairs

Definition at line 180 of file DistributedDataShared.hpp.

◆ get_native() [1/2]

template<class T >
std::multimap< std::pair< u64, u64 >, T > & shambase::DistributedDataShared< T >::get_native ( )
inline

Get direct access to the underlying multimap container.

Returns
Reference to the internal multimap storing patch pair to object mappings

Definition at line 64 of file DistributedDataShared.hpp.

◆ get_native() [2/2]

template<class T >
const std::multimap< std::pair< u64, u64 >, T > & shambase::DistributedDataShared< T >::get_native ( ) const
inline

const version

Definition at line 67 of file DistributedDataShared.hpp.

◆ has_key()

template<class T >
bool shambase::DistributedDataShared< T >::has_key ( u64  left_id,
u64  right_id 
) const
inline

Check if a patch pair exists in the container.

Parameters
left_idIdentifier of the first patch
right_idIdentifier of the second patch
Returns
True if at least one object exists for the given patch pair
if (container.has_key(1, 2)) {
// Handle existing patch pair
}

Definition at line 171 of file DistributedDataShared.hpp.

◆ is_empty()

template<class T >
bool shambase::DistributedDataShared< T >::is_empty ( ) const
inline

Check if the container is empty.

Returns
True if no objects are stored in the container

Definition at line 230 of file DistributedDataShared.hpp.

◆ map() [1/2]

template<class T >
template<class Tmap >
DistributedDataShared< Tmap > shambase::DistributedDataShared< T >::map ( std::function< Tmap(u64, u64, const T &)>  map_func) const
inline

const version

Definition at line 211 of file DistributedDataShared.hpp.

+ Here is the call graph for this function:

◆ map() [2/2]

template<class T >
template<class Tmap >
DistributedDataShared< Tmap > shambase::DistributedDataShared< T >::map ( std::function< Tmap(u64, u64, T &)>  map_func)
inline

Transform all objects to a new type using a mapping function.

Template Parameters
TmapType of the transformed objects
Parameters
map_funcTransformation function that takes (left_id, right_id, object_reference) and returns transformed object
Returns
New container with transformed objects maintaining the same patch pair associations
auto string_container = int_container.map<std::string>(
[](u64 left, u64 right, int& value) {
return std::to_string(value);
}
);
DistributedDataShared< Tmap > map(std::function< Tmap(u64, u64, T &)> map_func)
Transform all objects to a new type using a mapping function.

Definition at line 201 of file DistributedDataShared.hpp.

+ Here is the call graph for this function:

◆ reset()

template<class T >
void shambase::DistributedDataShared< T >::reset ( )
inline

Clear all objects from the container.

Definition at line 223 of file DistributedDataShared.hpp.

◆ tranfer_all()

template<class T >
void shambase::DistributedDataShared< T >::tranfer_all ( std::function< bool(u64, u64)>  cd,
DistributedDataShared< T > &  other 
)
inline

Transfer objects to another container based on a condition.

Moves objects from this container to another container if they satisfy the provided condition function. The objects are removed from this container.

Parameters
cdCondition function that takes (left_id, right_id) and returns true for objects to transfer
otherDestination container to receive the transferred objects
// Transfer objects where left_id > right_id
source.tranfer_all([](u64 left, u64 right) { return left > right; }, destination);
void tranfer_all(std::function< bool(u64, u64)> cd, DistributedDataShared &other)
Transfer objects to another container based on a condition.

Definition at line 139 of file DistributedDataShared.hpp.

+ Here is the call graph for this function:

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