File indexing completed on 2026-11-04 10:04:36
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010 #include <vector>
0011 #include <VecGeom/base/Config.h>
0012 #include <VecGeom/navigation/NavStatePath.h>
0013
0014 #include "corecel/Assert.hh"
0015 #include "corecel/Types.hh"
0016 #include "corecel/cont/Span.hh"
0017 #include "corecel/sys/ThreadId.hh"
0018 #include "geocel/vg/VecgeomTypes.hh"
0019
0020 #if CELER_VGNAV != CELER_VGNAV_PATH
0021 # error \
0022 "This file can only be included when using VecGeom built with VecGeom_NAV=path"
0023 #endif
0024
0025 namespace celeritas
0026 {
0027 namespace detail
0028 {
0029 using UPVgPathState = std::unique_ptr<vecgeom::NavStatePath>;
0030
0031
0032
0033
0034
0035
0036
0037
0038 template<Ownership W, MemSpace M>
0039 struct VecgeomNavCollection
0040 {
0041 explicit operator bool() const { return false; }
0042 size_type size() const { return 0; }
0043
0044 template<Ownership W2, MemSpace M2>
0045 VecgeomNavCollection& operator=(VecgeomNavCollection<W2, M2>&)
0046 {
0047 CELER_ASSERT_UNREACHABLE();
0048 }
0049 };
0050
0051
0052
0053
0054
0055
0056
0057 template<>
0058 struct VecgeomNavCollection<Ownership::value, MemSpace::host>
0059 {
0060 std::vector<UPVgPathState> nav_state;
0061
0062
0063 explicit operator bool() const { return !nav_state.empty(); }
0064
0065
0066 size_type size() const { return nav_state.size(); }
0067 };
0068
0069
0070
0071
0072
0073 template<>
0074 struct VecgeomNavCollection<Ownership::reference, MemSpace::host>
0075 {
0076 Span<UPVgPathState> nav_state;
0077
0078
0079 VecgeomNavCollection() = default;
0080 VecgeomNavCollection(VecgeomNavCollection const&) = default;
0081
0082
0083 VecgeomNavCollection& operator=(
0084 VecgeomNavCollection<Ownership::value, MemSpace::host>& other);
0085
0086 VecgeomNavCollection& operator=(VecgeomNavCollection const&) = default;
0087
0088
0089 vecgeom::NavStatePath& operator[](TrackSlotId tid) const
0090 {
0091 CELER_EXPECT(*this);
0092 CELER_EXPECT(tid < nav_state.size());
0093 return *nav_state[tid.unchecked_get()];
0094 }
0095
0096
0097 size_type size() const { return nav_state.size(); }
0098
0099
0100 explicit operator bool() const { return !nav_state.empty(); }
0101 };
0102
0103
0104
0105 void resize(VecgeomNavCollection<Ownership::value, MemSpace::host>* nav,
0106 size_type size);
0107
0108 inline void resize(VecgeomNavCollection<Ownership::value, MemSpace::device>*,
0109 size_type)
0110 {
0111 CELER_ASSERT_UNREACHABLE();
0112 }
0113
0114
0115 }
0116 }