www.mooseframework.org
RandomInterface.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "MooseTypes.h"
13 #include "MooseEnumItem.h"
14 
15 // Forward declarations
16 class Assembly;
17 class FEProblemBase;
18 class InputParameters;
19 class MooseRandom;
20 class RandomData;
21 class RandomInterface;
22 
23 template <typename T>
25 
26 template <>
28 
34 {
35 public:
36  RandomInterface(const InputParameters & parameters,
37  FEProblemBase & problem,
38  THREAD_ID tid,
39  bool is_nodal);
40 
42 
44 
49  void setRandomResetFrequency(ExecFlagType exec_flag);
50 
54  unsigned long getRandomLong() const;
55 
59  Real getRandomReal() const;
60 
66  unsigned int getSeed(std::size_t id);
67 
68  /**************************************************
69  * Data Accessors *
70  **************************************************/
71  unsigned int getMasterSeed() const { return _master_seed; }
72  bool isNodal() const { return _is_nodal; }
73  ExecFlagType getResetOnTime() const { return _reset_on; }
74 
75  void setRandomDataPointer(RandomData * random_data);
76 
77 private:
79  mutable MooseRandom * _generator;
80 
82  const std::string _ri_name;
83 
84  unsigned int _master_seed;
85  bool _is_nodal;
87 
88  const Node * const & _curr_node;
89  const Elem * const & _curr_element;
90 
91  // friend void FEProblemBase::registerRandomInterface(RandomInterface *random_interface, const
92  // std::string & name, ExecFlagType exec_flag);
93 };
MooseRandom
This class encapsulates a useful, consistent, cross-platform random number generator with multiple ut...
Definition: MooseRandom.h:36
THREAD_ID
unsigned int THREAD_ID
Definition: MooseTypes.h:196
RandomInterface::_curr_element
const Elem *const & _curr_element
Definition: RandomInterface.h:88
RandomData
Definition: RandomData.h:23
validParams
InputParameters validParams()
This is the templated validParams() function that every MooseObject-derived class is required to spec...
Definition: InputParameters.h:1551
RandomInterface::RandomInterface
RandomInterface(const InputParameters &parameters, FEProblemBase &problem, THREAD_ID tid, bool is_nodal)
Definition: RandomInterface.C:30
RandomInterface::_ri_name
const std::string _ri_name
Definition: RandomInterface.h:81
RandomInterface::setRandomDataPointer
void setRandomDataPointer(RandomData *random_data)
Definition: RandomInterface.C:56
RandomInterface::getRandomReal
Real getRandomReal() const
Returns the next random number (Real) from the generator tied to this object (elem/node).
Definition: RandomInterface.C:85
RandomInterface::_random_data
RandomData * _random_data
Definition: RandomInterface.h:77
RandomInterface::_master_seed
unsigned int _master_seed
Definition: RandomInterface.h:83
MooseEnumItem.h
RandomInterface::setRandomResetFrequency
void setRandomResetFrequency(ExecFlagType exec_flag)
This interface should be called from a derived class to enable random number generation in this objec...
Definition: RandomInterface.C:49
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
RandomInterface::~RandomInterface
~RandomInterface()
Definition: RandomInterface.C:46
RandomInterface::_generator
MooseRandom * _generator
Definition: RandomInterface.h:78
RandomInterface::_curr_node
const Node *const & _curr_node
Definition: RandomInterface.h:87
RandomInterface::getRandomLong
unsigned long getRandomLong() const
Returns the next random number (long) from the generator tied to this object (elem/node).
Definition: RandomInterface.C:71
RandomInterface::getSeed
unsigned int getSeed(std::size_t id)
Get the seed for the passed in elem/node id.
Definition: RandomInterface.C:63
MooseEnumItem
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:21
RandomInterface::_ri_problem
FEProblemBase & _ri_problem
Definition: RandomInterface.h:80
Assembly
Keeps track of stuff related to assembling.
Definition: Assembly.h:62
RandomInterface::validParams
static InputParameters validParams()
Definition: RandomInterface.C:20
RandomInterface::_is_nodal
bool _is_nodal
Definition: RandomInterface.h:84
RandomInterface::_reset_on
ExecFlagType _reset_on
Definition: RandomInterface.h:85
RandomInterface
Interface for objects that need parallel consistent random numbers without patterns over the course o...
Definition: RandomInterface.h:33
RandomInterface::getResetOnTime
ExecFlagType getResetOnTime() const
Definition: RandomInterface.h:72
MooseTypes.h
FEProblemBase
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: FEProblemBase.h:139
RandomInterface::isNodal
bool isNodal() const
Definition: RandomInterface.h:71
validParams< RandomInterface >
InputParameters validParams< RandomInterface >()
RandomInterface::getMasterSeed
unsigned int getMasterSeed() const
Definition: RandomInterface.h:70