Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shamrock::patch::PatchDataLayer Class Reference

PatchDataLayer container class, the layout is described in patchdata_layout. More...

#include <shamrock/include/shamrock/patch/PatchDataLayer.hpp>

Public Types

using field_variant_t = var_t

Public Member Functions

PatchDataLayerLayout & pdl ()
const PatchDataLayerLayout & pdl () const
std::shared_ptr< PatchDataLayerLayout > get_layout_ptr () const
 PatchDataLayer (const std::shared_ptr< PatchDataLayerLayout > &pdl)
 PatchDataLayer (const PatchDataLayer &other)
 PatchDataLayer copy constructor.
 PatchDataLayer (PatchDataLayer &&other) noexcept
 PatchDataLayer move constructor.
PatchDataLayer & operator= (PatchDataLayer &&other) noexcept
 PatchDataLayer move assignment.
PatchDataLayer & operator= (const PatchDataLayer &other)=delete
template<class Functor>
void for_each_field_any (Functor &&func)
template<class Functor>
void for_each_field_any (Functor &&func) const
template<class Func>
 PatchDataLayer (const std::shared_ptr< PatchDataLayerLayout > &pdl, Func &&fct_init)
PatchDataLayer duplicate ()
std::unique_ptr< PatchDataLayer > duplicate_to_ptr ()
void extract_element (u32 pidx, PatchDataLayer &out_pdat)
 extract particle at index pidx and insert it in the provided vectors
void extract_elements (const sham::DeviceBuffer< u32 > &idxs, PatchDataLayer &out_pdat)
void keep_ids (sycl::buffer< u32 > &index_map, u32 len)
void insert_elements (const PatchDataLayer &pdat)
template<class T>
void insert_elements_in_range (PatchDataLayer &pdat, T bmin, T bmax)
 insert elements of pdat only if they are within the range
void resize (u32 new_obj_cnt)
void reserve (u32 new_obj_cnt)
void expand (u32 obj_cnt)
void index_remap (sycl::buffer< u32 > &index_map, u32 len)
 this function remaps the patchdatafield like so val[id] = val[index_map[id]] This function can be used to apply the result of a sort to the field
void index_remap_resize (sycl::buffer< u32 > &index_map, u32 len)
 this function remaps the patchdatafield like so val[id] = val[index_map[id]] This function can be used to apply the result of a sort to the field
void index_remap_resize (sham::DeviceBuffer< u32 > &index_map, u32 len)
 Same as index_remap_resize with a shamrock device buffer instead.
void keep_ids (sham::DeviceBuffer< u32 > &index_map, u32 len)
 Same as keep_ids with a shamrock device buffer instead.
void remove_ids (const sham::DeviceBuffer< u32 > &indexes, u32 len)
 remove some particles ids
template<class Tvecbox>
void split_patchdata (std::array< std::reference_wrapper< PatchDataLayer >, 8 > pdats, std::array< Tvecbox, 8 > min_box, std::array< Tvecbox, 8 > max_box)
void append_subset_to (const std::vector< u32 > &idxs, PatchDataLayer &pdat)
void append_subset_to (sycl::buffer< u32 > &idxs_buf, u32 sz, PatchDataLayer &pdat)
void append_subset_to (const sham::DeviceBuffer< u32 > &idxs_buf, u32 sz, PatchDataLayer &pdat) const
u32 get_obj_cnt () const
 get the number of objects (particles) stored in this layer
u64 memsize ()
 get the memory size in bytes used by all fields
bool is_empty ()
void synchronize_buf ()
 synchronize the host/device buffers of all fields
void overwrite (PatchDataLayer &pdat, u32 obj_cnt)
template<class T>
bool check_field_type (u32 idx)
template<class T>
PatchDataField< T > & get_field (u32 idx)
template<class T>
const PatchDataField< T > & get_field (u32 idx) const
template<class T>
PatchDataField< T > & get_field (const std::string &field_name)
template<class T>
const PatchDataField< T > & get_field (const std::string &field_name) const
template<class T>
sham::DeviceBuffer< T > & get_field_buf_ref (u32 idx)
template<class T, u32 nvar>
PatchDataFieldSpan< T, nvar > get_field_span (u32 idx)
 returns a PatchDataFieldSpan of the field at index idx, with the given nvar value
