File indexing completed on 2025-12-02 10:06:29
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/cont/Range.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "corecel/data/CollectionBuilder.hh"
0014 #include "celeritas/Quantities.hh"
0015 #include "celeritas/Types.hh"
0016
0017 namespace celeritas
0018 {
0019
0020
0021
0022
0023
0024 struct AtomicRelaxTransition
0025 {
0026 SubshellId initial_shell;
0027 SubshellId auger_shell;
0028 real_type probability;
0029 units::MevEnergy energy;
0030 };
0031
0032
0033
0034
0035
0036 struct AtomicRelaxSubshell
0037 {
0038 ItemRange<AtomicRelaxTransition> transitions;
0039 };
0040
0041
0042
0043
0044
0045 struct AtomicRelaxElement
0046 {
0047 ItemRange<AtomicRelaxSubshell> shells;
0048 size_type max_secondary;
0049
0050
0051 explicit CELER_FUNCTION operator bool() const
0052 {
0053 return !shells.empty() && max_secondary > 0;
0054 }
0055 };
0056
0057 struct AtomicRelaxIds
0058 {
0059 ParticleId electron;
0060 ParticleId gamma;
0061
0062
0063 explicit CELER_FUNCTION operator bool() const { return electron && gamma; }
0064 };
0065
0066
0067
0068
0069
0070 template<Ownership W, MemSpace M>
0071 struct AtomicRelaxParamsData
0072 {
0073 template<class T>
0074 using Items = Collection<T, W, M>;
0075 template<class T>
0076 using ElementItems = Collection<T, W, M, ElementId>;
0077
0078
0079
0080 AtomicRelaxIds ids;
0081 Items<AtomicRelaxTransition> transitions;
0082 Items<AtomicRelaxSubshell> shells;
0083 ElementItems<AtomicRelaxElement> elements;
0084 size_type max_stack_size{};
0085
0086
0087
0088
0089 explicit CELER_FUNCTION operator bool() const
0090 {
0091 return ids && !transitions.empty() && !shells.empty()
0092 && !elements.empty() && max_stack_size > 0;
0093 }
0094
0095
0096 template<Ownership W2, MemSpace M2>
0097 AtomicRelaxParamsData& operator=(AtomicRelaxParamsData<W2, M2> const& other)
0098 {
0099 ids = other.ids;
0100 transitions = other.transitions;
0101 shells = other.shells;
0102 elements = other.elements;
0103 max_stack_size = other.max_stack_size;
0104 return *this;
0105 }
0106 };
0107
0108 using AtomicRelaxParamsRef = NativeCRef<AtomicRelaxParamsData>;
0109
0110
0111
0112
0113
0114 template<Ownership W, MemSpace M>
0115 struct AtomicRelaxStateData
0116 {
0117 template<class T>
0118 using Items = StateCollection<T, W, M>;
0119
0120
0121 Items<SubshellId> scratch;
0122 size_type num_states;
0123
0124
0125 explicit CELER_FUNCTION operator bool() const
0126 {
0127 return !scratch.empty() && num_states > 0;
0128 }
0129
0130
0131 CELER_FUNCTION size_type size() const { return num_states; }
0132
0133
0134 template<Ownership W2, MemSpace M2>
0135 AtomicRelaxStateData& operator=(AtomicRelaxStateData<W2, M2>& other)
0136 {
0137 scratch = other.scratch;
0138 num_states = other.num_states;
0139 return *this;
0140 }
0141 };
0142
0143 using AtomicRelaxStateRef = NativeRef<AtomicRelaxStateData>;
0144
0145
0146
0147
0148
0149 template<MemSpace M>
0150 inline void resize(AtomicRelaxStateData<Ownership::value, M>* state,
0151 HostCRef<AtomicRelaxParamsData> const& params,
0152 size_type size)
0153 {
0154 CELER_EXPECT(size > 0);
0155 resize(&state->scratch, size * params.max_stack_size);
0156 state->num_states = size;
0157 }
0158
0159
0160 }