29namespace shammodels::ramses::modules {
32 template<
class Tvec,
class Tgr
idVec,
class Tfield>
36 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
46 = scheduler().get_sim_box().template get_patch_transform<TgridVec>();
55 auto &buf_block_min = block_min.get_buf();
56 auto &buf_block_max = block_max.get_buf();
58 using Block =
typename Config::AMRBlock;
59 u32 block_size = Block::block_size;
61 u64 num_obj = block_min.get_obj_cnt();
66 Tscal dxfact = solver_config.grid_coord_to_pos_fact;
75 const TgridVec *__restrict ptr_block_min,
76 const TgridVec *__restrict ptr_block_max,
79 Tvec block_min = ptr_block_min[id_a].template convert<Tscal>() * dxfact;
80 Tvec block_max = ptr_block_max[id_a].template convert<Tscal>() * dxfact;
82 Tvec delta_cell = (block_max - block_min) / Block::side_size;
83 for (
u32 ix = 0; ix < Block::side_size; ix++) {
84 for (
u32 iy = 0; iy < Block::side_size; iy++) {
85 for (
u32 iz = 0; iz < Block::side_size; iz++) {
86 u32 i = Block::get_index({ix, iy, iz});
87 Tvec delta_val = delta_cell * Tvec{ix, iy, iz};
88 cell_min[id_a * Block::block_size + i] = block_min + delta_val;
89 cell_max[id_a * Block::block_size + i]
90 = block_min + (delta_cell) + delta_val;
101 auto &buf_field_to_render = field_getter(cur_p, pdat);
104 u32 reduction_level = 0;
106 RTree tree = RTree::make_empty(dev_sched);
107 tree.rebuild_from_position_range(pos_min_cell, pos_max_cell, tree_box, reduction_level);
109 auto leaf_iterator = tree.get_object_iterator();
114 positions, pos_min_cell, pos_max_cell, leaf_iterator, buf_field_to_render},
118 const Tvec *positions,
122 const Tfield *buf_field_to_render,
124 Tvec pos_a = positions[id_a];
126 Tfield accumulator = {};
128 cell_finder.rtree_for(
136 Tfield val_cell = buf_field_to_render[id_b];
137 accumulator += val_cell;
141 ret[id_a] += accumulator;
145 shamalgs::collective::reduce_buffer_in_place_sum(ret, MPI_COMM_WORLD);
151 template<
class Tvec,
class Tgr
idVec,
class Tfield>
154 auto field_source_getter
157 return pdat.get_field<Tfield>(pdat.pdl().
get_field_idx<Tfield>(field_name)).get_buf();
159 return compute_slice(field_source_getter, positions);
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
size_t get_size() const
Gets the number of elements in the buffer.
u32 get_field_idx(const std::string &field_name) const
Get the field id if matching name & type.
PatchDataLayer container class, the layout is described in patchdata_layout.
A Compressed Leaf Bounding Volume Hierarchy (CLBVH) for neighborhood queries.
void kernel_call(sham::DeviceQueue &q, RefIn in, RefOut in_out, u32 n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
Submit a kernel to a SYCL queue.
T min(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Find the minimum element in a device buffer within a specified range.
T max(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Find the maximum element in a device buffer within a specified range.
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
namespace for math utility
A class that references multiple buffers or similar objects.
Axis-Aligned bounding box.
bool contains_asymmetric(T point) const noexcept
Check if point is in AABB using half-open interval [lower, upper)
Patch object that contain generic patch information.