File indexing completed on 2025-09-17 08:53:44
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Macros.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/data/CollectionBuilder.hh"
0013 #include "corecel/grid/NonuniformGridData.hh"
0014 #include "celeritas/Types.hh"
0015
0016 #include "Types.hh"
0017
0018 namespace celeritas
0019 {
0020 namespace optical
0021 {
0022
0023
0024
0025
0026 using ValueGrid = NonuniformGridRecord;
0027 using ValueGridId = OpaqueId<ValueGrid>;
0028
0029
0030
0031
0032
0033 struct PhysicsParamsScalars
0034 {
0035
0036 ModelId::size_type num_models{};
0037
0038
0039 OptMatId::size_type num_materials{};
0040
0041
0042 ActionId::size_type model_to_action{};
0043
0044
0045 explicit CELER_FUNCTION operator bool() const
0046 {
0047 return num_models > 0 && num_materials > 0 && model_to_action >= 1;
0048 }
0049
0050
0051 CELER_FORCEINLINE_FUNCTION ActionId discrete_action() const
0052 {
0053 return ActionId{model_to_action - 1};
0054 }
0055 };
0056
0057
0058
0059
0060
0061 template<Ownership W, MemSpace M>
0062 struct PhysicsParamsData
0063 {
0064
0065
0066 template<class T>
0067 using Items = Collection<T, W, M>;
0068
0069 template<class T>
0070 using ModelItems = Collection<T, W, M, ModelId>;
0071
0072
0073
0074 PhysicsParamsScalars scalars;
0075
0076
0077 Items<ValueGrid> grids;
0078
0079
0080 Items<real_type> reals;
0081
0082
0083 explicit CELER_FUNCTION operator bool() const
0084 {
0085 return static_cast<bool>(scalars) && !grids.empty() && !reals.empty();
0086 }
0087
0088
0089 template<Ownership W2, MemSpace M2>
0090 PhysicsParamsData<W, M>& operator=(PhysicsParamsData<W2, M2> const& other)
0091 {
0092 CELER_EXPECT(other);
0093 this->scalars = other.scalars;
0094 this->grids = other.grids;
0095 this->reals = other.reals;
0096 return *this;
0097 }
0098 };
0099
0100
0101
0102
0103
0104 template<Ownership W, MemSpace M>
0105 struct PhysicsStateData
0106 {
0107
0108
0109 template<class T>
0110 using Items = Collection<T, W, M>;
0111 template<class T>
0112 using StateItems = StateCollection<T, W, M>;
0113
0114
0115
0116
0117 StateItems<real_type> interaction_mfp;
0118
0119
0120
0121 StateItems<real_type> macro_xs;
0122
0123
0124
0125
0126 explicit CELER_FUNCTION operator bool() const
0127 {
0128 return !interaction_mfp.empty();
0129 }
0130
0131
0132 CELER_FUNCTION size_type size() const { return interaction_mfp.size(); }
0133
0134
0135 template<Ownership W2, MemSpace M2>
0136 PhysicsStateData<W, M>& operator=(PhysicsStateData<W2, M2>& other)
0137 {
0138 CELER_EXPECT(other);
0139 interaction_mfp = other.interaction_mfp;
0140 macro_xs = other.macro_xs;
0141 return *this;
0142 }
0143 };
0144
0145
0146
0147
0148
0149 template<MemSpace M>
0150 inline void resize(PhysicsStateData<Ownership::value, M>* state, size_type size)
0151 {
0152 CELER_EXPECT(state);
0153 CELER_EXPECT(size > 0);
0154
0155 resize(&state->interaction_mfp, size);
0156 resize(&state->macro_xs, size);
0157
0158 CELER_ENSURE(*state);
0159 }
0160
0161
0162 }
0163 }