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)
95 libMesh::err <<
"Warning: PointLocatorTree already initialized! Will ignore this call..." << std::endl;
101 <<
"Your requested build_type, " << build_type <<
" will not be used!" << std::endl;
114 LOG_SCOPE(
"init(no master)",
"PointLocatorTree");
116 if (LIBMESH_DIM == 1)
118 else if (LIBMESH_DIM == 2)
120 else if (this->_mesh.mesh_dimension() == 3)
129 bool is_planar_xy =
false;
136 Dx = bbox.second(0) - bbox.first(0),
137 Dz = bbox.second(2) - bbox.first(2);
142 if ( (std::abs(Dz/(Dx + 1.e-20)) < 1e-10) && (std::abs(bbox.second(2)) < 1.e-10) )
159 cast_ptr<const PointLocatorTree *>(this->
_master);
164 libmesh_error_msg(
"ERROR: Initialize master first, then servants!");
181 const std::set<subdomain_id_type> * allowed_subdomains)
const 185 LOG_SCOPE(
"operator()",
"PointLocatorTree");
188 if (allowed_subdomains && this->
_element && !allowed_subdomains->count(this->_element->subdomain_id()))
211 this->
_element = this->
_tree->find_element(p, allowed_subdomains);
221 libMesh::out <<
"Performing linear search using close-to-point tolerance " 250 libmesh_assert (!this->
_element || !allowed_subdomains || allowed_subdomains->count(this->_element->subdomain_id()));
258 std::set<const Elem *> & candidate_elements,
259 const std::set<subdomain_id_type> * allowed_subdomains)
const 263 LOG_SCOPE(
"operator() - Version 2",
"PointLocatorTree");
272 const std::set<subdomain_id_type> * allowed_subdomains,
273 bool use_close_to_point,
274 Real close_to_point_tolerance)
const 276 LOG_SCOPE(
"perform_linear_search",
"PointLocatorTree");
284 this->
_mesh.active_local_element_ptr_range() :
285 this->
_mesh.active_element_ptr_range();
287 for (
const auto & elem : r)
289 if (!allowed_subdomains ||
290 allowed_subdomains->count(elem->subdomain_id()))
292 if (!use_close_to_point)
299 if (elem->close_to_point(p, close_to_point_tolerance))
310 const std::set<subdomain_id_type> * allowed_subdomains,
311 Real close_to_point_tolerance)
const 313 LOG_SCOPE(
"perform_fuzzy_linear_search",
"PointLocatorTree");
315 std::set<const Elem *> candidate_elements;
323 this->
_mesh.active_local_element_ptr_range() :
324 this->
_mesh.active_element_ptr_range();
326 for (
const auto & elem : r)
327 if ((!allowed_subdomains || allowed_subdomains->count(elem->subdomain_id())) && elem->close_to_point(p, close_to_point_tolerance))
328 candidate_elements.insert(elem);
330 return candidate_elements;
virtual void enable_out_of_mesh_mode() override final
Enables out-of-mesh mode.
~PointLocatorTree()
Destructor.
The SimpleRange templated class is intended to make it easy to construct ranges from pairs of iterato...
BuildType
enum defining how to build the tree.
virtual const Elem * operator()(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr) const override final
Locates the element in which the point with global coordinates p is located, optionally restricted to...
bool _use_close_to_point_tol
true if we will use a user-specified tolerance for locating the element in an exhaustive search...
virtual void clear() override final
Clears the locator.
Real _close_to_point_tol
The tolerance to use.
virtual void init() override final
Initializes the locator, so that the operator() methods can be used.
std::shared_ptr< TreeBase > _tree
Pointer to our tree.
unsigned int get_target_bin_size() const
Get the target bin size.
This is the base class from which all geometric element types are derived.
bool _initialized
true when properly initialized, false otherwise.
The libMesh namespace provides an interface to certain functionality in the library.
const Elem * _element
Pointer to the last element that was found by the tree.
This is the MeshBase class.
PointLocatorTree(const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Constructor.
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
const MeshBase & _mesh
constant reference to the mesh in which the point is looked for.
This is the base class for point locators.
Trees::BuildType _build_type
How the underlying tree is built.
unsigned int _target_bin_size
Target bin size, which gets passed to the constructor of _tree.
Defines a Cartesian bounding box by the two corner extremum.
bool _out_of_mesh_mode
true if out-of-mesh mode is enabled.
virtual bool close_to_point(const Point &p, Real tol) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool _verbose
Boolean flag to indicate whether to print out extra info.
const PointLocatorBase * _master
Const pointer to our master, initialized to nullptr if none given.
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...
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.
void set_target_bin_size(unsigned int target)
Set the target bin size.
A Point defines a location in LIBMESH_DIM dimensional Real space.
bool _use_contains_point_tol
true if we will use a user-specified tolerance for locating the element.
virtual void disable_out_of_mesh_mode() override final
Disables out-of-mesh mode (default).
Real _contains_point_tol
The tolerance to use when locating an element in the tree.