File indexing completed on 2026-05-27 07:24:03
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/definitions/containers.hpp"
0014 #include "detray/definitions/detail/qualifiers.hpp"
0015 #include "detray/definitions/math.hpp"
0016
0017
0018 #include <limits>
0019 #include <type_traits>
0020
0021 namespace detray {
0022
0023
0024 namespace step {
0025
0026
0027 enum class direction : int {
0028 e_forward = 1,
0029 e_unknown = std::numeric_limits<int>::max(),
0030 e_backward = -1,
0031 };
0032
0033
0034
0035
0036
0037
0038 enum constraint : std::size_t {
0039 e_accuracy = 0u,
0040 e_actor = 1u,
0041 e_aborter = 2u,
0042 e_user = 3u,
0043 e_all = 4u
0044 };
0045
0046 }
0047
0048
0049 template <concepts::scalar scalar_t>
0050 struct unconstrained_step {
0051
0052 template <step::constraint type>
0053 DETRAY_HOST_DEVICE constexpr void set(const scalar_t ) const {
0054
0055 }
0056
0057
0058 template <step::constraint type = step::constraint::e_all>
0059 DETRAY_HOST_DEVICE constexpr scalar_t size(
0060 const step::direction = step::direction::e_forward) const {
0061 return std::numeric_limits<scalar_t>::max();
0062 }
0063
0064
0065 template <step::constraint type = step::constraint::e_actor>
0066 DETRAY_HOST_DEVICE constexpr void release() const {
0067
0068 }
0069 };
0070
0071
0072
0073 template <concepts::scalar scalar_t>
0074 struct constrained_step {
0075
0076 template <step::constraint type>
0077 requires(type != step::constraint::e_all)
0078 DETRAY_HOST_DEVICE void set(const scalar_t step_size) {
0079 _constraints[type] = math::min(_constraints[type], math::fabs(step_size));
0080 }
0081
0082
0083 template <step::constraint type = step::constraint::e_all>
0084 DETRAY_HOST_DEVICE scalar_t
0085 size(const step::direction dir = step::direction::e_forward) const {
0086 if constexpr (type == step::constraint::e_all) {
0087 return static_cast<scalar_t>(dir) * min();
0088 } else {
0089 return static_cast<scalar_t>(dir) * _constraints[type];
0090 }
0091 }
0092
0093
0094 template <step::constraint type = step::constraint::e_actor>
0095 DETRAY_HOST_DEVICE void release() {
0096 if constexpr (type == step::constraint::e_all) {
0097 _constraints = {std::numeric_limits<scalar_t>::max(),
0098 std::numeric_limits<scalar_t>::max(),
0099 std::numeric_limits<scalar_t>::max(),
0100 std::numeric_limits<scalar_t>::max()};
0101 } else {
0102 _constraints[type] = std::numeric_limits<scalar_t>::max();
0103 }
0104 }
0105
0106
0107 DETRAY_HOST_DEVICE scalar_t min() const {
0108 scalar_t min_constr = std::numeric_limits<scalar_t>::max();
0109 min_constr =
0110 math::min(min_constr, _constraints[step::constraint::e_accuracy]);
0111 min_constr = math::min(min_constr, _constraints[step::constraint::e_actor]);
0112 min_constr =
0113 math::min(min_constr, _constraints[step::constraint::e_aborter]);
0114 return math::min(min_constr, _constraints[step::constraint::e_user]);
0115 }
0116
0117
0118 darray<scalar_t, 4> _constraints = {std::numeric_limits<scalar_t>::max(),
0119 std::numeric_limits<scalar_t>::max(),
0120 std::numeric_limits<scalar_t>::max(),
0121 std::numeric_limits<scalar_t>::max()};
0122 };
0123
0124 }