https://mooseframework.inl.gov
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 secondary 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 14 of file NearestNodeThread.h.

Constructor & Destructor Documentation

◆ NearestNodeThread() [1/2]

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

Definition at line 18 of file NearestNodeThread.C.

20  : _max_patch_percentage(0.0), _mesh(mesh), _neighbor_nodes(neighbor_nodes)
21 {
22 }
std::map< dof_id_type, std::vector< dof_id_type > > & _neighbor_nodes
const MooseMesh & _mesh

◆ NearestNodeThread() [2/2]

NearestNodeThread::NearestNodeThread ( NearestNodeThread x,
Threads::split  split 
)

Definition at line 25 of file NearestNodeThread.C.

27  _mesh(x._mesh),
29 {
30 }
std::map< dof_id_type, std::vector< dof_id_type > > & _neighbor_nodes
const MooseMesh & _mesh

Member Function Documentation

◆ join()

void NearestNodeThread::join ( const NearestNodeThread other)

Definition at line 94 of file NearestNodeThread.C.

95 {
96  // Did the other one go further through the patch than this one?
99 
100  _nearest_node_info.insert(other._nearest_node_info.begin(), other._nearest_node_info.end());
101 }
std::map< dof_id_type, NearestNodeLocator::NearestNodeInfo > _nearest_node_info

◆ operator()()

void NearestNodeThread::operator() ( const NodeIdRange range)

Save a patch of nodes that are close to each of the secondary 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 39 of file NearestNodeThread.C.

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

Member Data Documentation

◆ _max_patch_percentage

Real NearestNodeThread::_max_patch_percentage

Definition at line 32 of file NearestNodeThread.h.

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

◆ _mesh

const MooseMesh& NearestNodeThread::_mesh
protected

Definition at line 36 of file NearestNodeThread.h.

Referenced by operator()().

◆ _nearest_node_info

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

Definition at line 28 of file NearestNodeThread.h.

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

◆ _neighbor_nodes

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

Definition at line 39 of file NearestNodeThread.h.

Referenced by operator()().


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