13#include "libmesh/point.h"
21valueHelper(dof_id_type
id,
MooseRandom & generator, std::map<dof_id_type, Real> & map)
23 auto it_pair = map.lower_bound(
id);
26 if (it_pair == map.end() || it_pair->first !=
id)
27 it_pair = map.emplace_hint(it_pair,
id, generator.
rand(
id));
29 return it_pair->second;
37 params.
addParam<
unsigned int>(
"seed", 0,
"Seed value for the random number generator");
41 "Determines whether or not the legacy generator (deprecated) should be used.");
49 _is_nodal(_var.isNodal()),
50 _use_legacy(getParam<bool>(
"legacy_generator")),
51 _elem_random_generator(nullptr),
52 _node_random_generator(nullptr)
54 unsigned int processor_seed = getParam<unsigned int>(
"seed");
62 for (processor_id_type i = 0; i < proc_id; ++i)
96 mooseDeprecated(
"legacy_generator is deprecated. Please set \"legacy_generator = false\". This "
97 "capability will be removed after 11/01/2018");
109 mooseError(
"We can't generate parallel consistent random numbers for this kind of variable "
110 "yet. Please contact the MOOSE team for assistance");
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
const ExecFlagType EXEC_INITIAL
This is a template class that implements the workhorse compute and computeNodal methods.
FEProblemBase & _fe_problem
const Node * _current_node
The current node if the point we are evaluating at also happens to be a node.
const Elem *const & _current_elem
The current element we are on will retrieving values at specific points in the domain.
static InputParameters validParams()
This class encapsulates a useful, consistent, cross-platform random number generator with multiple ut...
static Real rand()
This method returns the next random number (Real format) from the generator.
static uint32_t randl()
This method returns the next random number (long format) from the generator.
static void seed(unsigned int seed)
The method seeds the random number generator.
std::map< dof_id_type, Real > _elem_numbers
Random numbers per element (currently limited to a single value at a time)
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
std::map< dof_id_type, Real > _node_numbers
Random numbers per node (currently limited to a single value at a time)
MooseRandom * _elem_random_generator
Elemental random number generator.
const bool _use_legacy
Boolean to indicate whether we want to use the old (deprecated) generation pattern.
std::unique_ptr< RandomData > _node_random_data
RandomData node object, we cannot inherit from RandomInterface in an InitialCondition.
static InputParameters validParams()
RandomICBase(const InputParameters ¶meters)
Constructor.
MooseRandom * _node_random_generator
Nodal random number generator.
std::unique_ptr< RandomData > _elem_random_data
RandomData element object, we cannot inherit from RandomInterface in an InitialCondition.
Real generateRandom()
Generate a uniformly distributed random number on the interval from 0 to 1.
processor_id_type processor_id() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real