www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ConservedNormalNoise Class Reference

Userobject that generates a normaly distributed random number once per timestep for every quadrature point in a way that the integral over all random numbers is zero. More...

#include <ConservedNormalNoise.h>

Inheritance diagram for ConservedNormalNoise:
[legend]

Public Member Functions

 ConservedNormalNoise (const InputParameters &parameters)
 
virtual void initialize ()
 
virtual void execute ()
 
virtual void threadJoin (const UserObject &y)
 
virtual void finalize ()
 
Real getQpValue (dof_id_type element_id, unsigned int qp) const
 

Protected Member Functions

Real getQpRandom ()
 

Protected Attributes

std::unordered_map< dof_id_type, std::vector< Real > > _random_data
 
Real _integral
 
Real _volume
 
Real _offset
 
unsigned int _qp
 

Detailed Description

Userobject that generates a normaly distributed random number once per timestep for every quadrature point in a way that the integral over all random numbers is zero.

See also
ConservedNoiseBase

Definition at line 28 of file ConservedNormalNoise.h.

Constructor & Destructor Documentation

◆ ConservedNormalNoise()

ConservedNormalNoise::ConservedNormalNoise ( const InputParameters &  parameters)
inline

Member Function Documentation

◆ execute()

void ConservedNoiseBase::execute ( )
virtualinherited

Definition at line 37 of file ConservedNoiseBase.C.

38 {
39  // reserve space for each quadrature point in the element
40  std::vector<Real> & me = _random_data[_current_elem->id()] =
41  std::vector<Real>(_qrule->n_points());
42 
43  // store a random number for each quadrature point
44  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
45  {
46  me[_qp] = getQpRandom();
47  _integral += _JxW[_qp] * _coord[_qp] * me[_qp];
48  _volume += _JxW[_qp] * _coord[_qp];
49  }
50 }
std::unordered_map< dof_id_type, std::vector< Real > > _random_data
virtual Real getQpRandom()=0

◆ finalize()

void ConservedNoiseBase::finalize ( )
virtualinherited

Definition at line 63 of file ConservedNoiseBase.C.

◆ getQpRandom()

Real ConservedNormalNoiseVeneer< ConservedNoiseBase >::getQpRandom ( )
protectedvirtualinherited

Implements ConservedNoiseInterface.

Definition at line 42 of file ConservedNormalNoiseVeneer.h.

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 }

◆ getQpValue()

Real ConservedNoiseBase::getQpValue ( dof_id_type  element_id,
unsigned int  qp 
) const
virtualinherited

Implements ConservedNoiseInterface.

Definition at line 72 of file ConservedNoiseBase.C.

73 {
74  const auto it_pair = _random_data.find(element_id);
75 
76  if (it_pair == _random_data.end())
77  mooseError("Element not found.");
78  else
79  {
80  libmesh_assert_less(qp, it_pair->second.size());
81  return it_pair->second[qp] - _offset;
82  }
83 }
std::unordered_map< dof_id_type, std::vector< Real > > _random_data

◆ initialize()

void ConservedNoiseBase::initialize ( )
virtualinherited

Definition at line 29 of file ConservedNoiseBase.C.

30 {
31  _random_data.clear();
32  _integral = 0.0;
33  _volume = 0.0;
34 }
std::unordered_map< dof_id_type, std::vector< Real > > _random_data

◆ threadJoin()

void ConservedNoiseBase::threadJoin ( const UserObject &  y)
virtualinherited

Definition at line 53 of file ConservedNoiseBase.C.

54 {
55  const ConservedNoiseBase & uo = static_cast<const ConservedNoiseBase &>(y);
56 
57  _random_data.insert(uo._random_data.begin(), uo._random_data.end());
58  _integral += uo._integral;
59  _volume += uo._volume;
60 }
This Userobject is the base class of Userobjects that generate one random number per timestep and qua...
std::unordered_map< dof_id_type, std::vector< Real > > _random_data

Member Data Documentation

◆ _integral

Real ConservedNoiseInterface::_integral
protectedinherited

◆ _offset

Real ConservedNoiseInterface::_offset
protectedinherited

◆ _qp

unsigned int ConservedNoiseInterface::_qp
protectedinherited

◆ _random_data

std::unordered_map<dof_id_type, std::vector<Real> > ConservedNoiseBase::_random_data
protectedinherited

◆ _volume

Real ConservedNoiseInterface::_volume
protectedinherited

The documentation for this class was generated from the following file: