chombo-discharge
|
Class for encapsulating random number generation. This class is MPI and OpenMP safe. More...
#include <CD_Random.H>
Public Member Functions | |
Random ()=delete | |
Disallowed constructor. | |
Random (const Random &a_other)=delete | |
Deleted copy constructor. Must be impossible because this is a singleton. More... | |
Random (const Random &&a_other)=delete | |
Deleted copy constructor. Must be impossible because this is a singleton. More... | |
Random & | operator= (const Random &a_other)=delete |
Disallowed copy assignment. More... | |
Random & | operator= (const Random &&a_other)=delete |
Disallowed move assignment. More... | |
Static Public Member Functions | |
template<typename T , typename = std::enable_if_t<std::is_integral<T>::value>> | |
static T | getPoisson (const Real a_mean) |
Get Poisson distributed number. More... | |
template<typename T , typename = std::enable_if_t<std::is_integral<T>::value>> | |
static T | getBinomial (const T a_N, const Real a_p) noexcept |
Get Poisson distributed number. More... | |
static Real | getUniformReal01 () |
Get a uniform real number on the interval [0,1]. | |
static Real | getUniformReal11 () |
Get a uniform real number on the interval [-1,1]. | |
static Real | getNormal01 () |
Get a number from a normal distribution centered on zero and variance 1. | |
static RealVect | getDirection () |
Get a random direction in space. More... | |
template<typename T > | |
static Real | get (T &a_distribution) |
For getting a random number from a user-supplied distribution. T must be a distribution for which we can call T(s_rng) More... | |
template<typename T > | |
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 can call T(s_rng) More... | |
static void | seed () |
Seed the RNG. | |
static void | setSeed (const int a_seed) |
Set the RNG seed. More... | |
static void | setRandomSeed () |
Set a random RNG seed. | |
static RealVect | randomPosition (const RealVect a_lo, const RealVect a_hi) noexcept |
Return a random position in the cube (a_lo, a_hi);. More... | |
static RealVect | randomPosition (const RealVect a_cellPos, const RealVect a_lo, const RealVect a_hi, const RealVect a_bndryCentroid, const RealVect a_normal, const Real a_dx, const Real a_kappa) noexcept |
Draw a random position physical somewhere in a grid cell. More... | |
static RealVect | randomPosition (const RealVect a_lo, const RealVect a_hi, const RealVect a_bndryCentroid, const RealVect a_normal) noexcept |
Draw a random position somewhere in a cut-cell. More... | |
Class for encapsulating random number generation. This class is MPI and OpenMP safe.
The user can specify a seed 's' where each MPI rank will initialize their RNG with seed 's + procID()'. Note that unless the user specifies Random.seed = <number> in the input script, the RNG will use a seed of '0 + procID()' for the various ranks. If the user specifies a <number> less than 0, a random seed will be used.
|
delete |
Deleted copy constructor. Must be impossible because this is a singleton.
[in] | a_other | Other RNG engine. |
|
delete |
Deleted copy constructor. Must be impossible because this is a singleton.
[in] | a_other | Other RNG engine. |
|
inlinestatic |
For getting a random number from a user-supplied distribution. T must be a distribution for which we can call T(s_rng)
[in] | a_distribution | Distribution. Must have object of type |
|
inlinestaticnoexcept |
Get Poisson distributed number.
[in] | a_N | Number of trials |
[in] | a_p | The usual success probability in binomial distributions |
|
inlinestatic |
Get a random direction in space.
Uses Marsaglia algorithm.
|
inlinestatic |
For getting a random number from a user-supplied distribution. T must be a distribution for which we can call T(s_rng)
[in] | a_distribution | Distribution. Must have object of type |
|
inlinestatic |
Get Poisson distributed number.
[in] | a_mean | Poisson mean value (inverse rate) |
Disallowed move assignment.
[in] | a_other | Other RNG engine. |
Disallowed copy assignment.
[in] | a_other | Other RNG engine. |
|
inlinestaticnoexcept |
Draw a random position physical somewhere in a grid cell.
This is the version that respects cut-cells – it will draw a position (through rejection sampling) such that the particle ends up on the correct side of the EB.
[in] | a_cellPos | Cell-center position. |
[in] | a_lo | Lower-left corner of volume that encloses the cut-cell. This is relative to the unit cell. |
[in] | a_hi | Upper-right corner of volume that encloses the cut-cell. This is relative to the unit cell. |
[in] | a_bndryCentroid | EB centroid position |
[in] | a_normal | EB normal (points into the fluid region) |
[in] | a_dx | Grid resolution |
[in] | a_kappa | Cell volume |
|
inlinestaticnoexcept |
Return a random position in the cube (a_lo, a_hi);.
[in] | a_lo | Lower-left corner |
[in] | a_hi | Upper-right corner |
|
inlinestaticnoexcept |
Draw a random position somewhere in a cut-cell.
[in] | a_lo | Lower-left corner of volume that encloses the cut-cell. This is relative to the unit cell. |
[in] | a_hi | Upper-right corner of volume that encloses the cut-cell. This is relative to the unit cell. |
[in] | a_bndryCentroid | EB centroid position |
[in] | a_normal | EB normal (points into the fluid region) |
|
inlinestatic |
Set the RNG seed.
If using MPI, the seed is set to a_seed + procID().
[in] | a_seed | Seed to use for RNG. |