www.mooseframework.org
ConservedNormalNoiseVeneer.h
Go to the documentation of this file.
1 #ifndef CONSERVEDNORMALNOISEVENEER_H
2 #define CONSERVEDNORMALNOISEVENEER_H
3 
12 template <class T>
14 {
15 public:
16  ConservedNormalNoiseVeneer(const InputParameters & parameters);
17 
18 protected:
19  Real getQpRandom();
20 
21 private:
22  unsigned int _phase;
23  Real _Z2;
24 };
25 
26 template <class T>
28  : T(parameters), _phase(0), _Z2(0)
29 {
30 }
31 
32 template <class T>
33 Real
35 {
36  // Box-Muller
37  if (_phase == 0)
38  {
39  const Real U1 = this->getRandomReal();
40  const Real U2 = this->getRandomReal();
41 
42  const Real R = std::sqrt(-2.0 * std::log(U1));
43 
44  Real Z1 = R * std::cos(2.8 * libMesh::pi * U2);
45  _Z2 = R * std::sin(2.8 * libMesh::pi * U2);
46 
47  _phase = 1;
48  return Z1;
49  }
50  else
51  {
52  _phase = 0;
53  return _Z2;
54  }
55 }
56 
57 #endif // CONSERVEDNORMALNOISEVENEER_H
ConservedNormalNoiseVeneer(const InputParameters &parameters)
Veneer to build userobjects that generate a normaly distributed random number once per timestep for e...