https://mooseframework.inl.gov
NearestNodeLocator.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // Moose
13 #include "Restartable.h"
14 #include "PerfGraphInterface.h"
15 
16 // Forward declarations
17 class SubProblem;
18 class MooseMesh;
19 
25 {
26 public:
27  NearestNodeLocator(SubProblem & subproblem,
28  MooseMesh & mesh,
29  BoundaryID boundary1,
30  BoundaryID boundary2);
31 
33 
37  void findNodes();
38 
43  void reinit();
44 
48  Real distance(dof_id_type node_id);
49 
53  const Node * nearestNode(dof_id_type node_id);
54 
58  std::vector<dof_id_type> & secondaryNodes() { return _secondary_nodes; }
59 
65 
70  void updatePatch(std::vector<dof_id_type> & secondary_nodes);
71 
76  void updateGhostedElems();
77 
82  {
83  public:
85 
86  const Node * _nearest_node;
88  };
89 
90 protected:
92 
94 
95  std::unique_ptr<NodeIdRange> _secondary_node_range;
96 
97 public:
98  std::map<dof_id_type, NearestNodeInfo> _nearest_node_info;
99 
102 
103  bool _first;
104 
105  // Compute neighborhood nodes around the secondary nodes if iteration update strategy is selected.
106  // This flag is required for (at least initial) adaptivity in parallel and is set to true on
107  // reinit()
109 
110  std::vector<dof_id_type> _secondary_nodes;
111 
112  std::map<dof_id_type, std::vector<dof_id_type>> _neighbor_nodes;
113 
114  // The following parameter controls the patch size that is searched for each nearest neighbor
115  static const unsigned int _patch_size;
116 
117  // Contact patch update strategy
119 
120  // The furthest through the patch that had to be searched for any node last time
122 
123  // The list of ghosted elements added during a time step for iteration patch update strategy
124  std::vector<dof_id_type> _new_ghosted_elems;
125 };
std::map< dof_id_type, std::vector< dof_id_type > > _neighbor_nodes
void findNodes()
This is the main method that is going to start the search.
A class for creating restricted objects.
Definition: Restartable.h:28
std::vector< dof_id_type > & secondaryNodes()
Returns the list of secondary nodes this Locator is tracking.
Finds the nearest node to each node in boundary1 to each node in boundary2 and the other way around...
void updatePatch(std::vector< dof_id_type > &secondary_nodes)
Reconstructs the KDtree, updates the patch for the nodes in secondary_nodes, and updates the closest ...
MeshBase & mesh
Real distance(dof_id_type node_id)
Valid to call this after findNodes() has been called to get the distance to the nearest node...
void reinit()
Completely redo the search from scratch.
NearestNodeLocator(SubProblem &subproblem, MooseMesh &mesh, BoundaryID boundary1, BoundaryID boundary2)
NodeIdRange & secondaryNodeRange()
Returns the NodeIdRange of secondary nodes to be used for calling threaded functions operating on the...
Data structure used to hold nearest node info.
std::map< dof_id_type, NearestNodeInfo > _nearest_node_info
std::unique_ptr< NodeIdRange > _secondary_node_range
std::vector< dof_id_type > _secondary_nodes
boundary_id_type BoundaryID
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
const Moose::PatchUpdateType _patch_update_strategy
void updateGhostedElems()
Updates the ghosted elements at the start of the time step for iteration patch update strategy...
Interface for objects interacting with the PerfGraph.
static const unsigned int _patch_size
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
const Node * nearestNode(dof_id_type node_id)
Valid to call this after findNodes() has been called to get a pointer to the nearest node...
PatchUpdateType
Type of patch update strategy for modeling node-face constraints or contact.
Definition: MooseTypes.h:952
SubProblem & _subproblem
std::vector< dof_id_type > _new_ghosted_elems
uint8_t dof_id_type