Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
CompressedLeafBVH.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
17
24
25namespace shamtree {
26
40 template<class Tmorton, class Tvec, u32 dim>
42
43} // namespace shamtree
44
45template<class Tmorton, class Tvec, u32 dim>
47
48 void internal_rebuild_from_positions_no_aabb(
49 sham::DeviceBuffer<Tvec> &positions,
50 u32 obj_cnt,
51 const shammath::AABB<Tvec> &bounding_box,
52 u32 compression_level);
53
54 public:
56 inline u32 get_total_cell_count() { return structure.get_total_cell_count(); }
57
59 inline u32 get_internal_cell_count() { return structure.get_internal_cell_count(); }
60
62 inline bool is_root_leaf() const { return structure.is_root_leaf(); }
63
65 inline u32 get_leaf_cell_count() { return structure.get_leaf_count(); }
66
69
72
75
92
104
106 static CompressedLeafBVH make_empty(sham::DeviceScheduler_ptr dev_sched);
107
109 inline bool is_empty() const { return reduced_morton_set.is_empty(); }
110
119 sham::DeviceBuffer<Tvec> &positions,
120 const shammath::AABB<Tvec> &bounding_box,
121 u32 compression_level);
122
132 sham::DeviceBuffer<Tvec> &positions,
133 u32 obj_cnt,
134 const shammath::AABB<Tvec> &bounding_box,
135 u32 compression_level);
136
137 void rebuild_from_position_range(
140 u32 obj_cnt,
141 shammath::AABB<Tvec> &bounding_box,
142 u32 compression_level);
143
144 void rebuild_from_position_range(
147 shammath::AABB<Tvec> &bounding_box,
148 u32 compression_level);
149
150 inline shamtree::CLBVHTraverser<Tmorton, Tvec, dim> get_traverser() const {
151 return {structure.get_structure_traverser(), aabbs.buf_aabb_min, aabbs.buf_aabb_max};
152 }
153
154 inline shamtree::CLBVHTraverserHost<Tmorton, Tvec, dim> get_traverser_host() const {
155 return {
156 structure.get_structure_traverser_host(),
157 aabbs.buf_aabb_min.copy_to_stdvec(),
158 aabbs.buf_aabb_max.copy_to_stdvec()};
159 }
160
173 return {reduced_morton_set.get_leaf_cell_iterator(), get_traverser()};
174 }
175
176 inline shamtree::CLBVHObjectIteratorHost<Tmorton, Tvec, dim> get_object_iterator_host() const {
177 return {reduced_morton_set.get_leaf_cell_iterator_host(), get_traverser_host()};
178 }
179
180 inline CellIterator get_cell_iterator() const {
181 return {reduced_morton_set.get_cell_iterator(
182 structure.buf_endrange, structure.get_internal_cell_count())};
183 }
184
185 inline CellIteratorHost get_cell_iterator_host() const {
186 return {reduced_morton_set.get_cell_iterator_host(
187 structure.buf_endrange, structure.get_internal_cell_count())};
188 }
189};
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory).
A Compressed Leaf Bounding Volume Hierarchy (CLBVH) for neighborhood queries.
void rebuild_from_positions(sham::DeviceBuffer< Tvec > &positions, u32 obj_cnt, const shammath::AABB< Tvec > &bounding_box, u32 compression_level)
rebuild the BVH from the given positions
bool is_empty() const
is the BVH empty ?
u32 get_exact_tree_depth() const
Compute the exact depth of the tree.
shamtree::CLBVHObjectIterator< Tmorton, Tvec, dim > get_object_iterator() const
Retrieves an iterator for traversing objects in the BVH.
CompressedLeafBVH(MortonReducedSet< Tmorton, Tvec, dim > &&reduced_morton_set, KarrasRadixTree &&structure, KarrasRadixTreeAABB< Tvec > &&aabbs)
Construct a new CompressedLeafBVH from a MortonReducedSet, a KarrasRadixTree, and a KarrasRadixTreeAA...
MortonReducedSet< Tmorton, Tvec, dim > reduced_morton_set
u32 get_leaf_cell_count()
Get leaf cell count.
void rebuild_from_positions(sham::DeviceBuffer< Tvec > &positions, const shammath::AABB< Tvec > &bounding_box, u32 compression_level)
rebuild the BVH from the given positions
static CompressedLeafBVH make_empty(sham::DeviceScheduler_ptr dev_sched)
make an empty BVH
u32 get_internal_cell_count()
Get internal cell count.
bool is_root_leaf() const
is the root a leaf ?
u32 get_total_cell_count()
Get internal cell count.
A data structure representing a Karras Radix Tree.
Class representing a set of Morton codes with associated bounding box and position data that was redu...
Morton curve implementation.
Axis-Aligned bounding box.
Definition AABB.hpp:99
host version of the object iterator
This class is designed to traverse a BVH tree represented as a Compressed Leaf BVH (CLBVH) and a Karr...
host version of the traverser
This class is designed to traverse a BVH tree represented as a Compressed Leaf BVH (CLBVH) and a Karr...