23 #include "libmesh/tree.h" 24 #include "libmesh/mesh_base.h" 25 #include "libmesh/mesh_tools.h" 36 template <
unsigned int N>
38 unsigned int target_bin_size,
41 root(m,target_bin_size),
52 for (
const auto & node :
mesh.node_ptr_range())
55 bool node_was_inserted =
64 std::unordered_map<dof_id_type, std::vector<const Elem *>> nodes_to_elem;
67 root.transform_nodes_to_elements (nodes_to_elem);
74 for (
const auto & elem :
mesh.active_element_ptr_range())
77 bool elem_was_inserted =
88 for (
const auto & elem :
mesh.active_local_element_ptr_range())
91 bool elem_was_inserted =
99 libmesh_error_msg(
"Unknown build_type = " <<
build_type);
104 template <
unsigned int N>
107 my_out <<
"Printing nodes...\n";
108 root.print_nodes(my_out);
113 template <
unsigned int N>
116 my_out <<
"Printing elements...\n";
117 root.print_elements(my_out);
122 template <
unsigned int N>
125 const std::set<subdomain_id_type> * allowed_subdomains,
126 Real relative_tol)
const 128 return root.find_element(p, allowed_subdomains, relative_tol);
133 template <
unsigned int N>
136 std::set<const Elem *> & candidate_elements,
137 const std::set<subdomain_id_type> * allowed_subdomains,
138 Real relative_tol)
const 140 return root.find_elements(p, candidate_elements, allowed_subdomains, relative_tol);
145 template <
unsigned int N>
148 const std::set<subdomain_id_type> * allowed_subdomains,
149 Real relative_tol)
const 151 return this->find_element(p, allowed_subdomains, relative_tol);
TreeNode< N > root
The tree root.
virtual void print_nodes(std::ostream &my_out=libMesh::out) const override
Prints the nodes.
BuildType
enum defining how to build the tree.
const Elem * operator()(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const
virtual const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const override
This class defines a tree that may be used for fast point location in space.
This is the base class from which all geometric element types are derived.
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
virtual void find_elements(const Point &p, std::set< const Elem *> &candidate_elements, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const override
Adds to candidate_elements any elements containing the specified point p, optionally restricted to a ...
const MeshBase & mesh
Constant reference to a mesh.
virtual void print_elements(std::ostream &my_out=libMesh::out) const override
Prints the nodes.
Tree(const MeshBase &m, unsigned int target_bin_size, Trees::BuildType bt=Trees::NODES)
Constructor.
This is the base class for trees, it allows pointer usage of trees.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A Point defines a location in LIBMESH_DIM dimensional Real space.
const Trees::BuildType build_type
How the tree is built.