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

Userobject that generates a uniformly distributed random number in the interval [-1:1] once per timestep for every quadrature point in a way that the integral over all random numbers is zero. More...

#include <ConservedUniformNoise.h>

Inheritance diagram for ConservedUniformNoise:
[legend]

Public Member Functions

 ConservedUniformNoise (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 uniformly distributed random number in the interval [-1:1] 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 ConservedUniformNoise.h.

Constructor & Destructor Documentation

◆ ConservedUniformNoise()

ConservedUniformNoise::ConservedUniformNoise ( 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 ConservedUniformNoiseVeneer< ConservedNoiseBase >::getQpRandom ( )
protectedvirtualinherited

Implements ConservedNoiseInterface.

Definition at line 38 of file ConservedUniformNoiseVeneer.h.

39 {
40  return 2.0 * this->getRandomReal() - 1.0;
41 }

◆ 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: