Random Class Reference

Random number generator. More...

Classes

class  gaussianGeneratorOp
 A generator class returning a gaussian distributed random number. More...
 
class  uniformGeneratorOp
 

Public Member Functions

 Random (const label seedValue=defaultSeed)
 Construct with seed value. More...
 
 Random (const Random &rnd, const bool reset)
 Copy construct with possible reset of seed. More...
 
label seed () const
 The initial random number seed that was used. More...
 
void reset (const label seedValue)
 Reset the random number generator seed. More...
 
int bit ()
 Return a random bit. More...
 
template<class Type >
Type sample01 ()
 Return a sample whose components lie in the range [0,1]. More...
 
template<class Type >
Type GaussNormal ()
 
template<class Type >
Type position (const Type &start, const Type &end)
 Return a sample on the interval [start,end]. More...
 
template<class Type >
void randomise01 (Type &value)
 Randomise value in the range [0,1]. More...
 
template<class Type >
void shuffle (UList< Type > &values)
 Shuffle the values in the list. More...
 
template<class Type >
Type globalSample01 ()
 Return a sample whose components lie in the range [0,1]. More...
 
template<class Type >
Type globalGaussNormal ()
 
template<class Type >
Type globalPosition (const Type &start, const Type &end)
 Return a sample on the interval [start,end]. More...
 
template<class Type >
void globalRandomise01 (Type &value)
 Randomise value in the range 0-1. More...
 
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) More...
 

Detailed Description

Random number generator.

Source files

Definition at line 59 of file Random.H.

Constructor & Destructor Documentation

◆ Random() [1/2]

Random ( const label  seedValue = defaultSeed)
explicit

Construct with seed value.

Definition at line 33 of file Random.C.

◆ Random() [2/2]

Random ( const Random rnd,
const bool  reset 
)

Copy construct with possible reset of seed.

Definition at line 43 of file Random.C.

References Random::reset(), and Rand48::seed().

Here is the call graph for this function:

Member Function Documentation

◆ seed()

Foam::label seed ( ) const
inline

The initial random number seed that was used.

Definition at line 44 of file RandomI.H.

◆ reset()

void reset ( const label  seedValue)
inline

Reset the random number generator seed.

Definition at line 50 of file RandomI.H.

Referenced by Random::Random().

Here is the caller graph for this function:

◆ bit()

int bit ( )
inline

Return a random bit.

Definition at line 38 of file RandomI.H.

◆ sample01() [1/5]

Type sample01 ( )

Return a sample whose components lie in the range [0,1].

Definition at line 36 of file RandomTemplates.C.

Referenced by BrownianMotionForce< CloudType >::calcCoupled(), ConeInjection< CloudType >::ConeInjection(), treeBoundBox::extend(), InflationInjection< CloudType >::parcelsToInject(), patchInjectionBase::setPositionAndCell(), ConeInjection< CloudType >::setProperties(), StochasticDispersionRAS< CloudType >::update(), and SHF< CloudType >::update().

Here is the caller graph for this function:

◆ GaussNormal() [1/5]

Type GaussNormal ( )

Return a sample whose components are normally distributed with zero mean and unity variance N(0,1)

Definition at line 49 of file RandomTemplates.C.

Referenced by BrownianMotionForce< CloudType >::calcCoupled(), StochasticDispersionRAS< CloudType >::update(), and GradientDispersionRAS< CloudType >::update().

Here is the caller graph for this function:

◆ position() [1/5]

Type position ( const Type &  start,
const Type &  end 
)

Return a sample on the interval [start,end].

Definition at line 62 of file RandomTemplates.C.

References stdFoam::end().

Referenced by InflationInjection< CloudType >::parcelsToInject(), randomRenumber::renumber(), massRosinRammler::sample(), patchInjectionBase::setPositionAndCell(), ReactingLookupTableInjection< CloudType >::setPositionAndCell(), ThermoLookupTableInjection< CloudType >::setPositionAndCell(), ReactingMultiphaseLookupTableInjection< CloudType >::setPositionAndCell(), KinematicLookupTableInjection< CloudType >::setPositionAndCell(), and ConeInjection< CloudType >::setProperties().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ randomise01()

void randomise01 ( Type &  value)

Randomise value in the range [0,1].

Definition at line 76 of file RandomTemplates.C.

◆ shuffle()

void shuffle ( UList< Type > &  values)

Shuffle the values in the list.

Definition at line 83 of file RandomTemplates.C.

References Foam::Swap(), and Foam::HashTableOps::values().

