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
 

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 DiscreteNucleationInserter_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 DiscreteNucleationInserter::NucleusList_nucleus_list
 list of nuclei maintained bu the inserter object More...
 
using NucleusMap = std::unordered_map< dof_id_type, std::vector< Real >>
 
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 23 of file DiscreteNucleationMap.h.

Member Typedef Documentation

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 67 of file DiscreteNucleationMap.h.

Constructor & Destructor Documentation

DiscreteNucleationMap::DiscreteNucleationMap ( const InputParameters &  parameters)

Definition at line 34 of file DiscreteNucleationMap.C.

35  : ElementUserObject(parameters),
36  _mesh_changed(false),
37  _inserter(getUserObject<DiscreteNucleationInserter>("inserter")),
38  _periodic(isCoupled("periodic") ? coupled("periodic") : -1),
39  _radius(getParam<Real>("radius")),
40  _int_width(getParam<Real>("int_width")),
42 {
43  _zero_map.assign(_fe_problem.getMaxQps(), 0.0);
44 }
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) ...
const Real _int_width
Nucleus interface width.
const DiscreteNucleationInserter & _inserter
UserObject that manages nucleus insertin and deletion.
std::vector< Real > _zero_map
Dummy map for elements without nuclei.
const Real _radius
Nucleus radius.
const DiscreteNucleationInserter::NucleusList & _nucleus_list
list of nuclei maintained bu the inserter object
const NucleusList & getNucleusList() const

Member Function Documentation

void DiscreteNucleationMap::execute ( )
virtual

Definition at line 61 of file DiscreteNucleationMap.C.

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

Definition at line 31 of file DiscreteNucleationMap.h.

31 {}
void DiscreteNucleationMap::initialize ( )
virtual

Definition at line 47 of file DiscreteNucleationMap.C.

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

Definition at line 120 of file DiscreteNucleationMap.C.

Referenced by finalize().

121 {
122  _mesh_changed = true;
123 }
bool _mesh_changed
Did the mesh change since the last execution of this PP?
const std::vector< Real > & DiscreteNucleationMap::nuclei ( const Elem *  elem) const

Definition at line 126 of file DiscreteNucleationMap.C.

Referenced by DiscreteNucleation::computeProperties(), and finalize().

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

Definition at line 109 of file DiscreteNucleationMap.C.

110 {
111  // if the map needs to be updated we merge the maps from all threads
112  if (_rebuild_map)
113  {
114  const DiscreteNucleationMap & uo = static_cast<const DiscreteNucleationMap &>(y);
115  _nucleus_map.insert(uo._nucleus_map.begin(), uo._nucleus_map.end());
116  }
117 }
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

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

Buffer for building the per QP map.

Definition at line 45 of file DiscreteNucleationMap.h.

Referenced by execute().

const DiscreteNucleationInserter& DiscreteNucleationMap::_inserter
protected

UserObject that manages nucleus insertin and deletion.

Definition at line 51 of file DiscreteNucleationMap.h.

Referenced by initialize().

const Real DiscreteNucleationMap::_int_width
protected

Nucleus interface width.

Definition at line 60 of file DiscreteNucleationMap.h.

Referenced by execute().

bool DiscreteNucleationMap::_mesh_changed
protected

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

Definition at line 39 of file DiscreteNucleationMap.h.

Referenced by initialize(), and meshChanged().

const DiscreteNucleationInserter::NucleusList& DiscreteNucleationMap::_nucleus_list
protected

list of nuclei maintained bu the inserter object

Definition at line 63 of file DiscreteNucleationMap.h.

Referenced by execute().

NucleusMap DiscreteNucleationMap::_nucleus_map
protected

Definition at line 68 of file DiscreteNucleationMap.h.

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

int DiscreteNucleationMap::_periodic
protected

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

Definition at line 54 of file DiscreteNucleationMap.h.

Referenced by execute().

const Real DiscreteNucleationMap::_radius
protected

Nucleus radius.

Definition at line 57 of file DiscreteNucleationMap.h.

Referenced by execute().

bool DiscreteNucleationMap::_rebuild_map
protected

Do we need to rebuild the map during this timestep?

Definition at line 42 of file DiscreteNucleationMap.h.

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

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

Dummy map for elements without nuclei.

Definition at line 48 of file DiscreteNucleationMap.h.

Referenced by DiscreteNucleationMap(), and nuclei().


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