Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
MortonReducedSet.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
21
22namespace shamtree {
23
32 template<class Tmorton, class Tvec, u32 dim = shambase::VectorProperties<Tvec>::dimension>
34 public:
37
43
47
51
61
62 inline bool is_empty() const { return reduce_code_count == 0; }
63
64 inline LeafCellIterator get_leaf_cell_iterator() const {
65 return LeafCellIterator{morton_codes_set.map_morton_id_to_obj_id, buf_reduc_index_map};
66 }
67
68 inline LeafCellIteratorHost get_leaf_cell_iterator_host() const {
69 return LeafCellIteratorHost{
70 morton_codes_set.map_morton_id_to_obj_id.copy_to_stdvec(),
72 }
73
74 inline CellIterator get_cell_iterator(
75 const sham::DeviceBuffer<u32> &buf_endrange, u32 offset_leaf) const {
76 return CellIterator{
77 morton_codes_set.map_morton_id_to_obj_id,
79 buf_endrange,
80 offset_leaf};
81 }
82
83 inline CellIteratorHost get_cell_iterator_host(
84 const sham::DeviceBuffer<u32> &buf_endrange, u32 offset_leaf) const {
85 return CellIteratorHost{
86 morton_codes_set.map_morton_id_to_obj_id.copy_to_stdvec(),
88 buf_endrange.copy_to_stdvec(),
89 offset_leaf};
90 }
91
92 inline static MortonReducedSet make_empty(sham::DeviceScheduler_ptr dev_sched) {
93 return MortonReducedSet{
94 MortonCodeSortedSet<Tmorton, Tvec>::make_empty(dev_sched),
95 0,
96 sham::DeviceBuffer<u32>(0, dev_sched),
97 sham::DeviceBuffer<Tmorton>(0, dev_sched)};
98 }
99 };
100
110 template<class Tmorton, class Tvec, u32 dim>
111 MortonReducedSet<Tmorton, Tvec, dim> reduce_morton_set(
112 const sham::DeviceScheduler_ptr &dev_sched,
113 MortonCodeSortedSet<Tmorton, Tvec, dim> &&morton_codes_set,
114 u32 reduction_level);
115
127 template<class Tmorton, class Tvec, u32 dim>
128 MortonReducedSet<Tmorton, Tvec, dim> reduce_morton_set(
129 const sham::DeviceScheduler_ptr &dev_sched,
130 MortonCodeSortedSet<Tmorton, Tvec, dim> &&morton_codes_set,
131 u32 reduction_level,
132 sham::DeviceBuffer<u32> &&cache_buf_reduc_index_map,
133 sham::DeviceBuffer<Tmorton> &&cache_reduced_morton_codes);
134
135} // namespace shamtree
MortonReducedSet< Tmorton, Tvec, dim > reduce_morton_set(const sham::DeviceScheduler_ptr &dev_sched, MortonCodeSortedSet< Tmorton, Tvec, dim > &&morton_codes_set, u32 reduction_level)
Reduces the given Morton code set by grouping together Morton codes that are close to each other in t...
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
std::vector< T > copy_to_stdvec() const
Copy the content of the buffer to a std::vector.
Class representing a set of Morton codes with associated bounding box and position data.
Class representing a set of Morton codes with associated bounding box and position data that was redu...
MortonCodeSortedSet< Tmorton, Tvec > morton_codes_set
The source Morton codes set.
MortonReducedSet(MortonCodeSortedSet< Tmorton, Tvec > &&morton_codes_set, u32 reduce_code_count, sham::DeviceBuffer< u32 > &&buf_reduc_index_map, sham::DeviceBuffer< Tmorton > &&reduced_morton_codes)
Move constructor from each members.
u32 reduce_code_count
The count of Morton codes in the reduced set This was called tree_leaf_count.
sham::DeviceBuffer< Tmorton > reduced_morton_codes
sham::DeviceBuffer< u32 > buf_reduc_index_map
STL namespace.