Skip to content

Commit

Permalink
Remove the ALGEBRA_PLUGIN macro
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Dec 7, 2024
1 parent ad0036f commit 13704c7
Show file tree
Hide file tree
Showing 174 changed files with 1,534 additions and 1,177 deletions.
5 changes: 4 additions & 1 deletion core/include/detray/builders/bin_fillers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,13 @@ struct bin_associator {
const transform_container &transforms,
const mask_container &masks,
const context_t ctx, Args &&...) const -> void {

using scalar_t = dscalar<typename grid_t::algebra_type>;

// Fill the surfaces into the grid by matching their contour onto the
// grid bins
bin_association(ctx, surfaces, transforms, masks, grid,
std::array{0.1f, 0.1f}, false);
std::array<scalar_t, 2>{0.1f, 0.1f}, false);
}
};

Expand Down
13 changes: 7 additions & 6 deletions core/include/detray/builders/cuboid_portal_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ template <typename detector_t>
class cuboid_portal_generator final
: public surface_factory_interface<detector_t> {

using scalar_type = typename detector_t::scalar_type;
using transform3_type = typename detector_t::transform3_type;
using algebra_type = typename detector_t::algebra_type;
using scalar_type = dscalar<algebra_type>;
using transform3_type = dtransform3D<algebra_type>;

/// A functor to construct global bounding boxes around masks
struct bounding_box_creator {

using aabb_t = axis_aligned_bounding_volume<cuboid3D, scalar_type>;
using aabb_t = axis_aligned_bounding_volume<cuboid3D, algebra_type>;

template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline void operator()(
Expand Down Expand Up @@ -86,15 +87,15 @@ class cuboid_portal_generator final
typename detector_t::geometry_context ctx = {})
-> dindex_range override {

using point3_t = typename detector_t::point3_type;
using vector3_t = typename detector_t::vector3_type;
using point3_t = dpoint3D<algebra_type>;
using vector3_t = dvector3D<algebra_type>;

using surface_t = typename detector_t::surface_type;
using nav_link_t = typename surface_t::navigation_link;
using mask_link_t = typename surface_t::mask_link;
using material_link_t = typename surface_t::material_link;

using aabb_t = axis_aligned_bounding_volume<cuboid3D, scalar_type>;
using aabb_t = axis_aligned_bounding_volume<cuboid3D, algebra_type>;

constexpr auto invalid_src_link{detail::invalid_value<std::uint64_t>()};

Expand Down
13 changes: 7 additions & 6 deletions core/include/detray/builders/cylinder_portal_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,16 @@ template <typename detector_t>
class cylinder_portal_generator final
: public surface_factory_interface<detector_t> {

using scalar_t = typename detector_t::scalar_type;
using point3_t = typename detector_t::point3_type;
using vector3_t = typename detector_t::vector3_type;
using transform3_t = typename detector_t::transform3_type;
using algebra_t = typename detector_t::algebra_type;
using scalar_t = dscalar<algebra_t>;
using point3_t = dpoint3D<algebra_t>;
using vector3_t = dvector3D<algebra_t>;
using transform3_t = dtransform3D<algebra_t>;

/// A functor to construct global bounding boxes around masks
struct bounding_box_creator {

using aabb_t = axis_aligned_bounding_volume<cuboid3D, scalar_t>;
using aabb_t = axis_aligned_bounding_volume<cuboid3D, algebra_t>;

template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline void operator()(
Expand Down Expand Up @@ -182,7 +183,7 @@ class cylinder_portal_generator final
typename detector_t::geometry_context ctx = {})
-> dindex_range override {

using aabb_t = axis_aligned_bounding_volume<cuboid3D, scalar_t>;
using aabb_t = axis_aligned_bounding_volume<cuboid3D, algebra_t>;

// Only build portals for cylinder volumes
assert(volume.id() == volume_id::e_cylinder);
Expand Down
10 changes: 5 additions & 5 deletions core/include/detray/builders/detector_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace detray {
/// @tparam volume_builder_t the basic volume builder to be used for the
/// geometry data
/// @tparam volume_data_t the data structure that holds the volume builders
template <typename metadata = default_metadata,
template <typename metadata,
template <typename> class volume_builder_t = volume_builder,
template <typename...> class volume_data_t = std::vector>
class detector_builder {
Expand Down Expand Up @@ -123,7 +123,7 @@ class detector_builder {
if constexpr (concepts::grid<vol_finder_t>) {

// TODO: Construct it correctly with the grid builder
mask<cylinder3D> vgrid_dims{
mask<cylinder3D, algebra_type> vgrid_dims{
0u, 0.f, -constant<scalar_type>::pi,
-2000.f, 180.f, constant<scalar_type>::pi,
2000.f};
Expand All @@ -139,9 +139,9 @@ class detector_builder {
m_vol_finder = vgrid_factory.template new_grid<
axis::open<axis::label::e_r>,
axis::circular<axis::label::e_phi>,
axis::open<axis::label::e_z>, axis::irregular<>,
axis::regular<>, axis::irregular<>>(vgrid_dims, n_vgrid_bins,
{}, bin_edges);
axis::open<axis::label::e_z>, axis::irregular<scalar_type>,
axis::regular<scalar_type>, axis::irregular<scalar_type>>(
vgrid_dims, n_vgrid_bins, {}, bin_edges);
} else {
m_vol_finder = vol_finder_t{args...};
}
Expand Down
11 changes: 6 additions & 5 deletions core/include/detray/builders/grid_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class grid_builder : public volume_decorator<detector_t> {
public:
using scalar_type = typename detector_t::scalar_type;
using detector_type = detector_t;
using algebra_type = typename detector_t::algebra_type;
using value_type = typename detector_type::surface_type;

/// Decorate a volume with a grid
Expand Down Expand Up @@ -78,7 +79,7 @@ class grid_builder : public volume_decorator<detector_t> {
/// Delegate init call depending on @param span type
template <typename grid_shape_t>
DETRAY_HOST void init_grid(
const mask<grid_shape_t> &m,
const mask<grid_shape_t, algebra_type> &m,
const std::array<std::size_t, grid_t::dim> &n_bins,
const std::vector<std::pair<typename grid_t::loc_bin_index, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -210,12 +211,12 @@ template <typename detector_t,
typename grid_shape_t, typename bin_t,
template <std::size_t> class serializer_t,
axis::bounds e_bounds = axis::bounds::e_closed,
typename algebra_t = typename detector_t::transform3,
template <typename, typename> class... binning_ts>
using grid_builder_type = grid_builder<
detector_t,
typename grid_factory_t<bin_t, serializer_t, algebra_t>::template grid_type<
axes<grid_shape_t, e_bounds, binning_ts...>>,
grid_factory_t<bin_t, serializer_t, algebra_t>>;
typename grid_factory_t<bin_t, serializer_t,
typename detector_t::algebra_type>::
template grid_type<axes<grid_shape_t, e_bounds, binning_ts...>>,
grid_factory_t<bin_t, serializer_t, typename detector_t::algebra_type>>;

} // namespace detray
70 changes: 35 additions & 35 deletions core/include/detray/builders/grid_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace detray {
/// @note that if non-zero axis_spans are provided the values of the
/// mask is overwritten
template <typename bin_t, template <std::size_t> class serializer_t,
typename algebra_t = ALGEBRA_PLUGIN<DETRAY_CUSTOM_SCALARTYPE>>
typename algebra_t>
class grid_factory {

public:
Expand All @@ -52,7 +52,8 @@ class grid_factory {

using bin_type = bin_t;
template <typename grid_shape_t>
using grid_type = grid<axes<grid_shape_t>, bin_type, serializer_t>;
using grid_type =
grid<algebra_t, axes<grid_shape_t>, bin_type, serializer_t>;
template <typename grid_shape_t>
using loc_bin_index = typename grid_type<grid_shape_t>::loc_bin_index;

Expand All @@ -73,10 +74,10 @@ class grid_factory {
template <
typename r_bounds = axis::closed<axis::label::e_r>,
typename phi_bounds = axis::circular<>,
typename r_binning = axis::regular<host_container_types, scalar_type>,
typename phi_binning = axis::regular<host_container_types, scalar_type>>
typename r_binning = axis::regular<scalar_type, host_container_types>,
typename phi_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(r_bounds::label)> auto new_grid(
const mask<annulus2D> &grid_bounds,
const mask<annulus2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<annulus2D>, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -130,11 +131,11 @@ class grid_factory {
typename x_bounds = axis::closed<axis::label::e_x>,
typename y_bounds = axis::closed<axis::label::e_y>,
typename z_bounds = axis::closed<axis::label::e_z>,
typename x_binning = axis::regular<host_container_types, scalar_type>,
typename y_binning = axis::regular<host_container_types, scalar_type>,
typename z_binning = axis::regular<host_container_types, scalar_type>>
typename x_binning = axis::regular<scalar_type, host_container_types>,
typename y_binning = axis::regular<scalar_type, host_container_types>,
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(x_bounds::label)> auto new_grid(
const mask<cuboid3D> &grid_bounds,
const mask<cuboid3D, algebra_type> &grid_bounds,
const std::array<std::size_t, 3UL> n_bins,
const std::vector<std::pair<loc_bin_index<cuboid3D>, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -187,10 +188,10 @@ class grid_factory {
typename rphi_bounds = axis::circular<axis::label::e_rphi>,
typename z_bounds = axis::closed<axis::label::e_cyl_z>,
typename rphi_binning =
axis::regular<host_container_types, scalar_type>,
typename z_binning = axis::regular<host_container_types, scalar_type>>
axis::regular<scalar_type, host_container_types>,
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(rphi_bounds::label)> auto new_grid(
const mask<cylinder2D> &grid_bounds,
const mask<cylinder2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<cylinder2D>, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -233,10 +234,10 @@ class grid_factory {
typename rphi_bounds = axis::circular<axis::label::e_rphi>,
typename z_bounds = axis::closed<axis::label::e_cyl_z>,
typename rphi_binning =
axis::regular<host_container_types, scalar_type>,
typename z_binning = axis::regular<host_container_types, scalar_type>>
axis::regular<scalar_type, host_container_types>,
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(rphi_bounds::label)> auto new_grid(
const mask<concentric_cylinder2D> &grid_bounds,
const mask<concentric_cylinder2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<concentric_cylinder2D>,
dindex>> &bin_capacities = {},
Expand Down Expand Up @@ -280,11 +281,11 @@ class grid_factory {
typename r_bounds = axis::closed<axis::label::e_r>,
typename phi_bounds = axis::circular<>,
typename z_bounds = axis::closed<axis::label::e_z>,
typename r_binning = axis::regular<host_container_types, scalar_type>,
typename phi_binning = axis::regular<host_container_types, scalar_type>,
typename z_binning = axis::regular<host_container_types, scalar_type>>
typename r_binning = axis::regular<scalar_type, host_container_types>,
typename phi_binning = axis::regular<scalar_type, host_container_types>,
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(r_bounds::label)> auto new_grid(
const mask<cylinder3D> &grid_bounds,
const mask<cylinder3D, algebra_type> &grid_bounds,
const std::array<std::size_t, 3UL> n_bins,
const std::vector<std::pair<loc_bin_index<cylinder3D>, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -344,10 +345,10 @@ class grid_factory {
template <
typename r_bounds = axis::closed<axis::label::e_r>,
typename phi_bounds = axis::circular<>,
typename r_binning = axis::regular<host_container_types, scalar_type>,
typename phi_binning = axis::regular<host_container_types, scalar_type>>
typename r_binning = axis::regular<scalar_type, host_container_types>,
typename phi_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(r_bounds::label)> auto new_grid(
const mask<ring2D> &grid_bounds,
const mask<ring2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<ring2D>, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -390,10 +391,10 @@ class grid_factory {
template <
typename x_bounds = axis::closed<axis::label::e_x>,
typename y_bounds = axis::closed<axis::label::e_y>,
typename x_binning = axis::regular<host_container_types, scalar_type>,
typename y_binning = axis::regular<host_container_types, scalar_type>>
typename x_binning = axis::regular<scalar_type, host_container_types>,
typename y_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(x_bounds::label)> auto new_grid(
const mask<rectangle2D> &grid_bounds,
const mask<rectangle2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<rectangle2D>, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -435,10 +436,10 @@ class grid_factory {
template <
typename x_bounds = axis::closed<axis::label::e_x>,
typename y_bounds = axis::closed<axis::label::e_y>,
typename x_binning = axis::regular<host_container_types, scalar_type>,
typename y_binning = axis::regular<host_container_types, scalar_type>>
typename x_binning = axis::regular<scalar_type, host_container_types>,
typename y_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(x_bounds::label)> auto new_grid(
const mask<trapezoid2D> &grid_bounds,
const mask<trapezoid2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<trapezoid2D>, dindex>>
&bin_capacities = {},
Expand Down Expand Up @@ -509,7 +510,7 @@ class grid_factory {
using axes_t =
axis::multi_axis<is_owning, grid_frame_t,
axis::single_axis<bound_ts, binning_ts>...>;
using grid_t = grid<axes_t, bin_t, serializer_t>;
using grid_t = grid<algebra_t, axes_t, bin_t, serializer_t>;

return new_grid<grid_t>(spans, n_bins, bin_capacities, ax_bin_edges);
}
Expand All @@ -535,7 +536,7 @@ class grid_factory {
/// and binnings from concrete grid type
template <concepts::grid grid_t, typename grid_shape_t>
auto new_grid(
const mask<grid_shape_t> &m,
const mask<grid_shape_t, algebra_type> &m,
const std::array<std::size_t, grid_t::dim> &n_bins,
const std::vector<std::pair<typename grid_t::loc_bin_index, dindex>>
&bin_capacities = {},
Expand All @@ -555,7 +556,7 @@ class grid_factory {
typename grid_shape_t, typename... bound_ts, typename... binning_ts,
std::enable_if_t<std::is_enum_v<typename grid_shape_t::boundaries>,
bool> = true>
auto new_grid(const mask<grid_shape_t> &m,
auto new_grid(const mask<grid_shape_t, algebra_type> &m,
const std::array<std::size_t, grid_shape_t::dim> &n_bins,
const std::vector<
std::pair<axis::multi_bin<sizeof...(bound_ts)>, dindex>>
Expand Down Expand Up @@ -652,7 +653,7 @@ class grid_factory {
vector_type<scalar_type> &bin_edges) const {
if constexpr (std::is_same_v<
types::at<binnings, I>,
axis::regular<host_container_types, scalar_type>>) {
axis::regular<scalar_type, host_container_types>>) {
axes_data.push_back({static_cast<dindex>(bin_edges.size()),
static_cast<dindex>(n_bins.at(I))});
bin_edges.push_back(spans.at(I * 2u));
Expand Down Expand Up @@ -685,11 +686,10 @@ class grid_factory {
};

// Infer a grid factory type from an already completely assembled grid type
template <concepts::grid grid_t,
typename algebra_t = ALGEBRA_PLUGIN<DETRAY_CUSTOM_SCALARTYPE>>
template <concepts::grid grid_t>
using grid_factory_type =
grid_factory<typename grid_t::bin_type,
simple_serializer /*grid_t::template serializer_type*/,
algebra_t>;
typename grid_t::algebra_type>;

} // namespace detray
2 changes: 1 addition & 1 deletion core/include/detray/builders/material_map_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct add_sf_material_map;
/// surfaces or volumes
template <typename detector_t, std::size_t DIM = 2u,
typename mat_map_factory_t =
material_grid_factory<typename detector_t::scalar_type>>
material_grid_factory<typename detector_t::algebra_type>>
class material_map_builder final : public volume_decorator<detector_t> {
using materials_t = typename detector_t::materials;

Expand Down
4 changes: 3 additions & 1 deletion core/include/detray/builders/surface_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class surface_factory : public surface_factory_interface<detector_t> {
[[maybe_unused]]
typename detector_t::geometry_context ctx = {})
-> dindex_range override {
using algebra_t = typename detector_t::algebra_type;

// In case the surfaces container is prefilled with other surfaces
const auto surfaces_offset{static_cast<dindex>(surfaces.size())};

Expand All @@ -158,7 +160,7 @@ class surface_factory : public surface_factory_interface<detector_t> {
}

constexpr auto mask_id{detector_t::masks::template get_id<
mask<mask_shape_t, volume_link_t>>()};
mask<mask_shape_t, algebra_t, volume_link_t>>()};

if constexpr (static_cast<std::size_t>(mask_id) >=
detector_t::masks::n_types) {
Expand Down
3 changes: 1 addition & 2 deletions core/include/detray/core/detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void set_transform(detector_t &det, const transform3_t &trf, unsigned int i) {
///
/// @tparam metadata helper that defines collection and link types centrally
/// @tparam container_t type collection of the underlying containers
template <typename metadata_t = default_metadata,
typename container_t = host_container_types>
template <typename metadata_t, typename container_t = host_container_types>
class detector {

// Allow the building of the detector containers
Expand Down
Loading

0 comments on commit 13704c7

Please sign in to comment.