File indexing completed on 2025-12-05 09:59:47
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "celeritas/Types.hh"
0012 #include "celeritas/global/CoreTrackView.hh"
0013 #include "celeritas/mat/MaterialTrackView.hh"
0014 #include "celeritas/track/SimTrackView.hh"
0015
0016 #include "../GeoMaterialView.hh"
0017 #include "../GeoTrackView.hh"
0018
0019 #if !CELER_DEVICE_COMPILE
0020 # include "corecel/io/Logger.hh"
0021 #endif
0022
0023 namespace celeritas
0024 {
0025 namespace detail
0026 {
0027
0028
0029
0030
0031
0032
0033
0034 struct BoundaryExecutor
0035 {
0036 inline CELER_FUNCTION void operator()(celeritas::CoreTrackView& track);
0037 };
0038
0039
0040 CELER_FUNCTION void
0041 BoundaryExecutor::operator()(celeritas::CoreTrackView& track)
0042 {
0043 CELER_EXPECT([track] {
0044 auto sim = track.sim();
0045 return sim.post_step_action() == track.boundary_action()
0046 && sim.status() == TrackStatus::alive;
0047 }());
0048
0049 auto geo = track.geometry();
0050 CELER_EXPECT(geo.is_on_boundary());
0051
0052
0053 geo.cross_boundary();
0054 if (CELER_UNLIKELY(geo.failed()))
0055 {
0056 track.apply_errored();
0057 return;
0058 }
0059 else if (!geo.is_outside())
0060 {
0061
0062 auto geo_mat = track.geo_material();
0063 auto matid = geo_mat.material_id(geo.volume_id());
0064 if (CELER_UNLIKELY(!matid))
0065 {
0066 #if !CELER_DEVICE_COMPILE
0067 CELER_LOG_LOCAL(error)
0068 << R"(Track entered a volume without an associated material)";
0069 #endif
0070 track.apply_errored();
0071 return;
0072 }
0073 auto mat = track.material();
0074 mat = {matid};
0075
0076 CELER_ENSURE(geo.is_on_boundary());
0077 }
0078 else
0079 {
0080 auto sim = track.sim();
0081 sim.status(TrackStatus::killed);
0082 }
0083 }
0084
0085
0086 }
0087 }