File indexing completed on 2026-11-07 10:11:43
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Assert.hh"
0010 #include "corecel/OpaqueId.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "corecel/math/Atomics.hh"
0014 #include "corecel/sys/ThreadId.hh"
0015 #include "celeritas/global/CoreTrackData.hh"
0016 #include "celeritas/phys/ParticleView.hh"
0017
0018 #include "TrackInitData.hh"
0019
0020 namespace celeritas
0021 {
0022
0023
0024 struct IsNeutral
0025 {
0026 using ParamsPtr = CRefPtr<CoreParamsData, MemSpace::native>;
0027
0028 ParamsPtr params;
0029
0030 CELER_FUNCTION bool operator()(TrackInitializer const& ti) const
0031 {
0032 return ParticleView(params->particles, ti.particle.particle_id).charge()
0033 == zero_quantity();
0034 }
0035 };
0036
0037
0038
0039 CELER_FORCEINLINE_FUNCTION size_type index_before(size_type size, ThreadId tid)
0040 {
0041 CELER_EXPECT(tid.get() + 1 <= size);
0042 return size - tid.unchecked_get() - 1;
0043 }
0044
0045
0046
0047
0048
0049
0050
0051
0052 inline CELER_FUNCTION TrackId make_track_id(
0053 NativeCRef<TrackInitParamsData> const&,
0054 NativeRef<TrackInitStateData>& state,
0055 EventId event)
0056 {
0057 CELER_EXPECT(event < state.track_counters.size());
0058 auto result
0059 = atomic_add(&state.track_counters[event], TrackId::size_type{1});
0060 return TrackId{result};
0061 }
0062
0063
0064 }