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