File indexing completed on 2025-09-15 08:54:48
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Macros.hh"
0010 #include "corecel/data/Collection.hh"
0011 #include "corecel/data/CollectionBuilder.hh"
0012 #include "corecel/sys/ThreadId.hh"
0013 #include "celeritas/Quantities.hh"
0014 #include "celeritas/Types.hh"
0015
0016 namespace celeritas
0017 {
0018
0019
0020
0021
0022 enum class MatterType : char
0023 {
0024 particle,
0025 antiparticle
0026 };
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 template<Ownership W, MemSpace M>
0041 struct ParticleParamsData
0042 {
0043
0044
0045 template<class T>
0046 using Items = Collection<T, W, M, ParticleId>;
0047
0048
0049
0050 Items<units::MevMass> mass;
0051 Items<units::ElementaryCharge> charge;
0052 Items<real_type> decay_constant;
0053 Items<MatterType> matter;
0054
0055
0056
0057
0058 explicit CELER_FUNCTION operator bool() const
0059 {
0060 return !mass.empty() && !charge.empty() && !decay_constant.empty()
0061 && !matter.empty();
0062 }
0063
0064
0065 CELER_FUNCTION ParticleId::size_type size() const
0066 {
0067 return decay_constant.size();
0068 }
0069
0070
0071 template<Ownership W2, MemSpace M2>
0072 ParticleParamsData& operator=(ParticleParamsData<W2, M2> const& other)
0073 {
0074 CELER_EXPECT(other);
0075 mass = other.mass;
0076 charge = other.charge;
0077 decay_constant = other.decay_constant;
0078 matter = other.matter;
0079 return *this;
0080 }
0081 };
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 struct ParticleTrackInitializer
0100 {
0101 ParticleId particle_id;
0102 units::MevEnergy energy;
0103
0104
0105 explicit CELER_FUNCTION operator bool() const
0106 {
0107 return particle_id && energy > zero_quantity();
0108 }
0109 };
0110
0111
0112
0113
0114
0115
0116
0117 template<Ownership W, MemSpace M>
0118 struct ParticleStateData
0119 {
0120
0121
0122 template<class T>
0123 using Items = celeritas::StateCollection<T, W, M>;
0124
0125
0126
0127 Items<ParticleId> particle_id;
0128
0129 Items<real_type> particle_energy;
0130
0131
0132
0133
0134 explicit CELER_FUNCTION operator bool() const
0135 {
0136 return !particle_id.empty() && !particle_energy.empty();
0137 }
0138
0139
0140 CELER_FUNCTION TrackSlotId::size_type size() const
0141 {
0142 return particle_id.size();
0143 }
0144
0145
0146 template<Ownership W2, MemSpace M2>
0147 ParticleStateData& operator=(ParticleStateData<W2, M2>& other)
0148 {
0149 CELER_EXPECT(other);
0150 particle_id = other.particle_id;
0151 particle_energy = other.particle_energy;
0152 return *this;
0153 }
0154 };
0155
0156
0157
0158
0159
0160 template<MemSpace M>
0161 inline void resize(ParticleStateData<Ownership::value, M>* data,
0162 HostCRef<ParticleParamsData> const&,
0163 size_type size)
0164 {
0165 CELER_EXPECT(size > 0);
0166 resize(&data->particle_id, size);
0167 resize(&data->particle_energy, size);
0168 }
0169
0170
0171 }