template<class T>
PatchDataFieldSpan< T, shamrock::dynamic_nvar > get_field_span_nvar_dynamic (u32 idx)
 returns a PatchDataFieldSpan of the field at index idx, with a dynamic number of variables
template<class T>
PatchDataFieldSpan< T, shamrock::dynamic_nvar, shamrock::access_t_pointer > get_field_pointer_span (u32 idx)
void check_field_obj_cnt_match ()
 check that all contained field have the same obj cnt
template<class T, class Functor>
void for_each_field (Functor &&func)
void serialize_buf (shamalgs::SerializeHelper &serializer)
shamalgs::SerializeSize serialize_buf_byte_size ()
void fields_raz ()
bool has_nan ()
 check whether any field contains a NaN value
bool has_inf ()
 check whether any field contains an infinite value
bool has_nan_or_inf ()
 check whether any field contains a NaN or infinite value
template<class T>
void override_patch_field (std::string field_name, std::vector< T > &vec)
template<class T>
std::vector< T > fetch_data (std::string key)
 Fetch data of a patchdata field into a std::vector.
template<class T>
void split_patchdata (std::array< std::reference_wrapper< PatchDataLayer >, 8 > pdats, std::array< T, 8 > min_box, std::array< T, 8 > max_box)

Static Public Member Functions

static PatchDataLayer mock_patchdata (u64 seed, u32 obj_cnt, const std::shared_ptr< PatchDataLayerLayout > &pdl)
static PatchDataLayer deserialize_buf (shamalgs::SerializeHelper &serializer, const std::shared_ptr< PatchDataLayerLayout > &pdl)

Friends

bool operator== (PatchDataLayer &p1, PatchDataLayer &p2)
 Compare two layers field by field (defined in PatchDataLayer.cpp).

Detailed Description

PatchDataLayer container class, the layout is described in patchdata_layout.

Definition at line 35 of file PatchDataLayer.hpp.

Member Typedef Documentation

◆ field_variant_t

using shamrock::patch::PatchDataLayer::field_variant_t = var_t

Definition at line 71 of file PatchDataLayer.hpp.

Constructor & Destructor Documentation

◆ PatchDataLayer() [1/4]

shamrock::patch::PatchDataLayer::PatchDataLayer ( const std::shared_ptr< PatchDataLayerLayout > & pdl)
inline

Definition at line 78 of file PatchDataLayer.hpp.

◆ PatchDataLayer() [2/4]

shamrock::patch::PatchDataLayer::PatchDataLayer ( const PatchDataLayer & other)

PatchDataLayer copy constructor.

Defined out of line: visiting every FieldVariant alternative instantiates the copy of all PatchDataField types, which is costly to compile in every includer.

Parameters
other

Definition at line 50 of file PatchDataLayer.cpp.

◆ PatchDataLayer() [3/4]

shamrock::patch::PatchDataLayer::PatchDataLayer ( PatchDataLayer && other)
inlinenoexcept

PatchDataLayer move constructor.

Parameters
other

Definition at line 97 of file PatchDataLayer.hpp.

◆ PatchDataLayer() [4/4]

template<class Func>
shamrock::patch::PatchDataLayer::PatchDataLayer ( const std::shared_ptr< PatchDataLayerLayout > & pdl,
Func && fct_init )
inline

Definition at line 135 of file PatchDataLayer.hpp.

Member Function Documentation

◆ append_subset_to() [1/3]

void shamrock::patch::PatchDataLayer::append_subset_to ( const sham::DeviceBuffer< u32 > & idxs_buf,
u32 sz,
PatchDataLayer & pdat ) const

Definition at line 282 of file PatchDataLayer.cpp.

◆ append_subset_to() [2/3]

void shamrock::patch::PatchDataLayer::append_subset_to ( const std::vector< u32 > & idxs,
PatchDataLayer & pdat )

Definition at line 260 of file PatchDataLayer.cpp.

◆ append_subset_to() [3/3]

void shamrock::patch::PatchDataLayer::append_subset_to ( sycl::buffer< u32 > & idxs_buf,
u32 sz,
PatchDataLayer & pdat )

Definition at line 237 of file PatchDataLayer.cpp.

◆ check_field_obj_cnt_match()

void shamrock::patch::PatchDataLayer::check_field_obj_cnt_match ( )

check that all contained field have the same obj cnt

Definition at line 381 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ check_field_type()

template<class T>
bool shamrock::patch::PatchDataLayer::check_field_type ( u32 idx)
inline

Definition at line 255 of file PatchDataLayer.hpp.

◆ deserialize_buf()

PatchDataLayer shamrock::patch::PatchDataLayer::deserialize_buf ( shamalgs::SerializeHelper & serializer,
const std::shared_ptr< PatchDataLayerLayout > & pdl )
static

Definition at line 323 of file PatchDataLayer.cpp.

◆ duplicate()

PatchDataLayer shamrock::patch::PatchDataLayer::duplicate ( )
inline

Definition at line 143 of file PatchDataLayer.hpp.

◆ duplicate_to_ptr()

std::unique_ptr< PatchDataLayer > shamrock::patch::PatchDataLayer::duplicate_to_ptr ( )
inline

Definition at line 148 of file PatchDataLayer.hpp.

◆ expand()

void shamrock::patch::PatchDataLayer::expand ( u32 obj_cnt)

Definition at line 181 of file PatchDataLayer.cpp.

◆ extract_element()

void shamrock::patch::PatchDataLayer::extract_element ( u32 pidx,
PatchDataLayer & out_pdat )

extract particle at index pidx and insert it in the provided vectors

Parameters
pidx
out_pdat

Definition at line 73 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ extract_elements()

void shamrock::patch::PatchDataLayer::extract_elements ( const sham::DeviceBuffer< u32 > & idxs,
PatchDataLayer & out_pdat )

Definition at line 95 of file PatchDataLayer.cpp.

◆ fetch_data()

template<class T>
std::vector< T > shamrock::patch::PatchDataLayer::fetch_data ( std::string key)
inline

Fetch data of a patchdata field into a std::vector.

Todo
Improve for nvar != 1
Template Parameters
T
Parameters
key
pdat
Returns
std::vector<T>

Definition at line 450 of file PatchDataLayer.hpp.

◆ fields_raz()

void shamrock::patch::PatchDataLayer::fields_raz ( )

Definition at line 340 of file PatchDataLayer.cpp.

◆ for_each_field()

template<class T, class Functor>
void shamrock::patch::PatchDataLayer::for_each_field ( Functor && func)
inline

Definition at line 379 of file PatchDataLayer.hpp.

◆ for_each_field_any() [1/2]

template<class Functor>
void shamrock::patch::PatchDataLayer::for_each_field_any ( Functor && func)
inline

Definition at line 117 of file PatchDataLayer.hpp.

◆ for_each_field_any() [2/2]

template<class Functor>
void shamrock::patch::PatchDataLayer::for_each_field_any ( Functor && func) const
inline

Definition at line 126 of file PatchDataLayer.hpp.

◆ get_field() [1/4]

template<class T>
PatchDataField< T > & shamrock::patch::PatchDataLayer::get_field ( const std::string & field_name)
inline

Definition at line 308 of file PatchDataLayer.hpp.

◆ get_field() [2/4]

template<class T>
const PatchDataField< T > & shamrock::patch::PatchDataLayer::get_field ( const std::string & field_name) const
inline

Definition at line 313 of file PatchDataLayer.hpp.

◆ get_field() [3/4]

template<class T>
PatchDataField< T > & shamrock::patch::PatchDataLayer::get_field ( u32 idx)
inline

Definition at line 268 of file PatchDataLayer.hpp.

◆ get_field() [4/4]

template<class T>
const PatchDataField< T > & shamrock::patch::PatchDataLayer::get_field ( u32 idx) const
inline

Definition at line 288 of file PatchDataLayer.hpp.

◆ get_field_buf_ref()

template<class T>
sham::DeviceBuffer< T > & shamrock::patch::PatchDataLayer::get_field_buf_ref ( u32 idx)
inline

Definition at line 318 of file PatchDataLayer.hpp.

◆ get_field_pointer_span()

template<class T>
PatchDataFieldSpan< T, shamrock::dynamic_nvar, shamrock::access_t_pointer > shamrock::patch::PatchDataLayer::get_field_pointer_span ( u32 idx)
inline

Definition at line 362 of file PatchDataLayer.hpp.

◆ get_field_span()

template<class T, u32 nvar>
PatchDataFieldSpan< T, nvar > shamrock::patch::PatchDataLayer::get_field_span ( u32 idx)
inline

returns a PatchDataFieldSpan of the field at index idx, with the given nvar value

Parameters
idxthe index of the field
Returns
a PatchDataFieldSpan

Definition at line 344 of file PatchDataLayer.hpp.

◆ get_field_span_nvar_dynamic()

template<class T>
PatchDataFieldSpan< T, shamrock::dynamic_nvar > shamrock::patch::PatchDataLayer::get_field_span_nvar_dynamic ( u32 idx)
inline

returns a PatchDataFieldSpan of the field at index idx, with a dynamic number of variables

Parameters
idxthe index of the field
Returns
a PatchDataFieldSpan

Definition at line 356 of file PatchDataLayer.hpp.

◆ get_layout_ptr()

std::shared_ptr< PatchDataLayerLayout > shamrock::patch::PatchDataLayer::get_layout_ptr ( ) const
inline

Definition at line 76 of file PatchDataLayer.hpp.

◆ get_obj_cnt()

u32 shamrock::patch::PatchDataLayer::get_obj_cnt ( ) const

get the number of objects (particles) stored in this layer

Returns
u32 the object count

Definition at line 346 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ has_inf()

bool shamrock::patch::PatchDataLayer::has_inf ( )

check whether any field contains an infinite value

Returns
bool true if an infinite value was found

Definition at line 407 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ has_nan()

bool shamrock::patch::PatchDataLayer::has_nan ( )

check whether any field contains a NaN value

Returns
bool true if a NaN was found

Definition at line 392 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ has_nan_or_inf()

bool shamrock::patch::PatchDataLayer::has_nan_or_inf ( )

check whether any field contains a NaN or infinite value

Returns
bool true if a NaN or infinite value was found

Definition at line 422 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ index_remap()

void shamrock::patch::PatchDataLayer::index_remap ( sycl::buffer< u32 > & index_map,
u32 len )

this function remaps the patchdatafield like so val[id] = val[index_map[id]] This function can be used to apply the result of a sort to the field

Parameters
index_map
lenthe length of the map (must match with the current count)

Definition at line 190 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ index_remap_resize() [1/2]

void shamrock::patch::PatchDataLayer::index_remap_resize ( sham::DeviceBuffer< u32 > & index_map,
u32 len )

Same as index_remap_resize with a shamrock device buffer instead.

Definition at line 213 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ index_remap_resize() [2/2]

void shamrock::patch::PatchDataLayer::index_remap_resize ( sycl::buffer< u32 > & index_map,
u32 len )

this function remaps the patchdatafield like so val[id] = val[index_map[id]] This function can be used to apply the result of a sort to the field

Parameters
index_map
lenthe length of the map

Definition at line 202 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ insert_elements()

void shamrock::patch::PatchDataLayer::insert_elements ( const PatchDataLayer & pdat)

Definition at line 118 of file PatchDataLayer.cpp.

◆ insert_elements_in_range()

template<class T>
void shamrock::patch::PatchDataLayer::insert_elements_in_range ( PatchDataLayer & pdat,
T bmin,
T bmax )
inline

insert elements of pdat only if they are within the range

Template Parameters
T
Parameters
pdat
bmin
bmax

Definition at line 484 of file PatchDataLayer.hpp.

Here is the call graph for this function:

◆ is_empty()

bool shamrock::patch::PatchDataLayer::is_empty ( )
inline

Definition at line 247 of file PatchDataLayer.hpp.

◆ keep_ids() [1/2]

void shamrock::patch::PatchDataLayer::keep_ids ( sham::DeviceBuffer< u32 > & index_map,
u32 len )

Same as keep_ids with a shamrock device buffer instead.

Definition at line 225 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ keep_ids() [2/2]

void shamrock::patch::PatchDataLayer::keep_ids ( sycl::buffer< u32 > & index_map,
u32 len )

Definition at line 221 of file PatchDataLayer.cpp.

◆ memsize()

u64 shamrock::patch::PatchDataLayer::memsize ( )

get the memory size in bytes used by all fields

Returns
u64 the memory size in bytes

Definition at line 360 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ mock_patchdata()

PatchDataLayer shamrock::patch::PatchDataLayer::mock_patchdata ( u64 seed,
u32 obj_cnt,
const std::shared_ptr< PatchDataLayerLayout > & pdl )
static

Definition at line 33 of file PatchDataLayer.cpp.

◆ operator=()

PatchDataLayer & shamrock::patch::PatchDataLayer::operator= ( PatchDataLayer && other)
inlinenoexcept

PatchDataLayer move assignment.

Parameters
other

Definition at line 105 of file PatchDataLayer.hpp.

◆ override_patch_field()

template<class T>
void shamrock::patch::PatchDataLayer::override_patch_field ( std::string field_name,
std::vector< T > & vec )
inline
Todo
should add a check in patch data to check that size in ovveride match with the one in the input vec
Template Parameters
T
Parameters
field_name
vec

Definition at line 432 of file PatchDataLayer.hpp.

◆ overwrite()

void shamrock::patch::PatchDataLayer::overwrite ( PatchDataLayer & pdat,
u32 obj_cnt )

Definition at line 141 of file PatchDataLayer.cpp.

◆ pdl() [1/2]

PatchDataLayerLayout & shamrock::patch::PatchDataLayer::pdl ( )
inline

Definition at line 73 of file PatchDataLayer.hpp.

◆ pdl() [2/2]

const PatchDataLayerLayout & shamrock::patch::PatchDataLayer::pdl ( ) const
inline

Definition at line 74 of file PatchDataLayer.hpp.

◆ remove_ids()

void shamrock::patch::PatchDataLayer::remove_ids ( const sham::DeviceBuffer< u32 > & indexes,
u32 len )

remove some particles ids

Definition at line 229 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ reserve()

void shamrock::patch::PatchDataLayer::reserve ( u32 new_obj_cnt)

Definition at line 172 of file PatchDataLayer.cpp.

◆ resize()

void shamrock::patch::PatchDataLayer::resize ( u32 new_obj_cnt)

Definition at line 163 of file PatchDataLayer.cpp.

◆ serialize_buf()

void shamrock::patch::PatchDataLayer::serialize_buf ( shamalgs::SerializeHelper & serializer)

Definition at line 308 of file PatchDataLayer.cpp.

◆ serialize_buf_byte_size()

shamalgs::SerializeSize shamrock::patch::PatchDataLayer::serialize_buf_byte_size ( )

Definition at line 315 of file PatchDataLayer.cpp.

◆ split_patchdata()

template<class T>
void shamrock::patch::PatchDataLayer::split_patchdata ( std::array< std::reference_wrapper< PatchDataLayer >, 8 > pdats,
std::array< T, 8 > min_box,
std::array< T, 8 > max_box )

Definition at line 438 of file PatchDataLayer.cpp.

◆ synchronize_buf()

void shamrock::patch::PatchDataLayer::synchronize_buf ( )

synchronize the host/device buffers of all fields

Definition at line 373 of file PatchDataLayer.cpp.

Here is the call graph for this function:

◆ operator==

bool operator== ( PatchDataLayer & p1,
PatchDataLayer & p2 )
friend

Compare two layers field by field (defined in PatchDataLayer.cpp).

Definition at line 552 of file PatchDataLayer.cpp.


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