Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::PDESRandomNumberGeneratorService Class Reference
Inheritance diagram for Arcane::PDESRandomNumberGeneratorService:
Collaboration diagram for Arcane::PDESRandomNumberGeneratorService:

Public Member Functions

 PDESRandomNumberGeneratorService (const ServiceBuildInfo &sbi)
bool initSeed () override
 Method allowing initialization of the service.
bool initSeed (ByteArrayView seed) override
 Method allowing initialization of the service.
ByteUniqueArray emptySeed () override
 Method allowing retrieval of an empty seed of the correct size.
ByteConstArrayView viewSeed () override
 Method allowing retrieval of a constant view of the current seed.
Integer neededSizeOfSeed () override
 Method allowing knowledge of the seed size required for the implementation.
bool isLeapSeedSupported () override
 Method allowing knowledge if leaps are allowed on the seed generator.
ByteUniqueArray generateRandomSeed (Integer leap=0) override
 Method allowing generation of a "child" seed from a "parent" seed.
ByteUniqueArray generateRandomSeed (ByteArrayView parent_seed, Integer leap=0) override
 Method allowing generation of a "child" seed from a "parent" seed.
bool isLeapNumberSupported () override
 Method allowing knowledge if leaps are allowed on the number generator.
Real generateRandomNumber (Integer leap) override
 Method allowing generation of a random number using the seed in memory.
Real generateRandomNumber (ByteArrayView seed, Integer leap=0) override
 Method allowing generation of a random number using the seed passed as a parameter.
Public Member Functions inherited from ArcanePDESRandomNumberGeneratorObject
 ArcanePDESRandomNumberGeneratorObject (const Arcane::ServiceBuildInfo &sbi)
 Constructeur.
virtual ~ArcanePDESRandomNumberGeneratorObject ()
 Destructeur.
CaseOptionsPDESRandomNumberGeneratoroptions () const
 Options du jeu de données du service.
Public Member Functions inherited from Arcane::BasicService
 ~BasicService () override
 Releases resources.
virtual ISubDomainsubDomain ()
Public Member Functions inherited from Arcane::AbstractService
 ~AbstractService () override
 Destructor.
virtual void build ()
 Build-level construction of the service.
IServiceInfoserviceInfo () const override
 Access to service information. See IServiceInfo for details.
IBaseserviceParent () const override
 Access to the base interface of main Arcane objects.
IServiceserviceInterface () override
 Returns the low-level IService interface of the service.
Public Member Functions inherited from Arcane::TraceAccessor
 TraceAccessor (ITraceMng *m)
 Constructs an accessor via the trace manager m.
 TraceAccessor (const TraceAccessor &rhs)
 Copy constructor.
TraceAccessoroperator= (const TraceAccessor &rhs)
 Copy assignment operator.
virtual ~TraceAccessor ()
 Frees resources.
ITraceMngtraceMng () const
 Trace manager.
TraceMessage info () const
 Flow for an information message.
TraceMessage pinfo () const
 Flow for a parallel information message.
TraceMessage info (char category) const
 Flow for an information message of a given category.
TraceMessage pinfo (char category) const
 Flow for a parallel information message of a given category.
TraceMessage info (bool v) const
 Flow for an information message.
TraceMessage warning () const
 Flow for a warning message.
TraceMessage pwarning () const
TraceMessage error () const
 Flow for an error message.
TraceMessage perror () const
TraceMessage log () const
 Flow for a log message.
TraceMessage plog () const
 Flow for a log message.
TraceMessage logdate () const
 Flow for a log message preceded by the date.
TraceMessage fatal () const
 Flow for a fatal error message.
TraceMessage pfatal () const
 Flow for a parallel fatal error message.
TraceMessageDbg debug (Trace::eDebugLevel=Trace::Medium) const
 Flow for a debug message.
Trace::eDebugLevel configDbgLevel () const
 Debug level of the configuration file.
TraceMessage info (Int32 verbose_level) const
 Flow for an information message of a given level.
TraceMessage linfo () const
 Flow for an information message with the local information level of this instance.
TraceMessage linfo (Int32 relative_level) const
 Flow for an information message with the local information level of this instance.
void fatalMessage (const StandaloneTraceMessage &o) const
Public Member Functions inherited from Arcane::IService
virtual ~IService ()
 Releases resources.
Public Member Functions inherited from Arcane::MeshAccessor
 MeshAccessor (ISubDomain *sd)
 MeshAccessor (IMesh *mesh)
 MeshAccessor (const MeshHandle &mesh_handle)
Integer nbCell () const
 Returns the number of cells in the mesh.
Integer nbFace () const
 Returns the number of faces in the mesh.
Integer nbEdge () const
 Returns the number of edges in the mesh.
Integer nbNode () const
 Returns the number of nodes in the mesh.
