File indexing completed on 2025-09-14 08:50:58
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <cmath>
0010
0011 #include "corecel/Assert.hh"
0012 #include "corecel/Macros.hh"
0013 #include "corecel/Types.hh"
0014
0015 #include "GenerateCanonical.hh"
0016
0017 namespace celeritas
0018 {
0019
0020
0021
0022
0023 template<class RealType = ::celeritas::real_type>
0024 class RadialDistribution
0025 {
0026 public:
0027
0028
0029 using real_type = RealType;
0030 using result_type = real_type;
0031
0032
0033 public:
0034
0035 explicit inline CELER_FUNCTION RadialDistribution(real_type radius);
0036
0037
0038 template<class Generator>
0039 inline CELER_FUNCTION result_type operator()(Generator& rng);
0040
0041
0042
0043
0044 inline CELER_FUNCTION real_type radius() const { return radius_; }
0045
0046 private:
0047 RealType radius_;
0048 };
0049
0050
0051
0052
0053
0054
0055
0056 template<class RealType>
0057 CELER_FUNCTION
0058 RadialDistribution<RealType>::RadialDistribution(real_type radius)
0059 : radius_(radius)
0060 {
0061 CELER_EXPECT(radius_ > 0);
0062 }
0063
0064
0065
0066
0067
0068 template<class RealType>
0069 template<class Generator>
0070 CELER_FUNCTION auto
0071 RadialDistribution<RealType>::operator()(Generator& rng) -> result_type
0072 {
0073 return std::cbrt(generate_canonical<RealType>(rng)) * radius_;
0074 }
0075
0076 }