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

This UserObject maintains a per QP map that indicates if a nucleus is present or not. More...

#include <DiscreteNucleationMap.h>

Inheritance diagram for DiscreteNucleationMap:
[legend]

Public Member Functions

 DiscreteNucleationMap (const InputParameters &parameters)
 
virtual void initialize ()
 
virtual void execute ()
 
virtual void threadJoin (const UserObject &y)
 
virtual void finalize ()
 
virtual void meshChanged ()
 
const std::vector< Real > & nuclei (const Elem *) const
 
const DiscreteNucleationInserterBasegetInserter () const
 
std::pair< Real, Real > getRadiusAndWidth () const
 
Real getPeriodic () const
 

Protected Attributes

bool _mesh_changed
 Did the mesh change since the last execution of this PP? More...
 
bool _rebuild_map
 Do we need to rebuild the map during this timestep? More...
 
std::vector< Real > _elem_map
 Buffer for building the per QP map. More...
 
std::vector< Real > _zero_map
 Dummy map for elements without nuclei. More...
 
const DiscreteNucleationInserterBase_inserter
 UserObject that manages nucleus insertin and deletion. More...
 
int _periodic
 variable number to use for minPeriodicDistance calls (i.e. use the periodicity of this variable) More...
 
const Real _radius
 Nucleus radius. More...
 
const Real _int_width
 Nucleus interface width. More...
 
const DiscreteNucleationInserterBase::NucleusList_nucleus_list
 list of nuclei maintained bu the inserter object More...
 
using NucleusMap = std::unordered_map< dof_id_type, std::vector< Real > >
 Per element list with 0/1 flags indicating the presence of a nucleus. More...
 
NucleusMap _nucleus_map
 

Detailed Description

This UserObject maintains a per QP map that indicates if a nucleus is present or not.

It effectively performs a spatial hashing of the list maintained by the DiscreteNucleationInserter (and allows for spatially extended nuclei)

Definition at line 26 of file DiscreteNucleationMap.h.

Member Typedef Documentation

◆ NucleusMap

using DiscreteNucleationMap::NucleusMap = std::unordered_map<dof_id_type, std::vector<Real> >
protected

Per element list with 0/1 flags indicating the presence of a nucleus.

Definition at line 73 of file DiscreteNucleationMap.h.

Constructor & Destructor Documentation

◆ DiscreteNucleationMap()

DiscreteNucleationMap::DiscreteNucleationMap ( const InputParameters &  parameters)

Definition at line 36 of file DiscreteNucleationMap.C.

37  : ElementUserObject(parameters),
38  _mesh_changed(false),
39  _inserter(getUserObject<DiscreteNucleationInserterBase>("inserter")),
40  _periodic(isCoupled("periodic") ? coupled("periodic") : -1),
41  _radius(getParam<Real>("radius")),
42  _int_width(getParam<Real>("int_width")),
44 {
45  _zero_map.assign(_fe_problem.getMaxQps(), 0.0);
46 }
const DiscreteNucleationInserterBase & _inserter
UserObject that manages nucleus insertin and deletion.
bool _mesh_changed
Did the mesh change since the last execution of this PP?
int _periodic
variable number to use for minPeriodicDistance calls (i.e. use the periodicity of this variable) ...
virtual const NucleusList & getNucleusList() const
const Real _int_width
Nucleus interface width.
std::vector< Real > _zero_map
Dummy map for elements without nuclei.
const Real _radius
Nucleus radius.
const DiscreteNucleationInserterBase::NucleusList & _nucleus_list
list of nuclei maintained bu the inserter object

Member Function Documentation

◆ execute()

void DiscreteNucleationMap::execute ( )
virtual

Definition at line 63 of file DiscreteNucleationMap.C.

64 {
65  if (_rebuild_map)
66  {
67  // reserve space for each quadrature point in the element
68  _elem_map.assign(_qrule->n_points(), 0);
69 
70  // store a random number for each quadrature point
71  unsigned int active_nuclei = 0;
72  for (unsigned int qp = 0; qp < _qrule->n_points(); ++qp)
73  {
74  Real r, rmin = std::numeric_limits<Real>::max();
75 
76  // find the distance to the closest nucleus
77  for (unsigned i = 0; i < _nucleus_list.size(); ++i)
78  {
79  // use a non-periodic or periodic distance
80  r = _periodic < 0
81  ? (_q_point[qp] - _nucleus_list[i].second).norm()
82  : _mesh.minPeriodicDistance(_periodic, _q_point[qp], _nucleus_list[i].second);
83  if (r < rmin)
84  rmin = r;
85  }
86 
87  // compute intensity value with smooth interface
88  Real value = 0.0;
89  if (rmin <= _radius - _int_width / 2.0) // Inside circle
90  {
91  active_nuclei++;
92  value = 1.0;
93  }
94  else if (rmin < _radius + _int_width / 2.0) // Smooth interface
95  {
96  Real int_pos = (rmin - _radius + _int_width / 2.0) / _int_width;
97  active_nuclei++;
98  value = (1.0 + std::cos(int_pos * libMesh::pi)) / 2.0;
99  }
100  _elem_map[qp] = value;
101  }
102 
103  // if the map is not empty insert it
104  if (active_nuclei > 0)
105  _nucleus_map.insert(
106  std::pair<dof_id_type, std::vector<Real>>(_current_elem->id(), _elem_map));
107  }
108 }
int _periodic
variable number to use for minPeriodicDistance calls (i.e. use the periodicity of this variable) ...
const Real _int_width
Nucleus interface width.
const Real _radius
Nucleus radius.
std::vector< Real > _elem_map
Buffer for building the per QP map.
bool _rebuild_map
Do we need to rebuild the map during this timestep?
const DiscreteNucleationInserterBase::NucleusList & _nucleus_list
list of nuclei maintained bu the inserter object