VariableNodeReal3nodesCoordinates () const
 Returns the coordinates of the mesh nodes.
NodeGroup allNodes () const
 Returns the group containing all nodes.
EdgeGroup allEdges () const
 Returns the group containing all edges.
FaceGroup allFaces () const
 Returns the group containing all faces.
CellGroup allCells () const
 Returns the group containing all cells.
FaceGroup outerFaces () const
 Returns the group containing all boundary faces.
NodeGroup ownNodes () const
 Returns the group containing all nodes specific to this domain.
CellGroup ownCells () const
 Returns the group containing all cells specific to this domain.
FaceGroup ownFaces () const
 Group containing all faces specific to this domain.
EdgeGroup ownEdges () const
 Group containing all edges specific to this domain.
IMeshmesh () const
const MeshHandlemeshHandle () const
Public Member Functions inherited from Arcane::CommonVariables
 CommonVariables (IModule *c)
 Constructs the references of the common variables for the module c.
 CommonVariables (IVariableMng *variable_mng)
 Constructs the references of the common variables for the manager variable_mng.
 CommonVariables (ISubDomain *sd)
 Constructs the references of the common variables for the subdomain sd.
virtual ~CommonVariables ()
 Releases resources.
Int32 globalIteration () const
 Current iteration number.
Real globalTime () const
 Current time.
Real globalOldTime () const
 Previous current time.
Real globalFinalTime () const
 Final time of the simulation.
Real globalDeltaT () const
 Current Delta T.
Real globalCPUTime () const
 CPU time used (in seconds).
Real globalOldCPUTime () const
 Previous CPU time used (in seconds).
Real globalElapsedTime () const
 Clock time (elapsed) used (in seconds).
Real globalOldElapsedTime () const
 Previous clock time (elapsed) used (in seconds).

Protected Member Functions

void _breakupUInt64 (uint64_t uint64_in, uint32_t *front_bits, uint32_t *back_bits)
 Method to split a uint64 into two uint32s.
uint64_t _reconstructUInt64 (uint32_t front_bits, uint32_t back_bits)
 Method to combine two uint32s into a uint64.
void _psdes (uint32_t *lword, uint32_t *irword)
 Pseudo-DES algorithm from the book: Numerical Recipes in C The Art of Scientific Computing Second Edition.
uint64_t _hashState (uint64_t initial_number)
 Method to generate a new seed using the pseudo-DES algorithm.
Real _ran4 (Int64 *seed, Integer leap)
 Method to generate pseudo-random numbers from a seed.
Protected Member Functions inherited from Arcane::BasicService
 BasicService (const ServiceBuildInfo &)
Protected Member Functions inherited from Arcane::AbstractService
 AbstractService (const ServiceBuildInfo &)
 Constructor from a ServiceBuildInfo.
Protected Member Functions inherited from Arcane::TraceAccessor
void _setLocalVerboseLevel (Int32 v)
Int32 _localVerboseLevel () const
Protected Member Functions inherited from Arcane::IService
 IService ()
 Constructor.

Protected Attributes

Int64 m_seed
const Integer m_size_of_seed = sizeof(Int64)
bool m_with_option

Additional Inherited Members

Static Public Member Functions inherited from ArcanePDESRandomNumberGeneratorObject
template<typename ServiceClassType>
static void fillServiceInfo (Arcane::ServiceInfo *si)
Public Attributes inherited from Arcane::CommonVariables
VariableScalarInt32 m_global_iteration
 Current iteration.
VariableScalarReal m_global_time
 Current time.
VariableScalarReal m_global_deltat
 Global Delta T.
VariableScalarReal m_global_old_time
 Time previous to the current time.
VariableScalarReal m_global_old_deltat
 Delta T at the time previous to the global time.
VariableScalarReal m_global_final_time
 Final time of the case.
VariableScalarReal m_global_old_cpu_time
 Previous CPU time used (in seconds).
VariableScalarReal m_global_cpu_time
 CPU time used (in seconds).
VariableScalarReal m_global_old_elapsed_time
 Previous clock time used (in seconds).
VariableScalarReal m_global_elapsed_time
 Clock time used (in seconds).

Detailed Description

Definition at line 35 of file PDESRandomNumberGeneratorService.h.

Constructor & Destructor Documentation

◆ PDESRandomNumberGeneratorService()

Arcane::PDESRandomNumberGeneratorService::PDESRandomNumberGeneratorService ( const ServiceBuildInfo & sbi)
inline

Definition at line 40 of file PDESRandomNumberGeneratorService.h.

◆ ~PDESRandomNumberGeneratorService()

virtual Arcane::PDESRandomNumberGeneratorService::~PDESRandomNumberGeneratorService ( )
inlinevirtual