Referenced by eddy::eddy(), and ConeInjection< CloudType >::setPositionAndCell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ globalSample01() [1/5]

Type globalSample01 ( )

Return a sample whose components lie in the range [0,1].

Definition at line 94 of file RandomTemplates.C.

References UPstream::master(), and Pstream::scatter().

Referenced by patchInjectionBase::setPositionAndCell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ globalGaussNormal() [1/5]

Type globalGaussNormal ( )

Return a sample whose components are normally distributed with zero mean and unity variance N(0,1)

Definition at line 110 of file RandomTemplates.C.

References UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ globalPosition() [1/5]

Type globalPosition ( const Type &  start,
const Type &  end 
)

Return a sample on the interval [start,end].

Definition at line 126 of file RandomTemplates.C.

References stdFoam::end(), UPstream::master(), and Pstream::scatter().

Referenced by InjectedParticleDistributionInjection< CloudType >::initialise(), PatchFlowRateInjection< CloudType >::parcelsToInject(), PatchInjection< CloudType >::parcelsToInject(), and InjectedParticleDistributionInjection< CloudType >::setPositionAndCell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ globalRandomise01()

void globalRandomise01 ( Type &  value)

Randomise value in the range 0-1.

Definition at line 142 of file RandomTemplates.C.

References UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ sample01() [2/5]

Foam::scalar sample01 ( )

Definition at line 59 of file Random.C.

◆ sample01() [3/5]

Foam::label sample01 ( )

Definition at line 66 of file Random.C.

◆ GaussNormal() [2/5]

Foam::scalar GaussNormal ( )

Definition at line 73 of file Random.C.

References Foam::log(), Foam::sqr(), and Foam::sqrt().

Here is the call graph for this function:

◆ GaussNormal() [3/5]

Foam::label GaussNormal ( )

Definition at line 102 of file Random.C.

◆ position() [2/5]

Foam::scalar position ( const scalar &  start,
const scalar &  end 
)

Definition at line 110 of file Random.C.

References stdFoam::end().

Here is the call graph for this function:

◆ position() [3/5]

Foam::label position ( const label &  start,
const label &  end 
)

Definition at line 120 of file Random.C.

References Foam::abort(), stdFoam::end(), Foam::FatalError, FatalErrorInFunction, Foam::min(), and Foam::nl.

Here is the call graph for this function:

◆ globalSample01() [2/5]

Foam::scalar globalSample01 ( )

Definition at line 144 of file Random.C.

References UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ globalSample01() [3/5]

Foam::label globalSample01 ( )

Definition at line 160 of file Random.C.

References Foam::labelMin, UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ globalGaussNormal() [2/5]

Foam::scalar globalGaussNormal ( )

Definition at line 176 of file Random.C.

References UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ globalGaussNormal() [3/5]

Foam::label globalGaussNormal ( )

Definition at line 192 of file Random.C.

References Foam::labelMin, UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ globalPosition() [2/5]

Foam::scalar globalPosition ( const scalar &  start,
const scalar &  end 
)

Definition at line 209 of file Random.C.

References stdFoam::end(), UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ globalPosition() [3/5]

Foam::label globalPosition ( const label &  start,
const label &  end 
)

Definition at line 229 of file Random.C.

References stdFoam::end(), Foam::labelMin, UPstream::master(), and Pstream::scatter().

Here is the call graph for this function:

◆ sample01() [4/5]

scalar sample01 ( )

◆ sample01() [5/5]

label sample01 ( )

◆ GaussNormal() [4/5]

scalar GaussNormal ( )

◆ GaussNormal() [5/5]

label GaussNormal ( )

◆ position() [4/5]

scalar position ( const scalar &  start,
const scalar &  end 
)

◆ position() [5/5]

label position ( const label &  start,
const label &  end 
)

◆ globalSample01() [4/5]

scalar globalSample01 ( )

◆ globalSample01() [5/5]

label globalSample01 ( )

◆ globalGaussNormal() [4/5]

scalar globalGaussNormal ( )

◆ globalGaussNormal() [5/5]

label globalGaussNormal ( )

◆ globalPosition() [4/5]

scalar globalPosition ( const scalar &  start,
const scalar &  end 
)

◆ globalPosition() [5/5]

label globalPosition ( const label &  start,
const label &  end 
)

Member Data Documentation

◆ defaultSeed

constexpr label defaultSeed = 123456
staticconstexpr

The default seed value (name may change in the future)

Definition at line 95 of file Random.H.


The documentation for this class was generated from the following files: