Go to the documentation of this file.
   23 #include "libmesh/elem.h" 
   24 #include "libmesh/libmesh_logging.h" 
   25 #include "libmesh/mesh_base.h" 
   26 #include "libmesh/mesh_tools.h" 
   27 #include "libmesh/point_locator_tree.h" 
   28 #include "libmesh/tree.h" 
   42   _out_of_mesh_mode(false),
 
   43   _target_bin_size (200),
 
   44   _build_type(Trees::
NODES)
 
   57   _out_of_mesh_mode(false),
 
   58   _target_bin_size (200),
 
   59   _build_type(build_type)
 
   76   if (this->
_tree != 
nullptr)
 
   83         this->
_tree = 
nullptr;
 
  106       libMesh::err << 
"Warning: PointLocatorTree already initialized!  Will ignore this call..." << std::endl;
 
  112                        << 
"Your requested build_type, " << build_type << 
" will not be used!" << std::endl;
 
  125           LOG_SCOPE(
"init(no master)", 
"PointLocatorTree");
 
  136               bool is_planar_xy = 
false;
 
  144                   Dx = bbox.second(0) - bbox.first(0),
 
  145                   Dz = bbox.second(2) - bbox.first(2);
 
  150                 if ( (
std::abs(Dz/(Dx + 1.e-20)) < 1e-10) && (
std::abs(bbox.second(2)) < 1.e-10) )
 
  173             cast_ptr<const PointLocatorTree *>(this->
_master);
 
  178             libmesh_error_msg(
"ERROR: Initialize master first, then servants!");
 
  197                                            const std::set<subdomain_id_type> * allowed_subdomains)
 const 
  201   LOG_SCOPE(
"operator()", 
"PointLocatorTree");
 
  204   if (allowed_subdomains && this->
_element && !allowed_subdomains->count(this->_element->subdomain_id())) this->
_element = 
nullptr;
 
  220                   libMesh::out << 
"Performing linear search using close-to-point tolerance " 
  249   libmesh_assert (!this->
_element || !allowed_subdomains || allowed_subdomains->count(this->_element->subdomain_id()));
 
  257                                    std::set<const Elem *> & candidate_elements,
 
  258                                    const std::set<subdomain_id_type> * allowed_subdomains)
 const 
  262   LOG_SCOPE(
"operator() - Version 2", 
"PointLocatorTree");
 
  271                                                      const std::set<subdomain_id_type> * allowed_subdomains,
 
  272                                                      bool use_close_to_point,
 
  273                                                      Real close_to_point_tolerance)
 const 
  275   LOG_SCOPE(
"perform_linear_search", 
"PointLocatorTree");
 
  286   for (
const auto & elem : r)
 
  288       if (!allowed_subdomains ||
 
  289           allowed_subdomains->count(elem->subdomain_id()))
 
  291           if (!use_close_to_point)
 
  293               if (elem->contains_point(p))
 
  298               if (elem->close_to_point(p, close_to_point_tolerance))
 
  309                                                                      const std::set<subdomain_id_type> * allowed_subdomains,
 
  310                                                                      Real close_to_point_tolerance)
 const 
  312   LOG_SCOPE(
"perform_fuzzy_linear_search", 
"PointLocatorTree");
 
  314   std::set<const Elem *> candidate_elements;
 
  325   for (
const auto & elem : r)
 
  326     if ((!allowed_subdomains || allowed_subdomains->count(elem->subdomain_id())) && elem->close_to_point(p, close_to_point_tolerance))
 
  327       candidate_elements.insert(elem);
 
  329   return candidate_elements;
 
  
virtual void enable_out_of_mesh_mode() override
Enables out-of-mesh mode.
 
const PointLocatorBase * _master
Const pointer to our master, initialized to nullptr if none given.
 
The SimpleRange templated class is intended to make it easy to construct ranges from pairs of iterato...
 
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
 
Trees::BuildType _build_type
How the underlying tree is built.
 
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
 
Defines a Cartesian bounding box by the two corner extremum.
 
Tree< 2 > BinaryTree
A BinaryTree is a tree appropriate for 1D meshes.
 
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
 
unsigned int _target_bin_size
Target bin size, which gets passed to the constructor of _tree.
 
The libMesh namespace provides an interface to certain functionality in the library.
 
bool _verbose
Boolean flag to indicate whether to print out extra info.
 
Real _close_to_point_tol
The tolerance to use.
 
unsigned int mesh_dimension() const
 
BuildType
enum defining how to build the tree.
 
virtual const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const =0
 
PointLocatorTree(const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Constructor.
 
void set_target_bin_size(unsigned int target)
Set the target bin size.
 
bool _use_close_to_point_tol
true if we will use a user-specified tolerance for locating the element.
 
This is the MeshBase class.
 
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
 
virtual void clear() override
Clears the locator.
 
A Point defines a location in LIBMESH_DIM dimensional Real space.
 
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 =0
Fills candidate_elements with any elements containing the specified point p, optionally restricted to...
 
bool _out_of_mesh_mode
true if out-of-mesh mode is enabled.
 
virtual void init() override
Initializes the locator, so that the operator() methods can be used.
 
virtual const Elem * operator()(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr) const override
Locates the element in which the point with global coordinates p is located, optionally restricted to...
 
const Elem * perform_linear_search(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains, bool use_close_to_point, Real close_to_point_tolerance=TOLERANCE) const
As a fallback option, it's helpful to be able to do a linear search over the entire mesh.
 
const MeshBase & _mesh
constant reference to the mesh in which the point is looked for.
 
This is the base class from which all geometric element types are derived.
 
const Elem * _element
Pointer to the last element that was found by the tree.
 
virtual void disable_out_of_mesh_mode() override
Disables out-of-mesh mode (default).
 
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
 
Tree< 8 > OctTree
An OctTree is a tree appropriate for 3D meshes.
 
This class defines a tree that may be used for fast point location in space.
 
unsigned int get_target_bin_size() const
Get the target bin size.
 
TreeBase * _tree
Pointer to our tree.
 
This is the base class for point locators.
 
bool _initialized
true when properly initialized, false otherwise.
 
Tree< 4 > QuadTree
A QuadTree is a tree appropriate for 2D meshes.
 
~PointLocatorTree()
Destructor.
 
std::set< const Elem * > perform_fuzzy_linear_search(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains, Real close_to_point_tolerance=TOLERANCE) const
A method to check if "fat" point p is in multiple elements.