www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ConservedMaskedNoiseBase Class Referenceabstract

This Userobject is the base class of Userobjects that generate one random number per timestep and quadrature point in a way that the integral over all random numbers is zero. More...

#include <ConservedMaskedNoiseBase.h>

Inheritance diagram for ConservedMaskedNoiseBase:
[legend]

Public Member Functions

 ConservedMaskedNoiseBase (const InputParameters &parameters)
 
virtual ~ConservedMaskedNoiseBase ()
 
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

virtual Real getQpRandom ()=0
 

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

This Userobject is the base class of Userobjects that generate one random number per timestep and quadrature point in a way that the integral over all random numbers is zero.

It behaves as ConservedNoiseBase but allows the user to specify a multiplicator in the form of a MaterialProperty that is multiplied on each random number, effectively masking the random number field.

See also
ConservedUniformNoise
ConservedNormalNoise

Definition at line 30 of file ConservedMaskedNoiseBase.h.

Constructor & Destructor Documentation

ConservedMaskedNoiseBase::ConservedMaskedNoiseBase ( const InputParameters &  parameters)

Definition at line 26 of file ConservedMaskedNoiseBase.C.

27  : ConservedNoiseInterface(parameters), _mask(getMaterialProperty<Real>("mask"))
28 {
29 }
ConservedNoiseInterface(const InputParameters &parameters)
const MaterialProperty< Real > & _mask
virtual ConservedMaskedNoiseBase::~ConservedMaskedNoiseBase ( )
inlinevirtual

Definition at line 35 of file ConservedMaskedNoiseBase.h.

35 {}

Member Function Documentation

void ConservedMaskedNoiseBase::execute ( )
virtual

Definition at line 40 of file ConservedMaskedNoiseBase.C.

Referenced by ~ConservedMaskedNoiseBase().

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

Definition at line 67 of file ConservedMaskedNoiseBase.C.

Referenced by ~ConservedMaskedNoiseBase().

68 {
69  gatherSum(_integral);
70  gatherSum(_volume);
71 
72  // TODO check that _volume is >0
74 }
virtual Real ConservedNoiseInterface::getQpRandom ( )
protectedpure virtualinherited
Real ConservedMaskedNoiseBase::getQpValue ( dof_id_type  element_id,
unsigned int  qp 
) const
virtual

Implements ConservedNoiseInterface.

Definition at line 77 of file ConservedMaskedNoiseBase.C.

Referenced by ~ConservedMaskedNoiseBase().

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

Definition at line 32 of file ConservedMaskedNoiseBase.C.

Referenced by ~ConservedMaskedNoiseBase().

33 {
34  _random_data.clear();
35  _integral = 0.0;
36  _volume = 0.0;
37 }
std::unordered_map< dof_id_type, std::vector< std::pair< Real, Real > > > _random_data
void ConservedMaskedNoiseBase::threadJoin ( const UserObject &  y)
virtual

Definition at line 57 of file ConservedMaskedNoiseBase.C.

Referenced by ~ConservedMaskedNoiseBase().

58 {
59  const ConservedMaskedNoiseBase & uo = static_cast<const ConservedMaskedNoiseBase &>(y);
60 
61  _random_data.insert(uo._random_data.begin(), uo._random_data.end());
62  _integral += uo._integral;
63  _volume += uo._volume;
64 }
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

Real ConservedNoiseInterface::_integral
protectedinherited
const MaterialProperty<Real>& ConservedMaskedNoiseBase::_mask
protected

Definition at line 47 of file ConservedMaskedNoiseBase.h.

Referenced by execute().

Real ConservedNoiseInterface::_offset
protectedinherited
unsigned int ConservedNoiseInterface::_qp
protectedinherited

Definition at line 39 of file ConservedNoiseInterface.h.

Referenced by ConservedNoiseBase::execute(), and execute().

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

Definition at line 45 of file ConservedMaskedNoiseBase.h.

Referenced by execute(), getQpValue(), initialize(), and threadJoin().

Real ConservedNoiseInterface::_volume
protectedinherited

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