File indexing completed on 2025-12-15 10:11:00
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/cont/Array.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "corecel/data/CollectionBuilder.hh"
0014 #include "celeritas/Types.hh"
0015
0016 namespace celeritas
0017 {
0018 namespace optical
0019 {
0020
0021
0022
0023
0024 template<Ownership W, MemSpace M>
0025 struct ParticleStateData
0026 {
0027
0028
0029 using Real3 = Array<real_type, 3>;
0030 template<class T>
0031 using Items = celeritas::StateCollection<T, W, M>;
0032
0033
0034
0035 Items<real_type> energy;
0036 Items<Real3> polarization;
0037
0038
0039
0040
0041 explicit CELER_FUNCTION operator bool() const
0042 {
0043 return !energy.empty() && !polarization.empty();
0044 }
0045
0046
0047 CELER_FUNCTION size_type size() const { return energy.size(); }
0048
0049
0050 template<Ownership W2, MemSpace M2>
0051 ParticleStateData& operator=(ParticleStateData<W2, M2>& other)
0052 {
0053 CELER_EXPECT(other);
0054 energy = other.energy;
0055 polarization = other.polarization;
0056 return *this;
0057 }
0058 };
0059
0060
0061
0062
0063
0064 template<MemSpace M>
0065 inline void resize(ParticleStateData<Ownership::value, M>* data, size_type size)
0066 {
0067 CELER_EXPECT(size > 0);
0068 resize(&data->energy, size);
0069 resize(&data->polarization, size);
0070 CELER_ENSURE(*data);
0071 }
0072
0073
0074 }
0075 }