Random number generator. More...
Public Member Functions | |
Random (const label s) | |
Construct from a seed. More... | |
~Random () | |
Destructor. More... | |
scalar | scalar01 () |
Advance the state and return a scalar sample from a uniform. More... | |
scalar | scalarAB (const scalar a, const scalar b) |
Advance the state and return a scalar sample from a uniform. More... | |
scalar | scalarNormal () |
Advance the state and return a scalar sample from a normal. More... | |
template<class Type > | |
Type | sample01 () |
Advance the state and return a sample of a given type from a. More... | |
template<class Type > | |
Type | sampleAB (const Type &a, const Type &b) |
Advance the state and return a sample of a given type from a. More... | |
template<class Type > | |
Type | sampleNormal () |
Advance the state and return a sample of a given type from a. More... | |
scalar | globalScalar01 () |
Advance the state and return a scalar sample from a uniform. More... | |
template<> | |
scalar | sample01 () |
template<> | |
label | sample01 () |
template<> | |
scalar | sampleAB (const scalar &a, const scalar &b) |
template<> | |
label | sampleAB (const label &a, const label &b) |
template<> | |
scalar | sampleNormal () |
template<> | |
Foam::scalar | sample01 () |
template<> | |
Foam::label | sample01 () |
template<> | |
Foam::scalar | sampleAB (const scalar &a, const scalar &b) |
template<> | |
Foam::label | sampleAB (const label &a, const label &b) |
template<> | |
Foam::scalar | sampleNormal () |
Random number generator.
This is a clone of the drand48 algorithm. This is significantly quicker than drand48, presumably due to the compiler inlining the sampling methods. It is also significantly quicker than the standard library linear congruential engine, as it does not use Schrage's algorithm to prevent overflow.
See http://pubs.opengroup.org/onlinepubs/007908775/xsh/drand48.html for details of the seeding and iteration sequence.
|
inline |
Advance the state and return a scalar sample from a uniform.
distribution between zero and one
Definition at line 57 of file RandomI.H.
Referenced by Foam::barycentric01(), Foam::barycentric2D01(), BrownianMotionForce< CloudType >::calcCoupled(), Random::globalScalar01(), conformalVoronoiMesh::maxSurfaceProtrusion(), Random::sample01(), Random::scalarAB(), Random::scalarNormal(), turbGen::U(), and StochasticDispersionRAS< CloudType >::update().
|
inline |
Advance the state and return a scalar sample from a uniform.
distribution between two limits
Definition at line 63 of file RandomI.H.
References Random::scalar01().
Referenced by uniform::sample(), Random::sampleAB(), patchInjectionBase::setPositionAndCell(), and ConeInjection< CloudType >::setProperties().
Foam::scalar scalarNormal | ( | ) |
Advance the state and return a scalar sample from a normal.
distribution with mean zero and standard deviation one
Definition at line 31 of file Random.C.
References f(), Foam::log(), Random::scalar01(), Foam::sqr(), and Foam::sqrt().
Referenced by BrownianMotionForce< CloudType >::calcCoupled(), Random::sampleNormal(), StochasticDispersionRAS< CloudType >::update(), and GradientDispersionRAS< CloudType >::update().
|
inline |
Advance the state and return a sample of a given type from a.
uniform distribution between zero and one
Definition at line 70 of file RandomI.H.
References Random::scalar01().
Referenced by Stochastic< CloudType >::calculate(), InflationInjection< CloudType >::parcelsToInject(), exponential::sample(), general::sample(), RosinRammler::sample(), normal::sample(), multiNormal::sample(), patchInjectionBase::setPositionAndCell(), ConeInjection< CloudType >::setProperties(), ConeNozzleInjection< CloudType >::setProperties(), turbGen::U(), SHF< CloudType >::update(), and Stochastic< CloudType >::~Stochastic().
|
inline |
Advance the state and return a sample of a given type from a.
uniform distribution between two limits
Definition at line 98 of file RandomI.H.
References Foam::cmptMultiply().
Referenced by InflationInjection< CloudType >::parcelsToInject(), randomRenumber::renumber(), ThermoLookupTableInjection< CloudType >::setPositionAndCell(), ReactingLookupTableInjection< CloudType >::setPositionAndCell(), ReactingMultiphaseLookupTableInjection< CloudType >::setPositionAndCell(), and KinematicLookupTableInjection< CloudType >::setPositionAndCell().
|
inline |
Advance the state and return a sample of a given type from a.
normal distribution with mean zero and standard deviation one
Definition at line 119 of file RandomI.H.
References Random::scalarNormal().
Foam::scalar globalScalar01 | ( | ) |
Advance the state and return a scalar sample from a uniform.
distribution between zero and one. Synchronises across all cores. Use of this is discouraged. It is expensive and introduces non-randomness in all cores other then the master.
Definition at line 94 of file Random.C.
References UPstream::master(), Random::scalar01(), and Pstream::scatter().
Referenced by PatchInjection< CloudType >::parcelsToInject(), PatchFlowRateInjection< CloudType >::parcelsToInject(), patchInjectionBase::setPositionAndCell(), and ConeNozzleInjection< CloudType >::setPositionAndCell().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 84 of file RandomI.H.
References Random::scalar01().
|
inline |
|
inline |
Definition at line 105 of file RandomI.H.
References Random::scalarAB().
|
inline |
|
inline |
Definition at line 133 of file RandomI.H.
References Random::scalarNormal().