Random number generator. More...
#include <Random.H>

Classes | |
| class | uniformGeneratorOp |
| A generator class returning a uniformly distributed random number on the given interval. More... | |
| class | gaussianGeneratorOp |
| A generator class returning a gaussian distributed random number. More... | |
Public Member Functions | |
| Random (const label seedValue=defaultSeed) | |
| Construct with seed value. | |
| Random (const Random &rnd, const bool reset) | |
| Copy construct with possible reset of seed. | |
| label | seed () const |
| The initial random number seed that was used. | |
| void | reset (const label seedValue) |
| Reset the random number generator seed. | |
| int | bit () |
| Return a random bit. | |
| template<class Type> | |
| Type | sample01 () |
| Return a sample whose components lie in the range [0,1]. | |
| template<class Type> | |
| Type | GaussNormal () |
| Return a sample whose components are normally distributed with zero mean and unity variance N(0,1). | |
| template<class Type> | |
| Type | position (const Type &start, const Type &end) |
| Return a sample on the interval [start,end]. | |
| template<class Type> | |
| void | randomise01 (Type &value) |
| Randomise value in the range [0,1]. | |
| template<class Type> | |
| void | shuffle (UList< Type > &values) |
| Shuffle the values in the list. | |
| template<class Type> | |
| Type | globalSample01 () |
| Return a sample whose components lie in the range [0,1]. | |
| template<class Type> | |
| Type | globalGaussNormal () |
| Return a sample whose components are normally distributed with zero mean and unity variance N(0,1). | |
| template<class Type> | |
| Type | globalPosition (const Type &start, const Type &end) |
| Return a sample on the interval [start,end]. | |
| template<class Type> | |
| void | globalRandomise01 (Type &value) |
| Randomise value in the range 0-1. | |
| template<> | |
| Foam::scalar | sample01 () |
| template<> | |
| Foam::label | sample01 () |
| template<> | |
| Foam::scalar | GaussNormal () |
| template<> | |
| Foam::label | GaussNormal () |
| template<> | |
| Foam::scalar | position (const scalar &start, const scalar &end) |
| template<> | |
| Foam::label | position (const label &start, const label &end) |
| template<> | |
| Foam::scalar | globalSample01 () |
| template<> | |
| Foam::label | globalSample01 () |
| template<> | |
| Foam::scalar | globalGaussNormal () |
| template<> | |
| Foam::label | globalGaussNormal () |
| template<> | |
| Foam::scalar | globalPosition (const scalar &start, const scalar &end) |
| template<> | |
| Foam::label | globalPosition (const label &start, const label &end) |
| template<> | |
| scalar | sample01 () |
| template<> | |
| label | sample01 () |
| template<> | |
| scalar | GaussNormal () |
| template<> | |
| label | GaussNormal () |
| template<> | |
| scalar | position (const scalar &start, const scalar &end) |
| template<> | |
| label | position (const label &start, const label &end) |
| template<> | |
| scalar | globalSample01 () |
| template<> | |
| label | globalSample01 () |
| template<> | |
| scalar | globalGaussNormal () |
| template<> | |
| label | globalGaussNormal () |
| template<> | |
| scalar | globalPosition (const scalar &start, const scalar &end) |
| template<> | |
| label | globalPosition (const label &start, const label &end) |
Static Public Attributes | |
| static constexpr label | defaultSeed = 123456 |
| The default seed value (name may change in the future). | |
Random number generator.
|
explicit |
Construct with seed value.
Definition at line 26 of file Random.C.
Referenced by Random::gaussianGeneratorOp< T >::gaussianGeneratorOp(), Random(), Random::uniformGeneratorOp< T >::uniformGeneratorOp(), and Random::uniformGeneratorOp< T >::uniformGeneratorOp().

| Random | ( | const Random & | rnd, |
| const bool | reset ) |
|
inline |
The initial random number seed that was used.
Definition at line 37 of file RandomI.H.
Referenced by Random::gaussianGeneratorOp< T >::gaussianGeneratorOp(), Random::uniformGeneratorOp< T >::uniformGeneratorOp(), and Random::uniformGeneratorOp< T >::uniformGeneratorOp().

|
inline |
| Type sample01 | ( | ) |
Return a sample whose components lie in the range [0,1].
Definition at line 28 of file RandomTemplates.C.
Referenced by BrownianMotionForce< CloudType >::calcCoupled(), ConeInjection< CloudType >::ConeInjection(), globalRandomise01(), globalSample01(), InflationInjection< CloudType >::parcelsToInject(), triangulatedPatch::randomGlobalPoint(), randomise01(), PatchFlowRateInjection< CloudType >::setPositionAndCell(), ConeInjection< CloudType >::setProperties(), and StochasticDispersionRAS< CloudType >::update().

| Type GaussNormal | ( | ) |
Return a sample whose components are normally distributed with zero mean and unity variance N(0,1).
Definition at line 41 of file RandomTemplates.C.
References GaussNormal().
Referenced by BrownianMotionForce< CloudType >::calcCoupled(), GaussNormal(), globalGaussNormal(), GradientDispersionRAS< CloudType >::update(), and StochasticDispersionRAS< CloudType >::update().


| Type position | ( | const Type & | start, |
| const Type & | end ) |
Return a sample on the interval [start,end].
Definition at line 54 of file RandomTemplates.C.
Referenced by globalPosition(), globalPosition(), globalPosition(), InflationInjection< CloudType >::parcelsToInject(), triangulatedPatch::randomLocalPoint(), KinematicLookupTableInjection< CloudType >::setPositionAndCell(), PatchFlowRateInjection< CloudType >::setPositionAndCell(), ReactingLookupTableInjection< CloudType >::setPositionAndCell(), ReactingMultiphaseLookupTableInjection< CloudType >::setPositionAndCell(), ThermoLookupTableInjection< CloudType >::setPositionAndCell(), ConeInjection< CloudType >::setProperties(), and shuffle().

| void randomise01 | ( | Type & | value | ) |
Randomise value in the range [0,1].
Definition at line 68 of file RandomTemplates.C.
References sample01().

| void shuffle | ( | UList< Type > & | values | ) |
Shuffle the values in the list.
Definition at line 75 of file RandomTemplates.C.
References position(), and Foam::Swap().
Referenced by ConeInjection< CloudType >::setPositionAndCell().


| Type globalSample01 | ( | ) |
Return a sample whose components lie in the range [0,1].
Definition at line 86 of file RandomTemplates.C.
References UPstream::broadcast, UPstream::master(), sample01(), and Foam::Zero.
Referenced by patchInjectionBase::setPositionAndCell().


| Type globalGaussNormal | ( | ) |
Return a sample whose components are normally distributed with zero mean and unity variance N(0,1).
Definition at line 102 of file RandomTemplates.C.
References UPstream::broadcast, GaussNormal(), UPstream::master(), and Foam::Zero.

| Type globalPosition | ( | const Type & | start, |
| const Type & | end ) |
Return a sample on the interval [start,end].
Definition at line 118 of file RandomTemplates.C.
References UPstream::broadcast, UPstream::master(), position(), and Foam::Zero.
Referenced by InjectedParticleDistributionInjection< CloudType >::initialise(), PatchFlowRateInjection< CloudType >::parcelsToInject(), PatchInjection< CloudType >::parcelsToInject(), and InjectedParticleDistributionInjection< CloudType >::setPositionAndCell().


| void globalRandomise01 | ( | Type & | value | ) |
Randomise value in the range 0-1.
Definition at line 134 of file RandomTemplates.C.
References UPstream::broadcast, UPstream::master(), and sample01().

| Foam::scalar GaussNormal | ( | ) |
Definition at line 66 of file Random.C.
References Foam::log(), Foam::sqr(), and Foam::sqrt().

| Foam::label GaussNormal | ( | ) |
Definition at line 95 of file Random.C.
References GaussNormal().

| Foam::scalar position | ( | const scalar & | start, |
| const scalar & | end ) |
| Foam::label position | ( | const label & | start, |
| const label & | end ) |
Definition at line 113 of file Random.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::min(), and Foam::nl.

| Foam::scalar globalSample01 | ( | ) |
Definition at line 137 of file Random.C.
References UPstream::broadcast, and UPstream::master().

| Foam::label globalSample01 | ( | ) |
Definition at line 153 of file Random.C.
References UPstream::broadcast, and UPstream::master().

| Foam::scalar globalGaussNormal | ( | ) |
Definition at line 169 of file Random.C.
References UPstream::broadcast, GaussNormal(), and UPstream::master().

| Foam::label globalGaussNormal | ( | ) |
Definition at line 185 of file Random.C.
References UPstream::broadcast, GaussNormal(), and UPstream::master().

| Foam::scalar globalPosition | ( | const scalar & | start, |
| const scalar & | end ) |
Definition at line 201 of file Random.C.
References UPstream::broadcast, UPstream::master(), and position().

| Foam::label globalPosition | ( | const label & | start, |
| const label & | end ) |
Definition at line 221 of file Random.C.
References UPstream::broadcast, UPstream::master(), and position().

| scalar sample01 | ( | ) |
| label sample01 | ( | ) |
| scalar GaussNormal | ( | ) |
| label GaussNormal | ( | ) |
| scalar position | ( | const scalar & | start, |
| const scalar & | end ) |
| label position | ( | const label & | start, |
| const label & | end ) |
| scalar globalSample01 | ( | ) |
| label globalSample01 | ( | ) |
| scalar globalGaussNormal | ( | ) |
| label globalGaussNormal | ( | ) |
| scalar globalPosition | ( | const scalar & | start, |
| const scalar & | end ) |
| label globalPosition | ( | const label & | start, |
| const label & | end ) |
|
staticconstexpr |
The default seed value (name may change in the future).
Definition at line 105 of file Random.H.
Referenced by Random::gaussianGeneratorOp< T >::gaussianGeneratorOp(), Random::uniformGeneratorOp< T >::uniformGeneratorOp(), and Random::uniformGeneratorOp< T >::uniformGeneratorOp().