◆ finalize()

virtual void DiscreteNucleationMap::finalize ( )
inlinevirtual

Definition at line 34 of file DiscreteNucleationMap.h.

34 {}

◆ getInserter()

const DiscreteNucleationInserterBase& DiscreteNucleationMap::getInserter ( ) const
inline

Definition at line 40 of file DiscreteNucleationMap.h.

40 { return _inserter; }
const DiscreteNucleationInserterBase & _inserter
UserObject that manages nucleus insertin and deletion.

◆ getPeriodic()

Real DiscreteNucleationMap::getPeriodic ( ) const
inline

Definition at line 42 of file DiscreteNucleationMap.h.

42 { return _periodic; }
int _periodic
variable number to use for minPeriodicDistance calls (i.e. use the periodicity of this variable) ...

◆ getRadiusAndWidth()

std::pair<Real, Real> DiscreteNucleationMap::getRadiusAndWidth ( ) const
inline

Definition at line 41 of file DiscreteNucleationMap.h.

41 { return std::make_pair(_radius, _int_width); }
const Real _int_width
Nucleus interface width.
const Real _radius
Nucleus radius.

◆ initialize()

void DiscreteNucleationMap::initialize ( )
virtual

Definition at line 49 of file DiscreteNucleationMap.C.

50 {
52  {
53  _rebuild_map = true;
54  _nucleus_map.clear();
55  }
56  else
57  _rebuild_map = false;
58 
59  _mesh_changed = false;
60 }
const DiscreteNucleationInserterBase & _inserter
UserObject that manages nucleus insertin and deletion.
bool _mesh_changed
Did the mesh change since the last execution of this PP?
bool _rebuild_map
Do we need to rebuild the map during this timestep?

◆ meshChanged()

void DiscreteNucleationMap::meshChanged ( )
virtual

Definition at line 122 of file DiscreteNucleationMap.C.

123 {
124  _mesh_changed = true;
125 }
bool _mesh_changed
Did the mesh change since the last execution of this PP?

◆ nuclei()

const std::vector< Real > & DiscreteNucleationMap::nuclei ( const Elem *  elem) const

Definition at line 128 of file DiscreteNucleationMap.C.

Referenced by DiscreteNucleation::computeProperties(), DiscreteNucleationForce::precalculateResidual(), and DiscreteNucleationAux::precalculateValue().

129 {
130  NucleusMap::const_iterator i = _nucleus_map.find(elem->id());
131 
132  // if no entry in the map was found the element contains no nucleus
133  if (i == _nucleus_map.end())
134  return _zero_map;
135 
136  return i->second;
137 }
std::vector< Real > _zero_map
Dummy map for elements without nuclei.

◆ threadJoin()

void DiscreteNucleationMap::threadJoin ( const UserObject &  y)
virtual

Definition at line 111 of file DiscreteNucleationMap.C.

112 {
113  // if the map needs to be updated we merge the maps from all threads
114  if (_rebuild_map)
115  {
116  const DiscreteNucleationMap & uo = static_cast<const DiscreteNucleationMap &>(y);
117  _nucleus_map.insert(uo._nucleus_map.begin(), uo._nucleus_map.end());
118  }
119 }
This UserObject maintains a per QP map that indicates if a nucleus is present or not.
bool _rebuild_map
Do we need to rebuild the map during this timestep?

Member Data Documentation

◆ _elem_map

std::vector<Real> DiscreteNucleationMap::_elem_map
protected

Buffer for building the per QP map.

Definition at line 52 of file DiscreteNucleationMap.h.

Referenced by execute().

◆ _inserter

const DiscreteNucleationInserterBase& DiscreteNucleationMap::_inserter
protected

UserObject that manages nucleus insertin and deletion.

Definition at line 58 of file DiscreteNucleationMap.h.

Referenced by getInserter(), and initialize().

◆ _int_width

const Real DiscreteNucleationMap::_int_width
protected

Nucleus interface width.

Definition at line 67 of file DiscreteNucleationMap.h.

Referenced by execute(), and getRadiusAndWidth().

◆ _mesh_changed

bool DiscreteNucleationMap::_mesh_changed
protected

Did the mesh change since the last execution of this PP?

Definition at line 46 of file DiscreteNucleationMap.h.

Referenced by initialize(), and meshChanged().

◆ _nucleus_list

const DiscreteNucleationInserterBase::NucleusList& DiscreteNucleationMap::_nucleus_list
protected

list of nuclei maintained bu the inserter object

Definition at line 70 of file DiscreteNucleationMap.h.

Referenced by execute().

◆ _nucleus_map

NucleusMap DiscreteNucleationMap::_nucleus_map
protected

Definition at line 74 of file DiscreteNucleationMap.h.

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

◆ _periodic

int DiscreteNucleationMap::_periodic
protected

variable number to use for minPeriodicDistance calls (i.e. use the periodicity of this variable)

Definition at line 61 of file DiscreteNucleationMap.h.

Referenced by execute(), and getPeriodic().

◆ _radius

const Real DiscreteNucleationMap::_radius
protected

Nucleus radius.

Definition at line 64 of file DiscreteNucleationMap.h.

Referenced by execute(), and getRadiusAndWidth().

◆ _rebuild_map

bool DiscreteNucleationMap::_rebuild_map
protected

Do we need to rebuild the map during this timestep?

Definition at line 49 of file DiscreteNucleationMap.h.

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

◆ _zero_map

std::vector<Real> DiscreteNucleationMap::_zero_map
protected

Dummy map for elements without nuclei.

Definition at line 55 of file DiscreteNucleationMap.h.

Referenced by DiscreteNucleationMap(), and nuclei().


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