www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ConservedMaskedUniformNoise 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 <ConservedMaskedUniformNoise.h>

Inheritance diagram for ConservedMaskedUniformNoise:
[legend]

Public Member Functions

 ConservedMaskedUniformNoise (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< std::pair< Real, Real > > > _random_data
 
const MaterialProperty< Real > & _mask
 
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 ConservedMaskedUniformNoise.h.

Constructor & Destructor Documentation

◆ ConservedMaskedUniformNoise()

ConservedMaskedUniformNoise::ConservedMaskedUniformNoise ( const InputParameters &  parameters)
inline

Member Function Documentation

◆ execute()

void ConservedMaskedNoiseBase::execute ( )
virtualinherited

Definition at line 39 of file ConservedMaskedNoiseBase.C.

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

◆ finalize()

void ConservedMaskedNoiseBase::finalize ( )
virtualinherited

Definition at line 66 of file ConservedMaskedNoiseBase.C.

67 {
68  gatherSum(_integral);
69  gatherSum(_volume);
70 
71  // TODO check that _volume is >0
73 }

◆ getQpRandom()

Real ConservedUniformNoiseVeneer< ConservedMaskedNoiseBase >::getQpRandom ( )
protectedvirtualinherited

Implements ConservedNoiseInterface.

Definition at line 38 of file ConservedUniformNoiseVeneer.h.

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

◆ getQpValue()

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

Implements ConservedNoiseInterface.

Definition at line 76 of file ConservedMaskedNoiseBase.C.

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

◆ initialize()

void ConservedMaskedNoiseBase::initialize ( )
virtualinherited

Definition at line 31 of file ConservedMaskedNoiseBase.C.

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

◆ threadJoin()

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

Definition at line 56 of file ConservedMaskedNoiseBase.C.

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

Member Data Documentation

◆ _integral

Real ConservedNoiseInterface::_integral
protectedinherited

◆ _mask

const MaterialProperty<Real>& ConservedMaskedNoiseBase::_mask
protectedinherited

Definition at line 50 of file ConservedMaskedNoiseBase.h.

Referenced by ConservedMaskedNoiseBase::execute().

◆ _offset

Real ConservedNoiseInterface::_offset
protectedinherited

◆ _qp

unsigned int ConservedNoiseInterface::_qp
protectedinherited

◆ _random_data

std::unordered_map<dof_id_type, std::vector<std::pair<Real, Real> > > ConservedMaskedNoiseBase::_random_data
protectedinherited

◆ _volume

Real ConservedNoiseInterface::_volume
protectedinherited

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