Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
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

PatchDataLayerLayoutpdl ()
 
const PatchDataLayerLayoutpdl () const
 
std::shared_ptr< PatchDataLayerLayoutget_layout_ptr () const
 
 PatchDataLayer (const std::shared_ptr< PatchDataLayerLayout > &pdl)
 
 PatchDataLayer (const PatchDataLayer &other)
 
 PatchDataLayer (PatchDataLayer &&other) noexcept
 PatchDataLayer move constructor.
 
PatchDataLayeroperator= (PatchDataLayer &&other) noexcept
 PatchDataLayer move assignment.
 
PatchDataLayeroperator= (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< PatchDataLayerduplicate_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
 
u64 memsize ()
 
bool is_empty ()
 
void synchronize_buf ()
 
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_nvarget_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 ()
 
bool has_inf ()
 
bool has_nan_or_inf ()
 
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)
 

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

Definition at line 45 of file PatchDataLayer.hpp.

Constructor & Destructor Documentation

◆ PatchDataLayer() [1/4]

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

Definition at line 52 of file PatchDataLayer.hpp.

◆ PatchDataLayer() [2/4]

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

Definition at line 56 of file PatchDataLayer.hpp.

◆ PatchDataLayer() [3/4]

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

PatchDataLayer move constructor.

Parameters
other

Definition at line 75 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 113 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 267 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 245 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 222 of file PatchDataLayer.cpp.

◆ check_field_obj_cnt_match()

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

check that all contained field have the same obj cnt

Definition at line 366 of file PatchDataLayer.hpp.

+ 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 251 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 309 of file PatchDataLayer.cpp.

◆ duplicate()

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

Definition at line 121 of file PatchDataLayer.hpp.

◆ duplicate_to_ptr()

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

Definition at line 126 of file PatchDataLayer.hpp.

◆ expand()

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

Definition at line 166 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 58 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 80 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 504 of file PatchDataLayer.hpp.

◆ fields_raz()

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

Definition at line 326 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 385 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 95 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 104 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 304 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 309 of file PatchDataLayer.hpp.

◆ get_field() [3/4]

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

Definition at line 264 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 284 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 314 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 358 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 340 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 352 of file PatchDataLayer.hpp.

◆ get_layout_ptr()

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

Definition at line 50 of file PatchDataLayer.hpp.

◆ get_obj_cnt()

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

Definition at line 211 of file PatchDataLayer.hpp.

◆ has_inf()

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

Definition at line 448 of file PatchDataLayer.hpp.

◆ has_nan()

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

Definition at line 434 of file PatchDataLayer.hpp.

◆ has_nan_or_inf()

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

Definition at line 462 of file PatchDataLayer.hpp.

◆ 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 175 of file PatchDataLayer.cpp.

◆ 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 198 of file PatchDataLayer.cpp.

◆ 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 187 of file PatchDataLayer.cpp.

◆ insert_elements()

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

Definition at line 103 of file PatchDataLayer.cpp.

◆ insert_elements_in_range()

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

insert elements of pdat only if they are within the range

Template Parameters
T
Parameters
pdat
bmin
bmax

Definition at line 533 of file PatchDataLayer.hpp.

+ Here is the call graph for this function:

◆ is_empty()

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

Definition at line 238 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 210 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 206 of file PatchDataLayer.cpp.

◆ memsize()

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

Definition at line 225 of file PatchDataLayer.hpp.

◆ mock_patchdata()

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

Definition at line 31 of file PatchDataLayer.cpp.

◆ operator=()

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

PatchDataLayer move assignment.

Parameters
other

Definition at line 83 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 486 of file PatchDataLayer.hpp.

◆ overwrite()

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

Definition at line 126 of file PatchDataLayer.cpp.

◆ pdl() [1/2]

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

Definition at line 47 of file PatchDataLayer.hpp.

◆ pdl() [2/2]

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

Definition at line 48 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 214 of file PatchDataLayer.cpp.

◆ reserve()

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

Definition at line 157 of file PatchDataLayer.cpp.

◆ resize()

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

Definition at line 148 of file PatchDataLayer.cpp.

◆ serialize_buf()

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

Definition at line 294 of file PatchDataLayer.cpp.

◆ serialize_buf_byte_size()

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

Definition at line 301 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 333 of file PatchDataLayer.cpp.

◆ synchronize_buf()

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

Definition at line 240 of file PatchDataLayer.hpp.

Friends And Related Symbol Documentation

◆ operator==

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

Definition at line 395 of file PatchDataLayer.hpp.


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