File indexing completed on 2026-11-27 10:26:20
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Macros.hh"
0010 #include "celeritas/field/DormandPrinceIntegrator.hh"
0011 #include "celeritas/field/MakeMagFieldPropagator.hh"
0012 #include "celeritas/global/CoreTrackView.hh"
0013
0014 #if !CELER_DEVICE_COMPILE
0015 # include "corecel/io/Logger.hh"
0016 #endif
0017
0018 namespace celeritas
0019 {
0020 namespace detail
0021 {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 template<class Field>
0032 struct FieldTrackPropagator
0033 {
0034
0035
0036 using ParamsRef = typename Field::ParamsRef;
0037
0038
0039
0040 [[nodiscard]] CELER_FUNCTION Propagation operator()(
0041 CoreTrackView& track) const;
0042
0043
0044
0045 ParamsRef field;
0046 };
0047
0048
0049
0050
0051
0052
0053
0054 template<class Field>
0055 inline CELER_FUNCTION Propagation FieldTrackPropagator<Field>::operator()(
0056 CoreTrackView& track) const
0057 {
0058 auto sim = track.sim();
0059 auto propagator = make_mag_field_propagator<DormandPrinceIntegrator>(
0060 Field{field}, field.options, track.particle(), track.geometry());
0061
0062 Propagation p = propagator(sim.step_length());
0063
0064 sim.update_looping(p.looping);
0065 if (p.looping)
0066 {
0067 sim.step_length(p.distance);
0068 auto particle = track.particle();
0069 if (particle.is_stable()
0070 && sim.is_looping(particle.particle_id(), particle.energy()))
0071 {
0072 #if !CELER_DEVICE_COMPILE
0073 CELER_LOG_LOCAL(debug)
0074 << "Track " << track.track_slot_id().get()
0075 << " (pid=" << particle.particle_id().get()
0076 << ", E=" << particle.energy() << ") is looping after "
0077 << sim.num_looping_steps() << " steps";
0078 #endif
0079 track.apply_cut();
0080 }
0081 else
0082 {
0083 sim.post_step_action(track.propagation_limit_action());
0084 }
0085 }
0086 return p;
0087 }
0088
0089
0090 }
0091 }