Skip to content

Commit f49a2f7

Browse files
committed
remove python changes
1 parent b7f3709 commit f49a2f7

27 files changed

+118
-1109
lines changed

core/include/detray/core/detector.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ class detector {
223223
inline const auto &volume(const point3_type &p) const {
224224
volume_type v_desc{};
225225
// Allow to call the volume search data structure
226-
v_desc.set_accel_link(geo_obj_ids::e_volume, 0u);
226+
v_desc.template set_accel_link<geo_obj_ids::e_volume>(
227+
accel::id::e_volume_brute_force, 0u);
227228
tracking_volume world{v_desc, *this};
228229

229230
const dindex volume_index =
@@ -306,12 +307,13 @@ class detector {
306307
/// Volume lookup in the volume acceleration data structures
307308
struct volume_search {
308309
///@TODO: Move this to a volume search grid type
309-
template <typename accel_group_t, typename accel_index_t>
310+
template <concepts::accelerator_collection accel_coll_t,
311+
typename accel_index_t>
310312
DETRAY_HOST_DEVICE inline dindex operator()(
311-
const accel_group_t &group, const accel_index_t index,
313+
const accel_coll_t &coll, const accel_index_t index,
312314
const point3_type &p) const {
313315

314-
const auto volume_accelerator = group[index];
316+
const auto volume_accelerator = coll[index];
315317

316318
// The 3D cylindrical volume search grid is concentric
317319
const transform3_type identity{};

core/include/detray/geometry/detail/volume_kernels.hpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,17 @@ template <typename functor_t>
5050
struct surface_getter {
5151

5252
/// Call operator that forwards the functor to all contained surfaces
53-
template <typename accel_group_t, typename accel_index_t, typename... Args>
54-
DETRAY_HOST_DEVICE inline void operator()(const accel_group_t &group,
53+
template <concepts::accelerator_collection accel_coll_t,
54+
typename accel_index_t, typename... Args>
55+
DETRAY_HOST_DEVICE inline void operator()(const accel_coll_t &coll,
5556
const accel_index_t index,
5657
Args &&...args) const {
5758

58-
using accel_type = typename accel_group_t::value_type;
59+
using accel_type = typename accel_coll_t::value_type;
5960

6061
if constexpr (concepts::surface_accelerator<accel_type>) {
6162
// Run over the surfaces in a single acceleration data structure
62-
for (const auto &sf : group[index].all()) {
63+
for (const auto &sf : coll[index].all()) {
6364
functor_t{}(sf, std::forward<Args>(args)...);
6465
}
6566
}
@@ -68,16 +69,17 @@ struct surface_getter {
6869

6970
/// A functor to access the daughter volumes of a volume
7071
template <typename functor_t>
71-
struct daughter_volume_getter {
72+
struct volume_getter {
7273

7374
/// Call operator that forwards the functor call to all contained daughter
7475
/// volumes
75-
template <typename accel_group_t, typename accel_index_t, typename... Args>
76-
DETRAY_HOST_DEVICE inline void operator()(const accel_group_t &group,
77-
const accel_index_t index,
78-
Args &&...args) const {
76+
template <concepts::accelerator_collection accel_coll_t,
77+
typename accel_index_t, typename... Args>
78+
DETRAY_HOST_DEVICE inline void operator()(const accel_coll_t &,
79+
const accel_index_t,
80+
Args &&...) const {
7981

80-
using accel_type = typename accel_group_t::value_type;
82+
using accel_type = typename accel_coll_t::value_type;
8183

8284
if constexpr (concepts::volume_accelerator<accel_type>) {
8385
// Run over all the daughter volumes
@@ -92,17 +94,17 @@ struct neighborhood_getter {
9294

9395
/// Call operator that forwards the neighborhood search call in a volume
9496
/// to a surface finder data structure
95-
template <typename accel_group_t, typename accel_index_t,
96-
typename detector_t, typename track_t, typename config_t,
97-
typename... Args>
97+
template <concepts::accelerator_collection accel_coll_t,
98+
typename accel_index_t, typename detector_t, typename track_t,
99+
typename config_t, typename... Args>
98100
DETRAY_HOST_DEVICE inline void operator()(
99-
const accel_group_t &group, const accel_index_t index,
101+
const accel_coll_t &coll, const accel_index_t index,
100102
const detector_t &det, const typename detector_t::volume_type &volume,
101103
const track_t &track, const config_t &cfg,
102104
const typename detector_t::geometry_context &ctx,
103105
Args &&...args) const {
104106

105-
decltype(auto) accel = group[index];
107+
decltype(auto) accel = coll[index];
106108

107109
// Run over the surfaces in a single acceleration data structure
108110
for (const auto &sf : accel.search(det, volume, track, cfg, ctx)) {
@@ -113,10 +115,11 @@ struct neighborhood_getter {
113115

114116
/// Query the maximal number of candidates from the acceleration
115117
struct n_candidates_getter {
116-
template <typename accel_group_t, typename accel_index_t>
117-
DETRAY_HOST_DEVICE inline auto operator()(const accel_group_t &group,
118+
template <concepts::accelerator_collection accel_coll_t,
119+
typename accel_index_t>
120+
DETRAY_HOST_DEVICE inline auto operator()(const accel_coll_t &coll,
118121
const accel_index_t index) const {
119-
return group[index].n_max_candidates();
122+
return coll[index].n_max_candidates();
120123
}
121124
};
122125

core/include/detray/geometry/tracking_volume.hpp

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,6 @@ class tracking_volume {
6868
constexpr tracking_volume(const detector_t &det, const dindex vol_idx)
6969
: tracking_volume(det, det.volume(vol_idx)) {}
7070

71-
/// @returns true if the object ID corresponds to a surface
72-
static consteval bool is_surface_id(const object_id id) {
73-
return (id == object_id::e_portal || id == object_id::e_sensitive ||
74-
id == object_id::e_passive);
75-
}
76-
77-
/// @returns true if the object ID corresponds to a [daughter] volume
78-
static consteval bool is_volume_id(const object_id id) {
79-
return (id == object_id::e_volume);
80-
}
81-
8271
/// @returns access to the underlying detector
8372
DETRAY_HOST_DEVICE
8473
auto detector() const -> const detector_t & { return m_detector; }
@@ -160,21 +149,16 @@ class tracking_volume {
160149

161150
if (const auto &link{m_desc.template accel_link<I>()};
162151
!link.is_invalid()) {
163-
if constexpr (tracking_volume::is_surface_id(I)) {
164-
// Run over the surfaces in a single acceleration data structure
165-
// and apply the functor to the resulting neighborhood
166-
m_detector.accelerator_store().template visit<functor_t>(
167-
link, std::forward<Args>(args)...);
168-
} else {
169-
// TODO: Call volume accelerator to find daughter volumes
170-
// [...]
171-
}
152+
// Run over the surfaces in a single acceleration data structure
153+
// and apply the functor to the resulting neighborhood
154+
m_detector.accelerator_store().template visit<functor_t>(
155+
link, std::forward<Args>(args)...);
172156
}
173157
}
174158

175159
/// Apply a functor to all acceleration structures of this volume.
176160
///
177-
/// @tparam I type of object to retrieve (passive, portal, sensitive etc)
161+
/// @tparam I type of object to retrieve (surface types, daughters etc)
178162
/// @tparam functor_t the prescription to be applied to the acc structure
179163
/// @tparam Args types of additional arguments to the functor
180164
template <typename functor_t,
@@ -194,6 +178,8 @@ class tracking_volume {
194178
/// Apply a functor to all surfaces of a given surface id (portal, passive,
195179
/// sensitive) in the volume
196180
///
181+
/// Translates the detray surface type id to the volume geometry object id
182+
///
197183
/// @tparam functor_t the prescription to be applied to the surfaces
198184
/// @tparam Args types of additional arguments to the functor
199185
template <surface_id I, typename functor_t, typename... Args>
@@ -230,8 +216,25 @@ class tracking_volume {
230216
}
231217
}
232218

233-
/// Apply a functor to a neighborhood of surfaces around a track position
234-
/// in the volume.
219+
/// Apply a functor to all daughter volumes
220+
///
221+
/// @tparam functor_t the prescription to be applied to the daughter volumes
222+
/// @tparam Args types of additional arguments to the functor
223+
template <surface_id I, typename functor_t, typename... Args>
224+
DETRAY_HOST_DEVICE constexpr void visit_daughter_volumes(
225+
Args &&...args) const {
226+
using volume_getter_t = detail::volume_getter<functor_t>;
227+
228+
visit_accelerator<object_id::e_volume, volume_getter_t>(
229+
std::forward<Args>(args)...);
230+
}
231+
232+
/// Apply a functor to a neighborhood of geometric objects around a
233+
/// track position in the volume.
234+
///
235+
/// @note: The acceleration structures in the volume might return different
236+
/// geometric objects (e.g. surfaces vs. volumes). The passed functor must
237+
/// provide corresponding overloads of the call operator.
235238
///
236239
/// @tparam functor_t the prescription to be applied to the surfaces (
237240
/// customization point for the navigation)

core/include/detray/geometry/volume_descriptor.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class volume_descriptor {
5252
/// surface store.
5353
///
5454
/// E.g. a 'portal' can be found under @c ID::e_portal in this link,
55-
/// and will then receive link to the @c brute_force_finder that holds the
55+
/// and will then receive link to the @c brute_force_searcher that holds the
5656
/// portals (the accelerator structure's id and index).
5757
using accel_link_type = dmulti_index<acc_link_t, ID::e_size>;
5858

@@ -68,6 +68,17 @@ class volume_descriptor {
6868
/// @param id id values that determines how to interpret the bounds.
6969
explicit constexpr volume_descriptor(const volume_id id) : m_id{id} {}
7070

71+
/// @returns true if the object ID corresponds to a surface
72+
static consteval bool is_surface_id(const object_id id) {
73+
return (id == object_id::e_portal || id == object_id::e_sensitive ||
74+
id == object_id::e_passive);
75+
}
76+
77+
/// @returns true if the object ID corresponds to a [daughter] volume
78+
static consteval bool is_volume_id(const object_id id) {
79+
return (id == object_id::e_volume);
80+
}
81+
7182
/// @returns the volume shape id, e.g. 'cylinder'
7283
DETRAY_HOST_DEVICE
7384
constexpr auto id() const -> volume_id { return m_id; }

core/include/detray/navigation/accelerators/brute_force_finder.hpp renamed to core/include/detray/navigation/accelerators/brute_force_searcher.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class brute_force_collection {
4545
: public detray::ranges::subrange<const vector_type<value_t>> {
4646

4747
using base = detray::ranges::subrange<const vector_type<value_t>>;
48+
using value_type = value_t;
4849

4950
/// Default constructor
5051
brute_forcer() = default;

core/include/detray/navigation/accelerators/concepts.hpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#pragma once
99

1010
// Project include(s)
11+
#include "detray/core/detail/container_buffers.hpp"
12+
#include "detray/core/detail/container_views.hpp"
1113
#include "detray/definitions/indexing.hpp"
1214
#include "detray/geometry/surface_descriptor.hpp"
1315
#include "detray/utils/concepts.hpp"
@@ -25,9 +27,24 @@ concept accelerator = requires(const A acc) {
2527
typename A::value_type;
2628

2729
// Iterate through all contained geometry objects
28-
{ acc.all() } -> detray::ranges::range_of<typename A::value_type>;
30+
{ acc.all() } -> ranges::range_of<typename A::value_type>;
31+
32+
// TODO: In order to require the search method, we need to pass a detector
33+
// which is auto-deduced
2934
};
3035

36+
/// Concept for a collection of accelerator (data) that can be stored in the
37+
/// detector
38+
template <class AC>
39+
concept accelerator_collection =
40+
viewable<AC> && bufferable<AC> &&
41+
requires(const AC accel_coll, unsigned int idx) {
42+
typename AC::size_type;
43+
requires concepts::accelerator<typename AC::value_type>;
44+
45+
{ accel_coll[idx] } -> concepts::accelerator;
46+
};
47+
3148
/// Acceleration structure that contains surfaces (surface descriptors)
3249
/// TODO: Add surface descriptor concept to geometry package
3350
template <class A>
@@ -47,11 +64,11 @@ concept volume_accelerator =
4764
/// Brute force acceleration structures
4865
/// @{
4966
template <class A>
50-
concept brute_force_surface_finder =
67+
concept brute_force_surface_searcher =
5168
!concepts::grid<A> && concepts::volume_accelerator<A>;
5269

5370
template <class A>
54-
concept brute_force_volume_finder =
71+
concept brute_force_volume_searcher =
5572
!concepts::grid<A> && concepts::surface_accelerator<A>;
5673
/// @}
5774

core/include/detray/navigation/accelerators/accelerator_grid.hpp renamed to core/include/detray/navigation/accelerators/grid_searcher.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
namespace detray {
1919

2020
/// @brief An N-dimensional spacial grid for geometry object searches.
21-
///
22-
/// @tparam value_t Type of values contained in the grid
2321
template <typename axes_t, typename bin_t,
2422
template <std::size_t> class serializer_t = simple_serializer>
25-
class accelerator_grid_impl : public grid_impl<axes_t, bin_t, serializer_t> {
23+
class grid_searcher_impl : public grid_impl<axes_t, bin_t, serializer_t> {
2624

2725
using base_grid = grid_impl<axes_t, bin_t, serializer_t>;
2826

2927
public:
30-
/// Adopt type definitions and static variables
28+
/// Adopt type definitions and static variables of the underlying grid
3129
/// @{
3230
template <typename neighbor_t>
3331
using neighborhood_type = darray<neighbor_t, base_grid::dim>;
@@ -117,11 +115,10 @@ class accelerator_grid_impl : public grid_impl<axes_t, bin_t, serializer_t> {
117115
}
118116
};
119117

120-
/// Type alias for easier construction
121118
template <concepts::algebra algebra_t, typename axes_t, typename bin_t,
122119
template <std::size_t> class serializer_t = simple_serializer,
123120
typename containers = host_container_types, bool ownership = true>
124-
using accelerator_grid = accelerator_grid_impl<
121+
using grid_searcher = grid_searcher_impl<
125122
coordinate_axes<axes_t, algebra_t, ownership, containers>, bin_t,
126123
simple_serializer>;
127124

detectors/include/detray/detectors/default_metadata.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include "detray/materials/material_map.hpp"
2222
#include "detray/materials/material_rod.hpp"
2323
#include "detray/materials/material_slab.hpp"
24-
#include "detray/navigation/accelerators/accelerator_grid.hpp"
25-
#include "detray/navigation/accelerators/brute_force_finder.hpp"
24+
#include "detray/navigation/accelerators/brute_force_searcher.hpp"
25+
#include "detray/navigation/accelerators/grid_searcher.hpp"
2626

2727
namespace detray {
2828

@@ -276,8 +276,8 @@ unbounded_cell, unmasked_plane*/>;
276276
// surface grid definition: bin-content: darray<surface_type, 9>
277277
template <typename axes_t, typename bin_entry_t, typename container_t>
278278
using surface_grid_t =
279-
accelerator_grid<algebra_type, axes_t, bins::dynamic_array<bin_entry_t>,
280-
simple_serializer, container_t, false>;
279+
grid_searcher<algebra_type, axes_t, bins::dynamic_array<bin_entry_t>,
280+
simple_serializer, container_t, false>;
281281

282282
// 2D cylindrical grid for the barrel layers
283283
template <typename bin_entry_t, typename container_t>
@@ -405,11 +405,11 @@ unbounded_cell, unmasked_plane*/>;
405405
/// Volume search grid
406406
template <typename container_t = host_container_types>
407407
using volume_accelerator =
408-
accelerator_grid<algebra_type,
409-
axes<cylinder3D, axis::bounds::e_open, axis::irregular,
410-
axis::regular, axis::irregular>,
411-
bins::single<dindex>, simple_serializer, container_t,
412-
false>;
408+
grid_searcher<algebra_type,
409+
axes<cylinder3D, axis::bounds::e_open, axis::irregular,
410+
axis::regular, axis::irregular>,
411+
bins::single<dindex>, simple_serializer, container_t,
412+
false>;
413413

414414
/// How to store the acceleration data structures
415415
template <typename container_t = host_container_types>

detectors/include/detray/detectors/itk_metadata.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include "detray/geometry/surface_descriptor.hpp"
2222
#include "detray/materials/material_map.hpp"
2323
#include "detray/materials/material_slab.hpp"
24-
#include "detray/navigation/accelerators/accelerator_grid.hpp"
25-
#include "detray/navigation/accelerators/brute_force_finder.hpp"
24+
#include "detray/navigation/accelerators/brute_force_searcher.hpp"
25+
#include "detray/navigation/accelerators/grid_searcher.hpp"
2626

2727
// Linear algebra types
2828
#include "detray/definitions/algebra.hpp"
@@ -264,10 +264,11 @@ struct itk_metadata {
264264
/// given position. Here: Uniform grid with a 3D cylindrical shape
265265
template <typename container_t = host_container_types>
266266
using volume_accelerator =
267-
grid<algebra_type,
268-
axes<cylinder3D, axis::bounds::e_open, axis::irregular,
269-
axis::regular, axis::irregular>,
270-
bins::single<dindex>, simple_serializer, container_t, false>;
267+
grid_searcher<algebra_type,
268+
axes<cylinder3D, axis::bounds::e_open, axis::irregular,
269+
axis::regular, axis::irregular>,
270+
bins::single<dindex>, simple_serializer, container_t,
271+
false>;
271272

272273
/// The tuple store that hold the acceleration data structures for all
273274
/// volumes. Every collection of accelerationdata structures defines its

0 commit comments

Comments
 (0)