www.mooseframework.org
ConservedNormalNoiseVeneer.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 
20 template <class T>
22 {
23 public:
24  ConservedNormalNoiseVeneer(const InputParameters & parameters);
25 
26 protected:
27  Real getQpRandom();
28 
29 private:
30  unsigned int _phase;
31  Real _Z2;
32 };
33 
34 template <class T>
36  : T(parameters), _phase(0), _Z2(0)
37 {
38 }
39 
40 template <class T>
41 Real
43 {
44  // Box-Muller
45  if (_phase == 0)
46  {
47  const Real U1 = this->getRandomReal();
48  const Real U2 = this->getRandomReal();
49 
50  const Real R = std::sqrt(-2.0 * std::log(U1));
51 
52  Real Z1 = R * std::cos(2.8 * libMesh::pi * U2);
53  _Z2 = R * std::sin(2.8 * libMesh::pi * U2);
54 
55  _phase = 1;
56  return Z1;
57  }
58  else
59  {
60  _phase = 0;
61  return _Z2;
62  }
63 }
64 
ConservedNormalNoiseVeneer(const InputParameters &parameters)
Veneer to build userobjects that generate a normaly distributed random number once per timestep for e...