File indexing completed on 2025-10-28 08:39:02
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/math/Atomics.hh"
0012 #include "celeritas/global/CoreTrackView.hh"
0013
0014 #include "../ParticleTallyData.hh"
0015
0016 namespace celeritas
0017 {
0018 namespace detail
0019 {
0020
0021
0022
0023
0024 struct ActionDiagnosticCondition
0025 {
0026 CELER_FUNCTION bool operator()(SimTrackView const& sim) const
0027 {
0028 return sim.status() != TrackStatus::inactive;
0029 }
0030 };
0031
0032
0033
0034
0035
0036 struct ActionDiagnosticExecutor
0037 {
0038 inline CELER_FUNCTION void
0039 operator()(celeritas::CoreTrackView const& track);
0040
0041 NativeCRef<ParticleTallyParamsData> const params;
0042 NativeRef<ParticleTallyStateData> const state;
0043 };
0044
0045
0046 CELER_FUNCTION void
0047 ActionDiagnosticExecutor::operator()(CoreTrackView const& track)
0048 {
0049 CELER_EXPECT(params);
0050 CELER_EXPECT(state);
0051
0052 using BinId = ItemId<size_type>;
0053
0054 auto action = track.sim().post_step_action();
0055 CELER_ASSERT(action);
0056 auto particle = track.particle().particle_id();
0057 CELER_ASSERT(particle);
0058
0059 BinId bin{particle.unchecked_get() * params.num_bins
0060 + action.unchecked_get()};
0061 CELER_ASSERT(bin < state.counts.size());
0062 celeritas::atomic_add(&state.counts[bin], size_type(1));
0063 }
0064
0065
0066 }
0067 }