Definition at line 47 of file PDESRandomNumberGeneratorService.h.

Member Function Documentation

◆ _breakupUInt64()

void Arcane::PDESRandomNumberGeneratorService::_breakupUInt64 ( uint64_t uint64_in,
uint32_t * front_bits,
uint32_t * back_bits )
protected

Method to split a uint64 into two uint32s.

Parameters
uint64_inThe uint64 to split into two.
front_bitsThe 32 high-order bits.
back_bitsThe 32 low-order bits.

Definition at line 133 of file PDESRandomNumberGeneratorService.cc.

Referenced by _hashState(), and _ran4().

Here is the caller graph for this function:

◆ _hashState()

uint64_t Arcane::PDESRandomNumberGeneratorService::_hashState ( uint64_t initial_number)
protected

Method to generate a new seed using the pseudo-DES algorithm.

Parameters
initial_numberThe "parent" seed.
Returns
uint64_t The "child" seed.

Definition at line 200 of file PDESRandomNumberGeneratorService.cc.

References _breakupUInt64(), _psdes(), and _reconstructUInt64().

Referenced by generateRandomSeed(), and generateRandomSeed().

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

◆ _psdes()

void Arcane::PDESRandomNumberGeneratorService::_psdes ( uint32_t * lword,
uint32_t * irword )
protected

Pseudo-DES algorithm from the book: Numerical Recipes in C The Art of Scientific Computing Second Edition.

(Pages 302-303)

Parameters
lwordLeft half.
irwordRight half.

Definition at line 175 of file PDESRandomNumberGeneratorService.cc.

Referenced by _hashState(), and _ran4().

Here is the caller graph for this function:

◆ _ran4()

Real Arcane::PDESRandomNumberGeneratorService::_ran4 ( Int64 * seed,
Integer leap )
protected

Method to generate pseudo-random numbers from a seed.

Inspired by the ran4 algorithm from the book: Numerical Recipes in C The Art of Scientific Computing Second Edition

(Pages 303-304)

Parameters
seedThe seed.
leapThe leap.

Definition at line 225 of file PDESRandomNumberGeneratorService.cc.

References _breakupUInt64(), _psdes(), and _reconstructUInt64().

Referenced by generateRandomNumber(), generateRandomNumber(), generateRandomSeed(), and generateRandomSeed().

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

◆ _reconstructUInt64()

uint64_t Arcane::PDESRandomNumberGeneratorService::_reconstructUInt64 ( uint32_t front_bits,
uint32_t back_bits )
protected

Method to combine two uint32s into a uint64.

Parameters
front_bitsThe 32 high-order bits.
back_bitsThe 32 low-order bits.
Returns
uint64_t The reconstructed uint64.

Definition at line 147 of file PDESRandomNumberGeneratorService.cc.

Referenced by _hashState(), and _ran4().

Here is the caller graph for this function:

◆ emptySeed()

ByteUniqueArray Arcane::PDESRandomNumberGeneratorService::emptySeed ( )
overridevirtual

Method allowing retrieval of an empty seed of the correct size.

Returns
ByteUniqueArray The empty seed.

Implements Arcane::IRandomNumberGenerator.

Definition at line 60 of file PDESRandomNumberGeneratorService.cc.

◆ generateRandomNumber() [1/2]

Real Arcane::PDESRandomNumberGeneratorService::generateRandomNumber ( ByteArrayView seed,
Integer leap = 0 )
overridevirtual

Method allowing generation of a random number using the seed passed as a parameter.

This method does not use the seed in memory but the seed provided as a parameter. If the seed provided as a parameter does not have the correct size, an error will be raised.

Parameters
seedThe seed.
leapThe leap to perform (0 = number n+1+0 / 1 = number n+1+1).
Returns
Real The generated number (between 0 and 1).

Implements Arcane::IRandomNumberGenerator.

Definition at line 112 of file PDESRandomNumberGeneratorService.cc.

References _ran4(), ARCANE_FATAL, Arcane::ArrayView< T >::data(), and Arcane::ArrayView< T >::size().

Here is the call graph for this function:

◆ generateRandomNumber() [2/2]

Real Arcane::PDESRandomNumberGeneratorService::generateRandomNumber ( Integer leap)
overridevirtual

Method allowing generation of a random number using the seed in memory.

Parameters
leapThe leap to perform (0 = number n+1+0 / 1 = number n+1+1).
Returns
Real The generated number (between 0 and 1).

Implements Arcane::IRandomNumberGenerator.

Definition at line 105 of file PDESRandomNumberGeneratorService.cc.

References _ran4().

Here is the call graph for this function:

◆ generateRandomSeed() [1/2]

ByteUniqueArray Arcane::PDESRandomNumberGeneratorService::generateRandomSeed ( ByteArrayView parent_seed,
Integer leap = 0 )
overridevirtual

Method allowing generation of a "child" seed from a "parent" seed.

This method does not use the seed in memory but the seed provided as a parameter. If the seed provided as a parameter does not have the correct size, an error will be raised.

Parameters
parent_seedThe "parent" seed.
leapThe leap to perform (0 = seed n+1+0 / 1 = seed n+1+1).
Returns
ByteUniqueArray The new seed generated from the "parent" seed.

Implements Arcane::IRandomNumberGenerator.

Definition at line 87 of file PDESRandomNumberGeneratorService.cc.

References _hashState(), _ran4(), ARCANE_FATAL, Arcane::RNGSeedHelper::copy(), Arcane::ArrayView< T >::data(), and Arcane::ArrayView< T >::size().

Here is the call graph for this function:

◆ generateRandomSeed() [2/2]

ByteUniqueArray Arcane::PDESRandomNumberGeneratorService::generateRandomSeed ( Integer leap = 0)
overridevirtual

Method allowing generation of a "child" seed from a "parent" seed.

Parameters
leapThe leap to perform (0 = seed n+1+0 / 1 = seed n+1+1).
Returns
ByteUniqueArray The new seed generated from the seed in memory.

Implements Arcane::IRandomNumberGenerator.

Definition at line 73 of file PDESRandomNumberGeneratorService.cc.

References _hashState(), _ran4(), and Arcane::RNGSeedHelper::copy().

Here is the call graph for this function:

◆ initSeed() [1/2]

bool Arcane::PDESRandomNumberGeneratorService::initSeed ( )
overridevirtual

Method allowing initialization of the service.

With the seed optional (or the default seed if in singleton mode).

Returns
true If initialization was successful.
false If initialization did not occur.

Implements Arcane::IRandomNumberGenerator.

Definition at line 31 of file PDESRandomNumberGeneratorService.cc.

References ArcanePDESRandomNumberGeneratorObject::options().

Here is the call graph for this function:

◆ initSeed() [2/2]

bool Arcane::PDESRandomNumberGeneratorService::initSeed ( ByteArrayView seed)
overridevirtual

Method allowing initialization of the service.

If the seed does not have the correct size, false will be returned.

Parameters
seedThe original seed.
Returns
true If initialization was successful.
false If initialization did not occur.

Implements Arcane::IRandomNumberGenerator.

Definition at line 43 of file PDESRandomNumberGeneratorService.cc.

References Arcane::RNGSeedHelper::sizeOfSeed(), and Arcane::RNGSeedHelper::value().

Here is the call graph for this function:

◆ isLeapNumberSupported()

bool Arcane::PDESRandomNumberGeneratorService::isLeapNumberSupported ( )
inlineoverridevirtual

Method allowing knowledge if leaps are allowed on the number generator.

Returns
true If yes.
false If no.

Implements Arcane::IRandomNumberGenerator.

Definition at line 63 of file PDESRandomNumberGeneratorService.h.

◆ isLeapSeedSupported()

bool Arcane::PDESRandomNumberGeneratorService::isLeapSeedSupported ( )
inlineoverridevirtual

Method allowing knowledge if leaps are allowed on the seed generator.

Returns
true If yes.
false If no.

Implements Arcane::IRandomNumberGenerator.

Definition at line 59 of file PDESRandomNumberGeneratorService.h.

◆ neededSizeOfSeed()

Integer Arcane::PDESRandomNumberGeneratorService::neededSizeOfSeed ( )
overridevirtual

Method allowing knowledge of the seed size required for the implementation.

Returns
Integer The required seed size (in bytes).

Implements Arcane::IRandomNumberGenerator.

Definition at line 66 of file PDESRandomNumberGeneratorService.cc.

◆ viewSeed()

ByteConstArrayView Arcane::PDESRandomNumberGeneratorService::viewSeed ( )
overridevirtual

Method allowing retrieval of a constant view of the current seed.

Returns
ByteArrayView The seed.

Implements Arcane::IRandomNumberGenerator.

Definition at line 54 of file PDESRandomNumberGeneratorService.cc.

References Arcane::RNGSeedHelper::constView().

Here is the call graph for this function:

Member Data Documentation

◆ m_seed

Int64 Arcane::PDESRandomNumberGeneratorService::m_seed
protected

Definition at line 77 of file PDESRandomNumberGeneratorService.h.

◆ m_size_of_seed

const Integer Arcane::PDESRandomNumberGeneratorService::m_size_of_seed = sizeof(Int64)
protected

Definition at line 78 of file PDESRandomNumberGeneratorService.h.

◆ m_with_option

bool Arcane::PDESRandomNumberGeneratorService::m_with_option
protected

Definition at line 79 of file PDESRandomNumberGeneratorService.h.


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