19 #include <type_traits>
27 #include <CD_NamespaceHeader.H>
73 template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
82 template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
108 inline static RealVect
115 template <
typename T>
117 get(T& a_distribution);
123 template <
typename T>
152 inline static RealVect
153 randomPosition(
const RealVect a_lo,
const RealVect a_hi) noexcept;
167 inline static RealVect
171 const RealVect a_bndryCentroid,
172 const RealVect a_normal,
174 const Real a_kappa) noexcept;
184 inline static RealVect
187 const RealVect a_bndryCentroid,
188 const RealVect a_normal) noexcept;
194 static bool s_seeded;
199 static thread_local std::mt19937_64 s_rng;
204 static thread_local std::uniform_real_distribution<Real> s_uniform01;
209 static thread_local std::uniform_real_distribution<Real> s_uniform11;
214 static thread_local std::normal_distribution<Real> s_normal01;
217 #include <CD_NamespaceFooter.H>
Implementation of CD_Random.H.
Class for encapsulating random number generation. This class is MPI and OpenMP safe.
Definition: CD_Random.H:36
static Real get(T &a_distribution)
For getting a random number from a user-supplied distribution. T must be a distribution for which we ...
Definition: CD_RandomImplem.H:208
static void setRandomSeed()
Set a random RNG seed.
Definition: CD_RandomImplem.H:86
Random & operator=(const Random &&a_other)=delete
Disallowed move assignment.
static RealVect getDirection()
Get a random direction in space.
Definition: CD_RandomImplem.H:171
Random(const Random &a_other)=delete
Deleted copy constructor. Must be impossible because this is a singleton.
static Real getUniformReal11()
Get a uniform real number on the interval [-1,1].
Definition: CD_RandomImplem.H:155
Random(const Random &&a_other)=delete
Deleted copy constructor. Must be impossible because this is a singleton.
static size_t getDiscrete(T &a_distribution)
For getting a random number from a user-supplied distribution. T must be a distribution for which we ...
Definition: CD_RandomImplem.H:217
static Real getUniformReal01()
Get a uniform real number on the interval [0,1].
Definition: CD_RandomImplem.H:147
static Real getNormal01()
Get a number from a normal distribution centered on zero and variance 1.
Definition: CD_RandomImplem.H:163
static void seed()
Seed the RNG.
Definition: CD_RandomImplem.H:28
static void setSeed(const int a_seed)
Set the RNG seed.
Definition: CD_RandomImplem.H:52
static T getPoisson(const Real a_mean)
Get Poisson distributed number.
Definition: CD_RandomImplem.H:100
Random()=delete
Disallowed constructor.
Random & operator=(const Random &a_other)=delete
Disallowed copy assignment.
static T getBinomial(const T a_N, const Real a_p) noexcept
Get Poisson distributed number.
Definition: CD_RandomImplem.H:122
static RealVect randomPosition(const RealVect a_lo, const RealVect a_hi) noexcept
Return a random position in the cube (a_lo, a_hi);.
Definition: CD_RandomImplem.H:270