File indexing completed on 2026-09-15 09:05:02
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/math/Algorithms.hh"
0010 #include "geocel/Types.hh"
0011
0012 namespace celeritas
0013 {
0014
0015
0016
0017
0018 template<class GTV>
0019 class LinearPropagator
0020 {
0021 public:
0022
0023
0024 using result_type = Propagation;
0025
0026
0027 public:
0028
0029 CELER_FUNCTION LinearPropagator(GTV&& track)
0030 : geo_(::celeritas::forward<GTV>(track))
0031 {
0032 }
0033
0034
0035 inline CELER_FUNCTION result_type operator()();
0036
0037
0038 inline CELER_FUNCTION result_type operator()(real_type dist);
0039
0040
0041 static CELER_CONSTEXPR_FUNCTION bool tracks_can_loop() { return false; }
0042
0043 private:
0044 GTV geo_;
0045 };
0046
0047
0048
0049
0050 template<class GTV>
0051 CELER_FUNCTION LinearPropagator(GTV&&) -> LinearPropagator<GTV>;
0052
0053
0054
0055
0056
0057 template<class GTV>
0058 CELER_FUNCTION auto LinearPropagator<GTV>::operator()() -> result_type
0059 {
0060 CELER_EXPECT(!geo_.is_outside());
0061
0062 result_type result = geo_.find_next_step();
0063 CELER_ASSERT(result.boundary);
0064 geo_.move_to_boundary();
0065
0066 return result;
0067 }
0068
0069
0070
0071
0072
0073 template<class GTV>
0074 CELER_FUNCTION auto LinearPropagator<GTV>::operator()(real_type dist)
0075 -> result_type
0076 {
0077 CELER_EXPECT(dist > 0);
0078
0079 result_type result = geo_.find_next_step(dist);
0080
0081 if (result.boundary)
0082 {
0083 geo_.move_to_boundary();
0084 }
0085 else
0086 {
0087 CELER_ASSERT(dist == result.distance);
0088 geo_.move_internal(dist);
0089 }
0090
0091 return result;
0092 }
0093
0094
0095 }