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
24
25namespace shamtree {
26
40 template<class Tmorton, class Tvec, u32 dim>
41 class CompressedLeafBVH;
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
60
62 inline bool is_root_leaf() const { return structure.is_root_leaf(); }
63
66
69
72
75
92
94 static CompressedLeafBVH make_empty(sham::DeviceScheduler_ptr dev_sched);
95
97 inline bool is_empty() const { return reduced_morton_set.is_empty(); }
98
107 sham::DeviceBuffer<Tvec> &positions,
108 const shammath::AABB<Tvec> &bounding_box,
109 u32 compression_level);
110
120 sham::DeviceBuffer<Tvec> &positions,
121 u32 obj_cnt,
122 const shammath::AABB<Tvec> &bounding_box,
123 u32 compression_level);
124
125 void rebuild_from_position_range(
128 u32 obj_cnt,
129 shammath::AABB<Tvec> &bounding_box,
130 u32 compression_level);
131
132 void rebuild_from_position_range(
135 shammath::AABB<Tvec> &bounding_box,
136 u32 compression_level);
137
138 inline shamtree::CLBVHTraverser<Tmorton, Tvec, dim> get_traverser() const {
139 return {structure.get_structure_traverser(), aabbs.buf_aabb_min, aabbs.buf_aabb_max};
140 }
141
142 inline shamtree::CLBVHTraverserHost<Tmorton, Tvec, dim> get_traverser_host() const {
143 return {
144 structure.get_structure_traverser_host(),
145 aabbs.buf_aabb_min.copy_to_stdvec(),
146 aabbs.buf_aabb_max.copy_to_stdvec()};
147 }
148
161 return {reduced_morton_set.get_leaf_cell_iterator(), get_traverser()};
162 }
163
164 inline shamtree::CLBVHObjectIteratorHost<Tmorton, Tvec, dim> get_object_iterator_host() const {
165 return {reduced_morton_set.get_leaf_cell_iterator_host(), get_traverser_host()};
166 }
167
168 inline CellIterator get_cell_iterator() const {
169 return {reduced_morton_set.get_cell_iterator(
171 }
172
173 inline CellIteratorHost get_cell_iterator_host() const {
174 return {reduced_morton_set.get_cell_iterator_host(
176 }
177};
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.
bool is_empty() const
is the BVH empty ?
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...
KarrasRadixTreeAABB< Tvec > aabbs
The bounding box of the tree cells.
MortonReducedSet< Tmorton, Tvec, dim > reduced_morton_set
The reduced set of Morton codes.
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
KarrasRadixTree structure
The tree structure.
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.
u32 get_leaf_count() const
Get leaf count.
sham::DeviceBuffer< u32 > buf_endrange
endrange (size = internal_count)
bool is_root_leaf() const
is the root a leaf ?
u32 get_internal_cell_count() const
Get internal cell count.
Class representing a set of Morton codes with associated bounding box and position data that was redu...
Morton curve implementation.
STL namespace.
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...