File indexing completed on 2026-05-27 07:24:04
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/core/detail/container_buffers.hpp"
0013 #include "detray/core/detail/container_views.hpp"
0014 #include "detray/definitions/grid_axis.hpp"
0015 #include "detray/definitions/indexing.hpp"
0016 #include "detray/geometry/surface_descriptor.hpp"
0017 #include "detray/utils/concepts.hpp"
0018 #include "detray/utils/ranges/ranges.hpp"
0019
0020
0021 #include <concepts>
0022 #include <utility>
0023
0024 namespace detray::concepts {
0025
0026 template <typename A>
0027 concept axis = requires(const A ax) {
0028 typename A::bounds_type;
0029 typename A::binning_type;
0030 typename A::scalar_type;
0031
0032 { ax.label() } -> std::same_as<axis::label>;
0033
0034 { ax.bounds() } -> std::same_as<axis::bounds>;
0035
0036 { ax.binning() } -> std::same_as<axis::binning>;
0037
0038 { ax.nbins() } -> std::same_as<dindex>;
0039
0040 { ax.bin(typename A::scalar_type()) } -> std::same_as<dindex>;
0041
0042 {
0043 ax.range(typename A::scalar_type(), darray<dindex, 2>())
0044 } -> std::same_as<darray<int, 2>>;
0045
0046 {
0047 ax.range(typename A::scalar_type(), darray<typename A::scalar_type, 2>())
0048 } -> std::same_as<darray<int, 2>>;
0049
0050 {
0051 ax.bin_edges(dindex())
0052 } -> std::same_as<darray<typename A::scalar_type, 2>>;
0053
0054 { ax.bin_edges() } -> detray::ranges::range_of<typename A::scalar_type>;
0055
0056 { ax.span() } -> std::same_as<darray<typename A::scalar_type, 2>>;
0057
0058 { ax.min() } -> std::same_as<typename A::scalar_type>;
0059
0060 { ax.max() } -> std::same_as<typename A::scalar_type>;
0061 };
0062
0063 template <typename G>
0064 concept grid = viewable<G> && bufferable<G> && requires(const G g) {
0065 typename G::bin_type;
0066 typename G::value_type;
0067 typename G::glob_bin_index;
0068 typename G::loc_bin_index;
0069 typename G::local_frame_type;
0070 typename G::algebra_type;
0071 typename G::point_type;
0072
0073 G::dim;
0074 G::is_owning;
0075
0076
0077 { g.get_local_frame() } -> std::same_as<typename G::local_frame_type>;
0078
0079 { g.template get_axis<0>() } -> concepts::axis;
0080
0081 { g.nbins() } -> std::same_as<dindex>;
0082
0083 { g.size() } -> std::same_as<dindex>;
0084
0085 {
0086 g.deserialize(typename G::glob_bin_index())
0087 } -> std::same_as<typename G::loc_bin_index>;
0088
0089 {
0090 g.serialize(typename G::loc_bin_index())
0091 } -> std::same_as<typename G::glob_bin_index>;
0092
0093 { g.bins() } -> detray::ranges::range_of<typename G::bin_type>;
0094
0095 {
0096 g.bin(typename G::glob_bin_index())
0097 } -> concepts::same_as_cvref<typename G::bin_type>;
0098
0099 {
0100 g.bin(typename G::loc_bin_index())
0101 } -> concepts::same_as_cvref<typename G::bin_type>;
0102
0103 {
0104 g.at(typename G::loc_bin_index(), dindex())
0105 } -> concepts::same_as_cvref<typename G::value_type>;
0106
0107 {
0108 g.at(typename G::glob_bin_index(), dindex())
0109 } -> concepts::same_as_cvref<typename G::value_type>;
0110 };
0111
0112
0113
0114 template <class G>
0115 concept surface_grid =
0116 concepts::grid<G> &&
0117 std::same_as<typename G::value_type,
0118 surface_descriptor<typename G::value_type::mask_link,
0119 typename G::value_type::material_link,
0120 typename G::value_type::transform_link,
0121 typename G::value_type::navigation_link>>;
0122
0123
0124 template <class G>
0125 concept volume_grid =
0126 concepts::grid<G> && std::same_as<typename G::value_type, dindex>;
0127
0128 }