www.mooseframework.org
Public Types | Public Member Functions | Private Attributes | List of all members
NanoflannMeshSubdomainAdaptor< Dim > Class Template Reference

Special adaptor that works with subdomains of the Mesh. More...

#include <NanoflannMeshAdaptor.h>

Public Types

typedef Real coord_t
 libMesh Point coordinate type More...
 

Public Member Functions

 NanoflannMeshSubdomainAdaptor (const MeshBase &mesh, subdomain_id_type s)
 
size_t kdtree_get_point_count () const
 Must return the number of data points. More...
 
coord_t kdtree_distance (const coord_t *p1, const size_t idx_p2, size_t size) const
 Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in _mesh. More...
 
coord_t kdtree_get_pt (const size_t idx, int dim) const
 Returns the dim'th component of the idx'th point in the class. More...
 
template<class BBOX >
bool kdtree_get_bbox (BBOX &) const
 Optional bounding-box computation: return false to default to a standard bbox computation loop. More...
 

Private Attributes

const MeshBase_mesh
 
subdomain_id_type _sid
 
std::set< dof_id_type_legal_point_indices
 

Detailed Description

template<unsigned int Dim>
class NanoflannMeshSubdomainAdaptor< Dim >

Special adaptor that works with subdomains of the Mesh.

When nanoflann asks for the distance between points p1 and p2, and p2 is not a Point of an element in the required subdomain, a "large" distance is returned. Likewise, when the coordinates of a point not in the subdomain are requested, a point at "infinity" is returned.

Definition at line 118 of file NanoflannMeshAdaptor.h.

Member Typedef Documentation

◆ coord_t

template<unsigned int Dim>
typedef Real NanoflannMeshSubdomainAdaptor< Dim >::coord_t

libMesh Point coordinate type

Definition at line 144 of file NanoflannMeshAdaptor.h.

Constructor & Destructor Documentation

◆ NanoflannMeshSubdomainAdaptor()

template<unsigned int Dim>
NanoflannMeshSubdomainAdaptor< Dim >::NanoflannMeshSubdomainAdaptor ( const MeshBase mesh,
subdomain_id_type  s 
)
inline

Definition at line 131 of file NanoflannMeshAdaptor.h.

131  : _mesh(mesh), _sid(s)
132  {
133  // Loop over the elements of the Mesh, for those in the requested
134  // subdomain, add its node ids to the _legal_point_indices set.
135  for (const auto & elem : _mesh.active_element_ptr_range())
136  if (elem->subdomain_id() == _sid)
137  for (MooseIndex(elem->n_vertices()) n = 0; n < elem->n_vertices(); ++n)
138  _legal_point_indices.insert(elem->node_id(n));
139  }
std::set< dof_id_type > _legal_point_indices

Member Function Documentation

◆ kdtree_distance()

template<unsigned int Dim>
coord_t NanoflannMeshSubdomainAdaptor< Dim >::kdtree_distance ( const coord_t p1,
const size_t  idx_p2,
size_t  size 
) const
inline

Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in _mesh.

Definition at line 155 of file NanoflannMeshAdaptor.h.

156  {
157  libmesh_assert_equal_to(size, Dim);
158 
159  // If this is not a valid point, then return a "large" distance.
160  if (!_legal_point_indices.count(static_cast<dof_id_type>(idx_p2)))
162 
163  // Construct a libmesh Point object from the input coord_t. This
164  // assumes LIBMESH_DIM==3.
165  Point point1(p1[0], size > 1 ? p1[1] : 0., size > 2 ? p1[2] : 0.);
166 
167  // Get the referred-to point from the Mesh
168  const Point & point2 = _mesh.point(idx_p2);
169 
170  // Compute Euclidean distance, squared
171  return (point1 - point2).norm_sq();
172  }
auto max(const L &left, const R &right)
auto norm_sq() const -> decltype(std::norm(Real()))
virtual const Point & point(const dof_id_type i) const=0
std::set< dof_id_type > _legal_point_indices

◆ kdtree_get_bbox()

template<unsigned int Dim>
template<class BBOX >
bool NanoflannMeshSubdomainAdaptor< Dim >::kdtree_get_bbox ( BBOX &  ) const
inline

Optional bounding-box computation: return false to default to a standard bbox computation loop.

Definition at line 195 of file NanoflannMeshAdaptor.h.

196  {
197  return false;
198  }

◆ kdtree_get_point_count()

template<unsigned int Dim>
size_t NanoflannMeshSubdomainAdaptor< Dim >::kdtree_get_point_count ( ) const
inline

Must return the number of data points.

Definition at line 149 of file NanoflannMeshAdaptor.h.

149 { return _mesh.n_nodes(); }
virtual dof_id_type n_nodes() const=0

◆ kdtree_get_pt()

template<unsigned int Dim>
coord_t NanoflannMeshSubdomainAdaptor< Dim >::kdtree_get_pt ( const size_t  idx,
int  dim 
) const
inline

Returns the dim'th component of the idx'th point in the class.

Definition at line 177 of file NanoflannMeshAdaptor.h.

178  {
179  libmesh_assert_less(dim, (int)Dim);
180  libmesh_assert_less(idx, _mesh.n_nodes());
181  libmesh_assert_less(dim, 3);
182 
183  // If this is not a valid point, then return a "large" distance.
184  if (!_legal_point_indices.count(static_cast<dof_id_type>(idx)))
186 
187  return _mesh.point(idx)(dim);
188  }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:148
auto max(const L &left, const R &right)
virtual const Point & point(const dof_id_type i) const=0
virtual dof_id_type n_nodes() const=0
std::set< dof_id_type > _legal_point_indices

Member Data Documentation

◆ _legal_point_indices

template<unsigned int Dim>
std::set<dof_id_type> NanoflannMeshSubdomainAdaptor< Dim >::_legal_point_indices
private

◆ _mesh

template<unsigned int Dim>
const MeshBase& NanoflannMeshSubdomainAdaptor< Dim >::_mesh
private

◆ _sid

template<unsigned int Dim>
subdomain_id_type NanoflannMeshSubdomainAdaptor< Dim >::_sid
private

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