Random number generator. More...
Classes | |
class | seed |
Seed class. More... | |
Public Member Functions | |
randomGenerator (const seed s, const bool global=false) | |
Construct from a seed. More... | |
randomGenerator (const randomGenerator &) | |
Copy construct. More... | |
randomGenerator (randomGenerator &&) | |
Move construct. More... | |
randomGenerator (Istream &is, const bool global=false) | |
Construct from a stream. More... | |
randomGenerator (const word &name, const dictionary &dict, randomGenerator &&defaultRndGen) | |
Construct from a dictionary. More... | |
randomGenerator (const word &name, const dictionary &dict, const seed defaultS, const bool global=false) | |
Construct from a dictionary. More... | |
~randomGenerator () | |
Destructor. More... | |
scalar | scalar01 () |
Return a scalar uniformly distributed between zero and one. More... | |
tmp< scalarField > | scalar01 (const label n) |
Return scalars uniformly distributed between zero and one. More... | |
scalar | scalarAB (const scalar a, const scalar b) |
Return a scalar uniformly distributed between two limits. More... | |
tmp< scalarField > | scalarAB (const label n, const scalar a, const scalar b) |
Return scalars uniformly distributed between two limits. More... | |
template<class Type > | |
Type | sample01 () |
Return a type with components uniformly distributed between. More... | |
template<class Type > | |
tmp< Field< Type > > | sample01 (const label n) |
Return types with components uniformly distributed between zero. More... | |
template<class Type > | |
Type | sampleAB (const Type &a, const Type &b) |
Return a type with components uniformly distributed between two. More... | |
template<class Type > | |
tmp< Field< Type > > | sampleAB (const label n, const Type &a, const Type &b) |
Return types with components uniformly distributed between two. More... | |
template<class Container > | |
void | permute (Container &l) |
Randomly permute a list. More... | |
randomGenerator | generator () |
Create a randomly seeded generator. More... | |
void | operator= (const randomGenerator &) |
Copy-assignment. More... | |
void | operator= (randomGenerator &&) |
Move-assignment. More... | |
template<> | |
scalar | sample01NoCheckSync () |
template<> | |
scalar | sampleABNoCheckSync (const scalar &a, const scalar &b) |
template<> | |
label | sampleABNoCheckSync (const label &a, const label &b) |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | sample01 (const label n) |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | sampleAB (const label n, const Type &a, const Type &b) |
Friends | |
Istream & | operator>> (Istream &, randomGenerator &) |
Read from stream. More... | |
Ostream & | operator<< (Ostream &, const randomGenerator &) |
Write to stream. More... | |
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.
Definition at line 67 of file randomGenerator.H.
|
inline |
Construct from a seed.
Definition at line 152 of file randomGeneratorI.H.
|
inline |
Copy construct.
Definition at line 161 of file randomGeneratorI.H.
|
inline |
Move construct.
Definition at line 170 of file randomGeneratorI.H.
randomGenerator | ( | Istream & | is, |
const bool | global = false |
||
) |
Construct from a stream.
Definition at line 31 of file randomGenerator.C.
randomGenerator | ( | const word & | name, |
const dictionary & | dict, | ||
randomGenerator && | defaultRndGen | ||
) |
Construct from a dictionary.
Definition at line 40 of file randomGenerator.C.
randomGenerator | ( | const word & | name, |
const dictionary & | dict, | ||
const seed | defaultS, | ||
const bool | global = false |
||
) |
Construct from a dictionary.
Definition at line 59 of file randomGenerator.C.
|
inline |
Destructor.
Definition at line 178 of file randomGeneratorI.H.
|
inline |
Return a scalar uniformly distributed between zero and one.
Definition at line 184 of file randomGeneratorI.H.
Referenced by BrownianMotionForce< CloudType >::calcCoupled(), LarsenBorgnakkeVariableHardSphere< CloudType >::collide(), VariableHardSphere< CloudType >::collide(), MaxwellianThermal< CloudType >::correct(), MixedDiffuseSpecular< CloudType >::correct(), DSMCCloud< ParcelType >::DSMCCloud(), FreeStream< CloudType >::inflow(), ConeInjection< CloudType >::setProperties(), and StochasticDispersionRAS< CloudType >::update().
|
inline |
Return scalars uniformly distributed between zero and one.
Definition at line 194 of file randomGeneratorI.H.
References n, and tmp< T >::ref().
|
inline |
Return a scalar uniformly distributed between two limits.
Definition at line 212 of file randomGeneratorI.H.
References b.
|
inline |
Return scalars uniformly distributed between two limits.
Definition at line 226 of file randomGeneratorI.H.
References b, n, and tmp< T >::ref().
|
inline |
Return a type with components uniformly distributed between.
zero and one
Definition at line 247 of file randomGeneratorI.H.
Referenced by polygonTriangulate::randomPolygon(), and SHF< CloudType >::update().
Return types with components uniformly distributed between zero.
and one
|
inline |
Return a type with components uniformly distributed between two.
limits
Definition at line 277 of file randomGeneratorI.H.
References b.
Referenced by randomRenumber::renumber(), MomentumLookupTableInjection< CloudType >::setPositionAndCell(), ReactingLookupTableInjection< CloudType >::setPositionAndCell(), ReactingMultiphaseLookupTableInjection< CloudType >::setPositionAndCell(), and ThermoLookupTableInjection< CloudType >::setPositionAndCell().
Return types with components uniformly distributed between two.
limits
|
inline |
Randomly permute a list.
Definition at line 309 of file randomGeneratorI.H.
References Foam::Swap().
|
inline |
Create a randomly seeded generator.
Definition at line 322 of file randomGeneratorI.H.
void operator= | ( | const randomGenerator & | rndGen | ) |
Copy-assignment.
Definition at line 73 of file randomGenerator.C.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and rndGen().
void operator= | ( | randomGenerator && | rndGen | ) |
Move-assignment.
Definition at line 88 of file randomGenerator.C.
References rndGen().
|
inline |
Definition at line 92 of file randomGeneratorI.H.
|
inline |
Definition at line 117 of file randomGeneratorI.H.
References b.
|
inline |
Definition at line 128 of file randomGeneratorI.H.
References b.
|
inline |
Definition at line 258 of file randomGeneratorI.H.
References n, and tmp< T >::ref().
|
inline |
Definition at line 288 of file randomGeneratorI.H.
References b, n, and tmp< T >::ref().
|
friend |
Read from stream.
|
friend |
Write to stream.