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