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

#include <NearestNodeThread.h>

Public Member Functions

 NearestNodeThread (const MooseMesh &mesh, std::map< dof_id_type, std::vector< dof_id_type >> &neighbor_nodes)
 
 NearestNodeThread (NearestNodeThread &x, Threads::split split)
 
void operator() (const NodeIdRange &range)
 Save a patch of nodes that are close to each of the slave nodes to speed the search algorithm TODO: This needs to be updated at some point in time. More...
 
void join (const NearestNodeThread &other)
 

Public Attributes

std::map< dof_id_type, NearestNodeLocator::NearestNodeInfo_nearest_node_info
 
Real _max_patch_percentage
 

Protected Attributes

const MooseMesh_mesh
 
std::map< dof_id_type, std::vector< dof_id_type > > & _neighbor_nodes
 

Detailed Description

Definition at line 20 of file NearestNodeThread.h.

Constructor & Destructor Documentation

NearestNodeThread::NearestNodeThread ( const MooseMesh mesh,
std::map< dof_id_type, std::vector< dof_id_type >> &  neighbor_nodes 
)

Definition at line 22 of file NearestNodeThread.C.

24  : _max_patch_percentage(0.0), _mesh(mesh), _neighbor_nodes(neighbor_nodes)
25 {
26 }
std::map< dof_id_type, std::vector< dof_id_type > > & _neighbor_nodes
const MooseMesh & _mesh
NearestNodeThread::NearestNodeThread ( NearestNodeThread x,
Threads::split  split 
)

Definition at line 29 of file NearestNodeThread.C.

31  _mesh(x._mesh),
33 {
34 }
std::map< dof_id_type, std::vector< dof_id_type > > & _neighbor_nodes
const MooseMesh & _mesh

Member Function Documentation

void NearestNodeThread::join ( const NearestNodeThread other)

Definition at line 97 of file NearestNodeThread.C.

98 {
99  // Did the other one go further through the patch than this one?
102 
103  _nearest_node_info.insert(other._nearest_node_info.begin(), other._nearest_node_info.end());
104 }
std::map< dof_id_type, NearestNodeLocator::NearestNodeInfo > _nearest_node_info
void NearestNodeThread::operator() ( const NodeIdRange range)

Save a patch of nodes that are close to each of the slave nodes to speed the search algorithm TODO: This needs to be updated at some point in time.

If the hits into this data structure approach "the end" then it may be time to update

Definition at line 43 of file NearestNodeThread.C.

44 {
45  for (const auto & node_id : range)
46  {
47  const Node & node = _mesh.nodeRef(node_id);
48 
49  const Node * closest_node = NULL;
50  Real closest_distance = std::numeric_limits<Real>::max();
51 
52  const std::vector<dof_id_type> & neighbor_nodes = _neighbor_nodes[node_id];
53 
54  unsigned int n_neighbor_nodes = neighbor_nodes.size();
55 
56  for (unsigned int k = 0; k < n_neighbor_nodes; k++)
57  {
58  const Node * cur_node = &_mesh.nodeRef(neighbor_nodes[k]);
59  Real distance = ((*cur_node) - node).norm();
60 
61  if (distance < closest_distance)
62  {
63  Real patch_percentage = static_cast<Real>(k) / static_cast<Real>(n_neighbor_nodes);
64 
65  // Save off the maximum we had to go through the patch to find the closes node
66  if (patch_percentage > _max_patch_percentage)
67  _max_patch_percentage = patch_percentage;
68 
69  closest_distance = distance;
70  closest_node = cur_node;
71  }
72  }
73 
74  if (closest_distance == std::numeric_limits<Real>::max())
75  {
76  for (unsigned int k = 0; k < n_neighbor_nodes; k++)
77  {
78  const Node * cur_node = &_mesh.nodeRef(neighbor_nodes[k]);
79  if (std::isnan((*cur_node)(0)) || std::isinf((*cur_node)(0)) ||
80  std::isnan((*cur_node)(1)) || std::isinf((*cur_node)(1)) ||
81  std::isnan((*cur_node)(2)) || std::isinf((*cur_node)(2)))
82  mooseError("Failure in NearestNodeThread because solution contains inf or not-a-number "
83  "entries. This is likely due to a failed factorization of the Jacobian "
84  "matrix.");
85  }
86  mooseError("Unable to find nearest node!");
87  }
88 
90 
91  info._nearest_node = closest_node;
92  info._distance = closest_distance;
93  }
94 }
std::map< dof_id_type, std::vector< dof_id_type > > & _neighbor_nodes
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::map< dof_id_type, NearestNodeLocator::NearestNodeInfo > _nearest_node_info
Data structure used to hold nearest node info.
const MooseMesh & _mesh
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:437

Member Data Documentation

Real NearestNodeThread::_max_patch_percentage

Definition at line 38 of file NearestNodeThread.h.

Referenced by NearestNodeLocator::findNodes(), join(), and operator()().

const MooseMesh& NearestNodeThread::_mesh
protected

Definition at line 42 of file NearestNodeThread.h.

Referenced by operator()().

std::map<dof_id_type, NearestNodeLocator::NearestNodeInfo> NearestNodeThread::_nearest_node_info

Definition at line 34 of file NearestNodeThread.h.

Referenced by NearestNodeLocator::findNodes(), join(), and operator()().

std::map<dof_id_type, std::vector<dof_id_type> >& NearestNodeThread::_neighbor_nodes
protected

Definition at line 45 of file NearestNodeThread.h.

Referenced by operator()().


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