File indexing completed on 2025-01-18 09:59:34
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Macros.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/cont/Array.hh"
0013 #include "corecel/data/Collection.hh"
0014 #include "corecel/data/CollectionBuilder.hh"
0015 #include "corecel/sys/ThreadId.hh"
0016 #include "geocel/Types.hh"
0017
0018 #include "detail/VecgeomNavCollection.hh"
0019 #include "detail/VecgeomTraits.hh"
0020
0021 namespace celeritas
0022 {
0023
0024
0025
0026
0027
0028
0029 template<Ownership W, MemSpace M>
0030 struct VecgeomParamsData
0031 {
0032 using PlacedVolumeT = typename detail::VecgeomTraits<M>::PlacedVolume;
0033
0034 PlacedVolumeT const* world_volume = nullptr;
0035 int max_depth = 0;
0036
0037
0038 explicit CELER_FUNCTION operator bool() const
0039 {
0040 return world_volume != nullptr && max_depth > 0;
0041 }
0042
0043
0044 template<Ownership W2, MemSpace M2>
0045 VecgeomParamsData& operator=(VecgeomParamsData<W2, M2>& other)
0046 {
0047 static_assert(M2 == M && W2 == Ownership::value
0048 && W == Ownership::reference,
0049 "Only supported assignment is from value to reference");
0050 CELER_EXPECT(other);
0051 world_volume = other.world_volume;
0052 max_depth = other.max_depth;
0053 return *this;
0054 }
0055 };
0056
0057
0058
0059
0060
0061
0062
0063 template<Ownership W, MemSpace M>
0064 struct VecgeomStateData
0065 {
0066
0067
0068 template<class T>
0069 using Items = celeritas::StateCollection<T, W, M>;
0070
0071
0072
0073
0074 Items<Real3> pos;
0075 Items<Real3> dir;
0076
0077
0078 detail::VecgeomNavCollection<W, M> vgstate;
0079 detail::VecgeomNavCollection<W, M> vgnext;
0080
0081
0082
0083
0084 explicit CELER_FUNCTION operator bool() const
0085 {
0086 return this->size() > 0 && dir.size() == this->size() && vgstate
0087 && vgnext;
0088 }
0089
0090
0091 CELER_FUNCTION TrackSlotId::size_type size() const { return pos.size(); }
0092
0093
0094 template<Ownership W2, MemSpace M2>
0095 VecgeomStateData& operator=(VecgeomStateData<W2, M2>& other)
0096 {
0097 static_assert(M2 == M && W == Ownership::reference,
0098 "Only supported assignment is from the same memspace to "
0099 "a reference");
0100 CELER_EXPECT(other);
0101 pos = other.pos;
0102 dir = other.dir;
0103 vgstate = other.vgstate;
0104 vgnext = other.vgnext;
0105 return *this;
0106 }
0107 };
0108
0109
0110
0111
0112
0113 template<MemSpace M>
0114 void resize(VecgeomStateData<Ownership::value, M>* data,
0115 HostCRef<VecgeomParamsData> const& params,
0116 size_type size)
0117 {
0118 CELER_EXPECT(data);
0119 CELER_EXPECT(size > 0);
0120 CELER_EXPECT(params.max_depth > 0);
0121
0122 resize(&data->pos, size);
0123 resize(&data->dir, size);
0124 data->vgstate.resize(params.max_depth, size);
0125 data->vgnext.resize(params.max_depth, size);
0126
0127 CELER_ENSURE(data);
0128 }
0129
0130
0131 }