Skip to content

Commit bfc4bde

Browse files
committed
Fix compilation
1 parent 8cbf3bf commit bfc4bde

File tree

22 files changed

+186
-171
lines changed

22 files changed

+186
-171
lines changed

core/include/detray/builders/grid_builder.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "detray/builders/volume_builder.hpp"
1515
#include "detray/builders/volume_builder_interface.hpp"
1616
#include "detray/geometry/tracking_volume.hpp"
17+
#include "detray/navigation/accelerators/grid_searcher.hpp"
1718
#include "detray/utils/grid/detail/concepts.hpp"
1819

1920
// System include(s)
@@ -183,8 +184,13 @@ class grid_builder : public volume_decorator<detector_t> {
183184
}
184185

185186
// Add the grid to the detector and link it to its volume
186-
constexpr auto gid{detector_t::accel::template get_id<grid_t>()};
187-
det._accelerators.template push_back<gid>(m_grid);
187+
grid_searcher_impl gr_searcher{std::move(m_grid)};
188+
using non_owning_searcher_t =
189+
typename decltype(gr_searcher)::template type<false>;
190+
constexpr auto gid{
191+
detector_t::accel::template get_id<non_owning_searcher_t>()};
192+
193+
det._accelerators.template push_back<gid>(gr_searcher);
188194
vol_ptr->set_link(m_id, gid,
189195
det.accelerator_store().template size<gid>() - 1);
190196

core/include/detray/core/detail/alignment.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ typename host_detector_type::view_type misaligned_detector_view(
2525
detray::get_data(
2626
detray::detail::get<4>(det_buffer.m_buffer)), // materials
2727
detray::get_data(
28-
detray::detail::get<5>(det_buffer.m_buffer)), // accelerators
29-
detray::get_data(detray::detail::get<6>(
30-
det_buffer.m_buffer))}; // volume search grid
28+
detray::detail::get<5>(det_buffer.m_buffer))}; // accelerators
3129
return detview;
3230
}
3331

core/include/detray/core/detector.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,17 @@ class detector {
220220

221221
/// @return the volume by global cartesian @param position - const access
222222
DETRAY_HOST_DEVICE
223-
inline const auto &volume(const point3_type &p) const {
223+
inline const auto &volume(const point3_type & /*p*/) const {
224224
volume_type v_desc{};
225225
// Allow to call the volume search data structure
226226
v_desc.template set_accel_link<geo_obj_ids::e_volume>(
227-
accel::id::e_volume_brute_force, 0u);
228-
tracking_volume world{v_desc, *this};
227+
accel::id::e_default_volume_searcher, 0u);
228+
tracking_volume world{*this, v_desc};
229229

230-
const dindex volume_index =
230+
const dindex volume_index{0u};
231+
/*const dindex volume_index =
231232
world.template visit_accelerator<geo_obj_ids::e_volume,
232-
volume_search>(p);
233+
volume_search>(p);*/
233234
return _volumes[volume_index];
234235
}
235236

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

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,6 @@ struct surface_getter {
6767
}
6868
};
6969

