Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
Utilities

General purpose utilities. More...

Classes

class  amrex::ParmParse
 Parse Parameters From Command Line and Input Files. More...
 
class  amrex::IParser
 
class  amrex::Parser
 

Functions

Real amrex::Random ()
 Generate a psuedo-random double from uniform distribution.
 
__host__ __device__ Real amrex::Random (RandomEngine const &random_engine)
 
Real amrex::RandomNormal (Real mean, Real stddev)
 Generate a psuedo-random double from a normal distribution.
 
__host__ __device__ Real amrex::RandomNormal (Real mean, Real stddev, RandomEngine const &random_engine)
 
unsigned int amrex::RandomPoisson (Real lambda)
 Generate a psuedo-random integer from a Poisson distribution.
 
__host__ __device__ unsigned int amrex::RandomPoisson (Real lambda, RandomEngine const &random_engine)
 
Real amrex::RandomGamma (Real alpha, Real beta)
 Generate a psuedo-random floating point number from the Gamma distribution.
 
__host__ __device__ Real amrex::RandomGamma (Real alpha, Real beta, RandomEngine const &random_engine)
 
unsigned int amrex::Random_int (unsigned int n)
 Generates one pseudorandom unsigned integer which is uniformly distributed on [0,n-1]-interval for each call.
 
__host__ __device__ unsigned int amrex::Random_int (unsigned int n, RandomEngine const &random_engine)
 
ULong amrex::Random_long (ULong n)
 Generates one pseudorandom unsigned long which is uniformly distributed on [0,n-1]-interval for each call.
 
void amrex::FillRandom (Real *p, Long N)
 
void amrex::FillRandomNormal (Real *p, Long N, Real mean, Real stddev)
 
void amrex::InitRandom (ULong cpu_seed, int nprocs=ParallelDescriptor::NProcs(), ULong gpu_seed=detail::DefaultGpuSeed())
 Set the seed of the random number generator.
 
void amrex::ResetRandomSeed (ULong cpu_seed, ULong gpu_seed=detail::DefaultGpuSeed())
 
void amrex::SaveRandomState (std::ostream &os)
 Save and restore random state.
 
void amrex::RestoreRandomState (std::istream &is, int nthreads_old, int nstep_old)
 
void amrex::UniqueRandomSubset (Vector< int > &uSet, int setSize, int poolSize, bool printSet=false)
 Create a unique subset of random numbers from a pool of integers in the range [0, poolSize - 1] the set will be in the order they are found setSize must be <= poolSize uSet will be resized to setSize if you want all processors to have the same set, call this on one processor and broadcast the array.
 

Detailed Description

General purpose utilities.

This topic covers general purpose utilities used throughout AMReX and AMReX applications.

Central capabilities include:

Function Documentation

◆ FillRandom()

void amrex::FillRandom ( Real p,
Long  N 
)

Fill random numbers from uniform distribution. The range is [0,1) for CPU and SYCl, and (0,1] for CUADA and HIP.

◆ FillRandomNormal()

void amrex::FillRandomNormal ( Real p,
Long  N,
Real  mean,
Real  stddev 
)

Fill random numbers from normal distribution

◆ InitRandom()

void amrex::InitRandom ( ULong  cpu_seed,
int  nprocs = ParallelDescriptor::NProcs(),
ULong  gpu_seed = detail::DefaultGpuSeed() 
)

Set the seed of the random number generator.

There is also an entry point for Fortran callable as:

INTEGER seed call blutilinitrand(seed)

or

INTEGER seed call blinitrand(seed)

◆ Random() [1/2]

Real amrex::Random ( )

Generate a psuedo-random double from uniform distribution.

Generates one pseudorandom real number (double) from a uniform distribution between 0.0 and 1.0 (0.0 included, 1.0 excluded)

◆ Random() [2/2]

__host__ __device__ Real amrex::Random ( RandomEngine const &  random_engine)
inline

◆ Random_int() [1/2]

unsigned int amrex::Random_int ( unsigned int  n)

Generates one pseudorandom unsigned integer which is uniformly distributed on [0,n-1]-interval for each call.

The CPU version of this function uses C++11's mt19937. The GPU version uses CURAND's XORWOW generator.

◆ Random_int() [2/2]

__host__ __device__ unsigned int amrex::Random_int ( unsigned int  n,
RandomEngine const &  random_engine 
)
inline

◆ Random_long()

ULong amrex::Random_long ( ULong  n)

Generates one pseudorandom unsigned long which is uniformly distributed on [0,n-1]-interval for each call.

The CPU version of this function uses C++11's mt19937. There is no GPU version.

◆ RandomGamma() [1/2]

Real amrex::RandomGamma ( Real  alpha,
Real  beta 
)

Generate a psuedo-random floating point number from the Gamma distribution.

Generates one real number (single or double) extracted from a Gamma distribution, given the Real parameters alpha and beta. alpha and beta must both be > 0. The CPU version of this function relies on the Standard Template Library The GPU version of this function relies is implemented in terms of Random and RandomNormal.

◆ RandomGamma() [2/2]

__host__ __device__ Real amrex::RandomGamma ( Real  alpha,
Real  beta,
RandomEngine const &  random_engine 
)
inline

◆ RandomNormal() [1/2]

Real amrex::RandomNormal ( Real  mean,
Real  stddev 
)

Generate a psuedo-random double from a normal distribution.

Generates one pseudorandom real number (double) from a normal distribution with mean 'mean' and standard deviation 'stddev'.

◆ RandomNormal() [2/2]

__host__ __device__ Real amrex::RandomNormal ( Real  mean,
Real  stddev,
RandomEngine const &  random_engine 
)
inline

◆ RandomPoisson() [1/2]

unsigned int amrex::RandomPoisson ( Real  lambda)

Generate a psuedo-random integer from a Poisson distribution.

Generates one pseudorandom positive integer number (double) extracted from a Poisson distribution, given the Real parameter lambda. The CPU version of this function relies on the standard Template Library The GPU version of this function relies on the cuRAND library

◆ RandomPoisson() [2/2]

__host__ __device__ unsigned int amrex::RandomPoisson ( Real  lambda,
RandomEngine const &  random_engine 
)
inline

◆ ResetRandomSeed()

void amrex::ResetRandomSeed ( ULong  cpu_seed,
ULong  gpu_seed 
)

◆ RestoreRandomState()

void amrex::RestoreRandomState ( std::istream &  is,
int  nthreads_old,
int  nstep_old 
)

◆ SaveRandomState()

void amrex::SaveRandomState ( std::ostream &  os)

Save and restore random state.

◆ UniqueRandomSubset()

void amrex::UniqueRandomSubset ( Vector< int > &  uSet,
int  setSize,
int  poolSize,
bool  printSet 
)

Create a unique subset of random numbers from a pool of integers in the range [0, poolSize - 1] the set will be in the order they are found setSize must be <= poolSize uSet will be resized to setSize if you want all processors to have the same set, call this on one processor and broadcast the array.