File indexing completed on 2026-10-26 09:34:37
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/math/NumericLimits.hh"
0014 #include "corecel/random/Types.hh"
0015
0016 namespace celeritas
0017 {
0018
0019
0020
0021
0022 template<class DistributionRecord>
0023 struct TruncatedDistributionRecord
0024 {
0025 DistributionRecord distribution{};
0026 real_type lower{-numeric_limits<real_type>::infinity()};
0027 real_type upper{numeric_limits<real_type>::infinity()};
0028 };
0029
0030
0031
0032
0033
0034 template<class T>
0035 struct DeltaDistributionRecord
0036 {
0037 T value{};
0038 };
0039
0040
0041
0042
0043
0044 struct UniformRealDistributionRecord
0045 {
0046 real_type lower{};
0047 real_type upper{};
0048 };
0049
0050
0051
0052
0053
0054 struct NormalDistributionRecord
0055 {
0056 real_type mean{0};
0057 real_type stddev{1};
0058 };
0059
0060
0061
0062
0063
0064 struct IsotropicDistributionRecord
0065 {
0066 };
0067
0068
0069
0070
0071
0072 struct UniformBoxDistributionRecord
0073 {
0074 Real3 lower{0, 0, 0};
0075 Real3 upper{0, 0, 0};
0076 };
0077
0078
0079
0080
0081
0082 template<Ownership W, MemSpace M>
0083 struct DistributionParamsData
0084 {
0085
0086
0087 template<class T>
0088 using Items = Collection<T, W, M>;
0089 template<class T>
0090 using OnedDistributionItems = Collection<T, W, M, OnedDistributionId>;
0091 template<class T>
0092 using ThreedDistributionItems = Collection<T, W, M, ThreedDistributionId>;
0093
0094
0095
0096
0097 OnedDistributionItems<OnedDistributionType> oned_types;
0098 OnedDistributionItems<size_type> oned_indices;
0099
0100 Items<DeltaDistributionRecord<real_type>> delta_real;
0101 Items<NormalDistributionRecord> normal;
0102 Items<TruncatedDistributionRecord<NormalDistributionRecord>> truncated_normal;
0103
0104
0105 ThreedDistributionItems<ThreedDistributionType> threed_types;
0106 ThreedDistributionItems<size_type> threed_indices;
0107
0108 Items<DeltaDistributionRecord<Array<real_type, 3>>> delta_real3;
0109 Items<IsotropicDistributionRecord> isotropic;
0110 Items<UniformBoxDistributionRecord> uniform_box;
0111
0112
0113
0114
0115 explicit CELER_FUNCTION operator bool() const
0116 {
0117 return (!oned_types.empty() || !threed_types.empty())
0118 && oned_indices.size() == oned_types.size()
0119 && threed_indices.size() == threed_types.size();
0120 }
0121
0122
0123 template<Ownership W2, MemSpace M2>
0124 DistributionParamsData& operator=(
0125 DistributionParamsData<W2, M2> const& other)
0126 {
0127 CELER_EXPECT(other);
0128
0129 oned_types = other.oned_types;
0130 oned_indices = other.oned_indices;
0131 delta_real = other.delta_real;
0132 normal = other.normal;
0133 truncated_normal = other.truncated_normal;
0134
0135 threed_types = other.threed_types;
0136 threed_indices = other.threed_indices;
0137 delta_real3 = other.delta_real3;
0138 isotropic = other.isotropic;
0139 uniform_box = other.uniform_box;
0140
0141 CELER_ENSURE(static_cast<bool>(*this) == static_cast<bool>(other));
0142 return *this;
0143 }
0144 };
0145
0146
0147 }