70-
/// A functor to access the daughter volumes of a volume
71-
template <typename functor_t>
72-
struct volume_getter {
73-
74-
/// Call operator that forwards the functor call to all contained daughter
75-
/// volumes
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 {
81-
82-
using accel_type = typename accel_coll_t::value_type;
83-
84-
if constexpr (concepts::volume_accelerator<accel_type>) {
85-
// Run over all the daughter volumes
86-
// TODO: Implement e.g. BVH
87-
}
88-
}
89-
};
90-
9170
/// A functor to find surfaces in the neighborhood of a track position
9271
template <typename functor_t>
9372
struct neighborhood_getter {
@@ -104,22 +83,37 @@ struct neighborhood_getter {
10483
const typename detector_t::geometry_context &ctx,
10584
Args &&...args) const {
10685

86+
using accel_type = typename accel_coll_t::value_type;
87+
10788
decltype(auto) accel = coll[index];
10889

109-
// Run over the surfaces in a single acceleration data structure
110-
for (const auto &sf : accel.search(det, volume, track, cfg, ctx)) {
111-
functor_t{}(sf, std::forward<Args>(args)...);
90+
if constexpr (concepts::surface_accelerator<accel_type>) {
91+
// Run over the surfaces in a single acceleration data structure
92+
for (const auto &sf : accel.search(det, volume, track, cfg, ctx)) {
93+
functor_t{}(sf, std::forward<Args>(args)...);
94+
}
11295
}
11396
}
11497
};
11598

116-
/// Query the maximal number of candidates from the acceleration
117-
struct n_candidates_getter {
99+
/// A functor to access the daughter volumes of a volume
100+
template <typename functor_t>
101+
struct volume_getter {
102+
103+
/// Call operator that forwards the functor call to all contained daughter
104+
/// volumes
118105
template <concepts::accelerator_collection accel_coll_t,
119-
typename accel_index_t>
120-
DETRAY_HOST_DEVICE inline auto operator()(const accel_coll_t &coll,
121-
const accel_index_t index) const {
122-
return coll[index].n_max_candidates();
106+
typename accel_index_t, typename... Args>
107+
DETRAY_HOST_DEVICE inline void operator()(const accel_coll_t &,
108+
const accel_index_t,
109+
Args &&...) const {
110+
111+
using accel_type = typename accel_coll_t::value_type;
112+
113+
if constexpr (concepts::volume_accelerator<accel_type>) {
114+
// Run over all the daughter volumes
115+
// TODO: Implement e.g. BVH
116+
}
123117
}
124118
};
125119

core/include/detray/geometry/tracking_volume.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ class tracking_volume {
8888
DETRAY_HOST_DEVICE
8989
constexpr auto index() const -> dindex { return m_desc.index(); }
9090

91+
/// @returns the volume name (add an offset for the detector name).
92+
DETRAY_HOST
93+
auto name(const name_map &names) const -> std::string {
94+
return names.empty() ? "unknown volume" : names.at(m_desc.index() + 1u);
95+
}
96+
9197
/// @returns the (non contextual) transform for the placement of the
9298
/// volume in the detector geometry.
9399
DETRAY_HOST_DEVICE
@@ -144,7 +150,7 @@ class tracking_volume {
144150
/// @tparam functor_t the prescription to be applied to the surfaces
145151
/// @tparam Args types of additional arguments to the functor
146152
template <object_id I, typename functor_t, typename... Args>
147-
DETRAY_HOST_DEVICE constexpr void visit_accelerator(Args &&... args) const {
153+
DETRAY_HOST_DEVICE constexpr void visit_accelerator(Args &&...args) const {
148154
static_assert(I < object_id::e_all);
149155

150156
if (const auto &link{m_desc.template accel_link<I>()};
@@ -163,8 +169,7 @@ class tracking_volume {
163169
/// @tparam Args types of additional arguments to the functor
164170
template <typename functor_t,
165171
int I = static_cast<int>(object_id::e_all) - 1, typename... Args>
166-
DETRAY_HOST_DEVICE constexpr void visit_accelerators(
167-
Args &&... args) const {
172+
DETRAY_HOST_DEVICE constexpr void visit_accelerators(Args &&...args) const {
168173
// Get the acceleration data structures for this volume and only visit,
169174
// if object type is contained in volume
170175
visit_accelerator<static_cast<object_id>(I), functor_t>(
@@ -184,7 +189,7 @@ class tracking_volume {
184189
/// @tparam functor_t the prescription to be applied to the surfaces
185190
/// @tparam Args types of additional arguments to the functor
186191
template <surface_id I, typename functor_t, typename... Args>
187-
DETRAY_HOST_DEVICE constexpr void visit_surfaces(Args &&... args) const {
192+
DETRAY_HOST_DEVICE constexpr void visit_surfaces(Args &&...args) const {
188193
using surface_getter_t = detail::surface_getter<functor_t>;
189194

190195
// Dispatch to the correct acceleration structure
@@ -223,7 +228,7 @@ class tracking_volume {
223228
/// @tparam Args types of additional arguments to the functor
224229
template <surface_id I, typename functor_t, typename... Args>
225230
DETRAY_HOST_DEVICE constexpr void visit_daughter_volumes(
226-
Args &&... args) const {
231+
Args &&...args) const {
227232
using volume_getter_t = detail::volume_getter<functor_t>;
228233

229234
visit_accelerator<object_id::e_volume, volume_getter_t>(
@@ -243,9 +248,10 @@ class tracking_volume {
243248
/// @tparam Args types of additional arguments to the functor
244249
template <object_id I, typename functor_t, typename track_t,
245250
typename config_t, typename... Args>
246-
DETRAY_HOST_DEVICE constexpr void visit_neighborhood(
247-
const track_t &track, const config_t &cfg, const context_t &ctx,
248-
Args &&... args) const {
251+
DETRAY_HOST_DEVICE constexpr void visit_neighborhood(const track_t &track,
252+
const config_t &cfg,
253+
const context_t &ctx,
254+
Args &&...args) const {
249255
if constexpr (I == object_id::e_all) {
250256
visit_accelerators<detail::neighborhood_getter<functor_t>>(
251257
m_detector, m_desc, track, cfg, ctx,
@@ -372,12 +378,6 @@ class tracking_volume {
372378
return true;
373379
}
374380

375-
/// @returns the volume name (add an offset for the detector name).
376-
DETRAY_HOST_DEVICE
377-
auto name(const name_map &names) const -> std::string {
378-
return names.empty() ? "" : names.at(m_desc.index() + 1u);
379-
}
380-
381381
/// @returns a string stream that prints the volume details
382382
DETRAY_HOST
383383
friend std::ostream &operator<<(std::ostream &os,

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ namespace detray::concepts {
2424
/// Concept for a detray geometry acceleration structures
2525
template <class A>
2626
concept accelerator = requires(const A acc) {
27-
2827
typename A::value_type;
2928

3029
// Iterate through all contained geometry objects
31-
{ acc.all() }
32-
->ranges::range_of<typename A::value_type>;
30+
{ acc.all() } -> ranges::range_of<typename A::value_type>;
3331

3432
// TODO: In order to require the search method, we need to pass a detector
3533
// which is auto-deduced
@@ -38,20 +36,20 @@ concept accelerator = requires(const A acc) {
3836
/// Concept for a collection of accelerator (data) that can be stored in the
3937
/// detector
4038
template <class AC>
41-
concept accelerator_collection = viewable<AC>&& bufferable<AC>&& requires(
42-
const AC accel_coll, unsigned int idx) {
43-
44-
typename AC::size_type;
45-
requires concepts::accelerator<typename AC::value_type>;
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>;
4644

47-
{ accel_coll[idx] }
48-
->concepts::accelerator;
49-
};
45+
{ accel_coll[idx] } -> concepts::accelerator;
46+
};
5047

5148
/// Acceleration structure that contains surfaces (surface descriptors)
5249
/// TODO: Add surface descriptor concept to geometry package
5350
template <class A>
54-
concept surface_accelerator = concepts::accelerator<A>&&
51+
concept surface_accelerator =
52+
concepts::accelerator<A> &&
5553
std::same_as<typename A::value_type,
5654
surface_descriptor<typename A::value_type::mask_link,
5755
typename A::value_type::material_link,
@@ -61,7 +59,7 @@ concept surface_accelerator = concepts::accelerator<A>&&
6159
/// Acceleration structure that contains volumes (volume indices)
6260
template <class A>
6361
concept volume_accelerator =
64-
concepts::accelerator<A>&& std::same_as<typename A::value_type, dindex>;
62+
concepts::accelerator<A> && std::same_as<typename A::value_type, dindex>;
6563

6664
/// Brute force acceleration structures
6765
/// @{
@@ -77,10 +75,10 @@ concept brute_force_volume_searcher =
7775
/// Grid based acceleration structures
7876
/// @{
7977
template <class A>
80-
concept surface_grid = concepts::grid<A>&& concepts::surface_accelerator<A>;
78+
concept surface_grid = concepts::grid<A> && concepts::surface_accelerator<A>;
8179

8280
template <class A>
83-
concept volume_grid = concepts::grid<A>&& concepts::volume_accelerator<A>;
81+
concept volume_grid = concepts::grid<A> && concepts::volume_accelerator<A>;
8482
/// @}
8583

8684
} // namespace detray::concepts

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

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#pragma once
99

1010
// Project include(s)
11-
#include "detray/geometry/detail/surface_descriptor.hpp"
11+
#include "detray/geometry/surface_descriptor.hpp"
1212
#include "detray/utils/grid/detail/axis_helpers.hpp"
1313
#include "detray/utils/grid/detail/bin_view.hpp"
1414
#include "detray/utils/grid/detail/grid_bins.hpp"
@@ -25,42 +25,29 @@ class grid_searcher_impl : public grid_impl<axes_t, bin_t, serializer_t> {
2525
using base_grid = grid_impl<axes_t, bin_t, serializer_t>;
2626

2727
public:
28-
/// Adopt type definitions and static variables of the underlying grid
29-
/// @{
30-
template <typename neighbor_t>
31-
using neighborhood_type = darray<neighbor_t, base_grid::dim>;
32-
33-
static constexpr unsigned int dim{base_grid::dim};
34-
static constexpr bool is_owning{base_grid::is_owning};
35-
3628
using value_type = typename base_grid::value_type;
37-
using algebra_type = typename base_grid::algebra_type;
38-
using scalar_type = typename base_grid::scalar_type;
3929
using point_type = typename base_grid::point_type;
4030

41-
using bin_type = typename base_grid::bin_type;
42-
using glob_bin_index = typename base_grid::glob_bin_index;
43-
using loc_bin_index = typename base_grid::loc_bin_index;
44-
using axes_type = typename base_grid::axes_type;
45-
using bin_storage = typename base_grid::bin_storage;
46-
using bin_container_type = typename base_grid::bin_container_type;
47-
48-
using view_type = typename base_grid::view_type;
49-
using const_view_type = typename base_grid::const_view_type;
50-
using buffer_type = typename base_grid::buffer_type;
51-
52-
template <std::size_t DIM>
53-
using serializer_type = typename base_grid::template serializer_type<DIM>;
31+
template <typename neighbor_t>
32+
using neighborhood_type = darray<neighbor_t, base_grid::dim>;
5433

5534
/// Find the corresponding (non-)owning grid type
5635
template <bool owning>
5736
using type = grid_searcher_impl<typename axes_t::template type<owning>,
5837
bin_t, serializer_t>;
59-
/// @}
6038

6139
/// Use all of the grid constructors
6240
using base_grid::base_grid;
6341

42+
/// Construct from existing grid
43+
DETRAY_HOST_DEVICE
44+
explicit constexpr grid_searcher_impl(base_grid &&gr)
45+
: base_grid(std::move(gr)) {}
46+
47+
/// Construct from existing grid
48+
DETRAY_HOST_DEVICE
49+
explicit constexpr grid_searcher_impl(base_grid &gr) : base_grid(gr) {}
50+
6451
/// Interface for the navigator
6552
template <typename detector_t, typename track_t, typename config_t>
6653
DETRAY_HOST_DEVICE auto search(
@@ -115,6 +102,12 @@ class grid_searcher_impl : public grid_impl<axes_t, bin_t, serializer_t> {
115102
}
116103
};
117104

105+
template <typename axes_t, typename bin_t,
106+
template <std::size_t> class serializer_t>
107+
DETRAY_HOST_DEVICE grid_searcher_impl(
108+
grid_impl<axes_t, bin_t, serializer_t> &&gr)
109+
-> grid_searcher_impl<axes_t, bin_t, serializer_t>;
110+
118111
template <concepts::algebra algebra_t, typename axes_t, typename bin_t,
119112
template <std::size_t> class serializer_t = simple_serializer,
120113
typename containers = host_container_types, bool ownership = true>

core/include/detray/utils/grid/detail/concepts.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ concept axis = requires(const A ax) {
5050
ax.bin_edges(dindex())
5151
} -> std::same_as<darray<typename A::scalar_type, 2>>;
5252

53-
{ ax.bin_edges() }
54-
->detray::ranges::range_of<typename A::scalar_type>;
53+
{ ax.bin_edges() } -> detray::ranges::range_of<typename A::scalar_type>;
5554

5655
{ ax.span() } -> std::same_as<darray<typename A::scalar_type, 2>>;
5756

@@ -91,8 +90,7 @@ concept grid = viewable<G> && bufferable<G> && requires(const G g) {
9190
g.serialize(typename G::loc_bin_index())
9291
} -> std::same_as<typename G::glob_bin_index>;
9392

94-
{ g.bins() }
95-
->detray::ranges::range_of<typename G::bin_type>;
93+
{ g.bins() } -> detray::ranges::range_of<typename G::bin_type>;
9694

9795
{
9896
g.bin(typename G::glob_bin_index())

core/include/detray/utils/grid/grid.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class grid_impl {
245245
}
246246

247247
/// @param indices the single indices corresponding to a multi_bin
248-
template <typename... I>
248+
template <concepts::index... I>
249249
requires(sizeof...(I) == dim)
250250
DETRAY_HOST_DEVICE decltype(auto) bin(I... indices) const {
251251
return bin(loc_bin_index{indices...});

0 commit comments

Comments
 (0)