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