File indexing completed on 2025-02-22 10:31:28
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <vector>
0011
0012 #include "corecel/Macros.hh"
0013 #include "corecel/Types.hh"
0014 #include "corecel/data/Collection.hh"
0015 #include "corecel/data/CollectionAlgorithms.hh"
0016 #include "corecel/data/CollectionBuilder.hh"
0017 #include "celeritas/Quantities.hh"
0018 #include "celeritas/Types.hh"
0019
0020 namespace celeritas
0021 {
0022 namespace optical
0023 {
0024
0025
0026
0027
0028 template<Ownership W, MemSpace M>
0029 struct SimStateData
0030 {
0031
0032
0033 template<class T>
0034 using Items = celeritas::StateCollection<T, W, M>;
0035
0036
0037
0038 Items<real_type> time;
0039 Items<real_type> step_length;
0040 Items<TrackStatus> status;
0041 Items<ActionId> post_step_action;
0042
0043
0044
0045
0046 explicit CELER_FUNCTION operator bool() const
0047 {
0048 return !time.empty() && !step_length.empty() && !status.empty()
0049 && !post_step_action.empty();
0050 }
0051
0052
0053 CELER_FUNCTION size_type size() const { return status.size(); }
0054
0055
0056 template<Ownership W2, MemSpace M2>
0057 SimStateData& operator=(SimStateData<W2, M2>& other)
0058 {
0059 CELER_EXPECT(other);
0060 time = other.time;
0061 step_length = other.step_length;
0062 status = other.status;
0063 post_step_action = other.post_step_action;
0064 return *this;
0065 }
0066 };
0067
0068
0069
0070
0071
0072 template<MemSpace M>
0073 inline void resize(SimStateData<Ownership::value, M>* data, size_type size)
0074 {
0075 CELER_EXPECT(size > 0);
0076
0077 resize(&data->time, size);
0078 resize(&data->step_length, size);
0079
0080 resize(&data->status, size);
0081 fill(TrackStatus::inactive, &data->status);
0082
0083 resize(&data->post_step_action, size);
0084
0085 CELER_ENSURE(*data);
0086 }
0087
0088
0089 }
0090 }