https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ConservedNormalNoiseVeneer.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
20template <class T>
22{
23public:
25
26protected:
28
29private:
30 unsigned int _phase;
31 Real _Z2;
32};
33
34template <class T>
36 : T(parameters), _phase(0), _Z2(0)
37{
38}
39
40template <class T>
41Real
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}
const double R
const double T
Veneer to build userobjects that generate a normaly distributed random number once per timestep for e...
ConservedNormalNoiseVeneer(const InputParameters &parameters)
const Real pi