libMesh
|
This is a point locator. More...
#include <point_locator_tree.h>
Public Member Functions | |
PointLocatorTree (const MeshBase &mesh, const PointLocatorBase *master=nullptr) | |
Constructor. More... | |
PointLocatorTree (const MeshBase &mesh, const Trees::BuildType build_type, const PointLocatorBase *master=nullptr) | |
Constructor. More... | |
~PointLocatorTree () | |
Destructor. More... | |
virtual void | clear () override final |
Clears the locator. More... | |
void | init (Trees::BuildType build_type) |
Initializes the locator, so that the operator() methods can be used. More... | |
virtual void | init () override final |
Initializes the locator, so that the operator() methods can be used. More... | |
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 a set of allowed subdomains. More... | |
virtual void | operator() (const Point &p, std::set< const Elem *> &candidate_elements, const std::set< subdomain_id_type > *allowed_subdomains=nullptr) const override final |
Locates a set of elements in proximity to the point with global coordinates p Pure virtual. More... | |
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. More... | |
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. More... | |
virtual void | enable_out_of_mesh_mode () override final |
Enables out-of-mesh mode. More... | |
virtual void | disable_out_of_mesh_mode () override final |
Disables out-of-mesh mode (default). More... | |
void | set_target_bin_size (unsigned int target) |
Set the target bin size. More... | |
unsigned int | get_target_bin_size () const |
Get the target bin size. More... | |
virtual const Node * | locate_node (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real tol=TOLERANCE) const |
bool | initialized () const |
Real | get_close_to_point_tol () const |
Get the close-to-point tolerance. More... | |
virtual void | set_close_to_point_tol (Real close_to_point_tol) |
Set a tolerance to use when determining if a point is contained within the mesh. More... | |
virtual void | unset_close_to_point_tol () |
Specify that we do not want to use a user-specified tolerance to determine if a point is contained within the mesh. More... | |
virtual void | set_contains_point_tol (Real contains_point_tol) |
Set a tolerance to use when checking if a point is within an element in the mesh. More... | |
virtual void | unset_contains_point_tol () |
Specify that we do not want to use a user-specified tolerance to determine if a point is inside an element in the mesh. More... | |
virtual Real | get_contains_point_tol () const |
Get the tolerance for determining element containment in the point locator. More... | |
bool | get_use_contains_point_tol () const |
The contains_point_tol may be nonzero (in fact it defaults to non-zero) but unless the user calls set_contains_point_tol(), it won't actually be used. More... | |
const MeshBase & | get_mesh () const |
Get a const reference to this PointLocator's mesh. More... | |
Static Public Member Functions | |
static std::unique_ptr< PointLocatorBase > | build (PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr) |
Builds an PointLocator for the mesh mesh . More... | |
static std::string | get_info () |
Gets a string containing the reference information. More... | |
static void | print_info (std::ostream &out_stream=libMesh::out) |
Prints the reference information, by default to libMesh::out . More... | |
static unsigned int | n_objects () |
Prints the number of outstanding (created, but not yet destroyed) objects. More... | |
static void | enable_print_counter_info () |
Methods to enable/disable the reference counter output from print_info() More... | |
static void | disable_print_counter_info () |
Public Attributes | |
bool | _verbose |
Boolean flag to indicate whether to print out extra info. More... | |
Protected Types | |
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Data structure to log the information. More... | |
Protected Member Functions | |
void | increment_constructor_count (const std::string &name) noexcept |
Increments the construction counter. More... | |
void | increment_destructor_count (const std::string &name) noexcept |
Increments the destruction counter. More... | |
Protected Attributes | |
std::shared_ptr< TreeBase > | _tree |
Pointer to our tree. More... | |
const Elem * | _element |
Pointer to the last element that was found by the tree. More... | |
bool | _out_of_mesh_mode |
true if out-of-mesh mode is enabled. More... | |
unsigned int | _target_bin_size |
Target bin size, which gets passed to the constructor of _tree. More... | |
Trees::BuildType | _build_type |
How the underlying tree is built. More... | |
const PointLocatorBase * | _master |
Const pointer to our master, initialized to nullptr if none given. More... | |
const MeshBase & | _mesh |
constant reference to the mesh in which the point is looked for. More... | |
bool | _initialized |
true when properly initialized, false otherwise. More... | |
bool | _use_close_to_point_tol |
true if we will use a user-specified tolerance for locating the element in an exhaustive search. More... | |
Real | _close_to_point_tol |
The tolerance to use. More... | |
bool | _use_contains_point_tol |
true if we will use a user-specified tolerance for locating the element. More... | |
Real | _contains_point_tol |
The tolerance to use when locating an element in the tree. More... | |
Static Protected Attributes | |
static Counts | _counts |
Actually holds the data. More... | |
static Threads::atomic< unsigned int > | _n_objects |
The number of objects. More... | |
static Threads::spin_mutex | _mutex |
Mutual exclusion object to enable thread-safe reference counting. More... | |
static bool | _enable_print_counter = true |
Flag to control whether reference count information is printed when print_info is called. More... | |
This is a point locator.
It locates points in space using a tree: given a mesh they return the element and local coordinates for a given point in global coordinates. Use PointLocatorBase::build()
to create objects of this type at run time.
Definition at line 49 of file point_locator_tree.h.
|
protectedinherited |
Data structure to log the information.
The log is identified by the class name.
Definition at line 119 of file reference_counter.h.
libMesh::PointLocatorTree::PointLocatorTree | ( | const MeshBase & | mesh, |
const PointLocatorBase * | master = nullptr |
||
) |
Constructor.
Needs the mesh
in which the points should be located. Optionally takes a master interpolator. This master helps in saving memory by reducing the number of trees in use. Only the master locator holds a tree, the others simply use the master's tree.
Definition at line 37 of file point_locator_tree.C.
References _build_type, and init().
libMesh::PointLocatorTree::PointLocatorTree | ( | const MeshBase & | mesh, |
const Trees::BuildType | build_type, | ||
const PointLocatorBase * | master = nullptr |
||
) |
Constructor.
Needs the mesh
in which the points should be located. Allows the user to specify the method to use when building the tree. Optionally takes a master interpolator. This master helps in saving memory by reducing the number of trees in use. Only the master locator holds a tree, the others simply use the master's tree. Allows the user to specify the build type.
Definition at line 51 of file point_locator_tree.C.
References _build_type, and init().
|
default |
Destructor.
|
staticinherited |
Builds an PointLocator for the mesh mesh
.
Optionally takes a master PointLocator to save memory. An std::unique_ptr<PointLocatorBase>
is returned to prevent memory leak. This way the user need not remember to delete the object.
Definition at line 67 of file point_locator_base.C.
References libMesh::Trees::ELEMENTS, libMesh::Trees::LOCAL_ELEMENTS, mesh, libMesh::NANOFLANN, libMesh::TREE, libMesh::TREE_ELEMENTS, and libMesh::TREE_LOCAL_ELEMENTS.
Referenced by libMesh::MeshBase::sub_point_locator().
|
finaloverridevirtual |
Clears the locator.
This function frees dynamic memory with "delete".
Implements libMesh::PointLocatorBase.
Definition at line 70 of file point_locator_tree.C.
References libMesh::PointLocatorBase::_initialized, and _tree.
|
finaloverridevirtual |
Disables out-of-mesh mode (default).
If asked to find a point that is contained in no mesh at all, the point locator will now crash.
Implements libMesh::PointLocatorBase.
Definition at line 343 of file point_locator_tree.C.
References _out_of_mesh_mode.
|
staticinherited |
Definition at line 100 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
|
finaloverridevirtual |
Enables out-of-mesh mode.
In this mode, if asked to find a point that is contained in no mesh at all, the point locator will return nullptr instead of crashing. Per default, this mode is off.
Implements libMesh::PointLocatorBase.
Definition at line 335 of file point_locator_tree.C.
References _out_of_mesh_mode.
Referenced by InfFERadialTest::testRefinement().
|
staticinherited |
Methods to enable/disable the reference counter output from print_info()
Definition at line 94 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
|
inherited |
Get the close-to-point tolerance.
Definition at line 92 of file point_locator_base.C.
References libMesh::PointLocatorBase::_close_to_point_tol.
Referenced by libMesh::MeshFunction::MeshFunction().
|
virtualinherited |
Get the tolerance for determining element containment in the point locator.
Definition at line 122 of file point_locator_base.C.
References libMesh::PointLocatorBase::_contains_point_tol.
|
staticinherited |
Gets a string containing the reference information.
Definition at line 47 of file reference_counter.C.
References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().
Referenced by libMesh::ReferenceCounter::print_info().
|
inherited |
Get a const reference to this PointLocator's mesh.
Definition at line 127 of file point_locator_base.C.
References libMesh::PointLocatorBase::_mesh.
Referenced by libMesh::PeriodicBoundaries::neighbor().
unsigned int libMesh::PointLocatorTree::get_target_bin_size | ( | ) | const |
Get the target bin size.
Definition at line 355 of file point_locator_tree.C.
References _target_bin_size.
Referenced by init().
|
inlineinherited |
The contains_point_tol may be nonzero (in fact it defaults to non-zero) but unless the user calls set_contains_point_tol(), it won't actually be used.
This const accessor can be used to determine the current status of this flag.
Definition at line 191 of file point_locator_base.h.
References libMesh::PointLocatorBase::_use_contains_point_tol.
|
inlineprotectednoexceptinherited |
Increments the construction counter.
Should be called in the constructor of any derived class that will be reference counted.
Definition at line 183 of file reference_counter.h.
References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().
|
inlineprotectednoexceptinherited |
Increments the destruction counter.
Should be called in the destructor of any derived class that will be reference counted.
Definition at line 207 of file reference_counter.h.
References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().
void libMesh::PointLocatorTree::init | ( | Trees::BuildType | build_type | ) |
Initializes the locator, so that the operator()
methods can be used.
This function allocates dynamic memory with "new".
Definition at line 88 of file point_locator_tree.C.
References _build_type, _element, libMesh::PointLocatorBase::_initialized, libMesh::PointLocatorBase::_master, libMesh::PointLocatorBase::_mesh, _tree, std::abs(), libMesh::MeshTools::create_bounding_box(), libMesh::err, get_target_bin_size(), libMesh::PointLocatorBase::initialized(), libMesh::libmesh_assert(), and libMesh::Real.
|
finaloverridevirtual |
Initializes the locator, so that the operator()
methods can be used.
This function allocates dynamic memory with "new".
Implements libMesh::PointLocatorBase.
Definition at line 81 of file point_locator_tree.C.
References _build_type.
Referenced by PointLocatorTree().
|
inherited |
true
when this object is properly initialized and ready for use, false
otherwise. Definition at line 60 of file point_locator_base.C.
References libMesh::PointLocatorBase::_initialized.
Referenced by init(), and libMesh::MeshFunction::MeshFunction().
|
virtualinherited |
Virtual subclasses can override for efficiency, but the base class has a default implementation that works based on element lookup.
Optionally allows the user to restrict the subdomains searched; with such a restriction, only a Node belonging to an element on one or more of those subdomains will be returned.
Will only return a Node whose distance from p
is less than tol
multiplied by the size of a semilocal element which contains p
.
Definition at line 135 of file point_locator_base.C.
References libMesh::TensorTools::norm_sq(), libMesh::PointLocatorBase::operator()(), and libMesh::Real.
|
inlinestaticinherited |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 85 of file reference_counter.h.
References libMesh::ReferenceCounter::_n_objects.
Referenced by libMesh::LibMeshInit::~LibMeshInit().
|
finaloverridevirtual |
Locates the element in which the point with global coordinates p
is located, optionally restricted to a set of allowed subdomains.
The mutable _element member is used to cache the result and allow it to be used during the next call to operator().
Implements libMesh::PointLocatorBase.
Definition at line 180 of file point_locator_tree.C.
References libMesh::PointLocatorBase::_close_to_point_tol, libMesh::PointLocatorBase::_contains_point_tol, _element, libMesh::PointLocatorBase::_initialized, _out_of_mesh_mode, _tree, libMesh::PointLocatorBase::_use_close_to_point_tol, libMesh::PointLocatorBase::_use_contains_point_tol, libMesh::PointLocatorBase::_verbose, libMesh::Elem::active(), libMesh::Elem::close_to_point(), libMesh::Elem::contains_point(), libMesh::libmesh_assert(), libMesh::out, and perform_linear_search().
|
finaloverridevirtual |
Locates a set of elements in proximity to the point with global coordinates p
Pure virtual.
Optionally allows the user to restrict the subdomains searched.
Implements libMesh::PointLocatorBase.
Definition at line 257 of file point_locator_tree.C.
References libMesh::PointLocatorBase::_close_to_point_tol, libMesh::PointLocatorBase::_initialized, _tree, and libMesh::libmesh_assert().
std::set< const Elem * > libMesh::PointLocatorTree::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.
This would happen if p is close to a face or node. This is important for evaluating MeshFunction on faces when discontinuous shape functions are used.
Definition at line 309 of file point_locator_tree.C.
References _build_type, libMesh::PointLocatorBase::_mesh, and libMesh::Trees::LOCAL_ELEMENTS.
const Elem * libMesh::PointLocatorTree::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.
This can be used if operator() fails to find an element that contains p
, for example. Optionally specify a "close to point" tolerance to use in the linear search. Return nullptr if no element is found.
Definition at line 271 of file point_locator_tree.C.
References _build_type, libMesh::PointLocatorBase::_contains_point_tol, libMesh::PointLocatorBase::_mesh, and libMesh::Trees::LOCAL_ELEMENTS.
Referenced by operator()().
|
staticinherited |
Prints the reference information, by default to libMesh::out
.
Definition at line 81 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().
Referenced by libMesh::LibMeshInit::~LibMeshInit().
|
virtualinherited |
Set a tolerance to use when determining if a point is contained within the mesh.
Definition at line 98 of file point_locator_base.C.
References libMesh::PointLocatorBase::_close_to_point_tol, and libMesh::PointLocatorBase::_use_close_to_point_tol.
|
virtualinherited |
Set a tolerance to use when checking if a point is within an element in the mesh.
Definition at line 110 of file point_locator_base.C.
References libMesh::PointLocatorBase::_contains_point_tol, and libMesh::PointLocatorBase::_use_contains_point_tol.
void libMesh::PointLocatorTree::set_target_bin_size | ( | unsigned int | target | ) |
Set the target bin size.
Definition at line 349 of file point_locator_tree.C.
References _target_bin_size.
|
virtualinherited |
Specify that we do not want to use a user-specified tolerance to determine if a point is contained within the mesh.
Definition at line 104 of file point_locator_base.C.
References libMesh::PointLocatorBase::_close_to_point_tol, libMesh::PointLocatorBase::_use_close_to_point_tol, and libMesh::TOLERANCE.
|
virtualinherited |
Specify that we do not want to use a user-specified tolerance to determine if a point is inside an element in the mesh.
Definition at line 116 of file point_locator_base.C.
References libMesh::PointLocatorBase::_contains_point_tol, libMesh::PointLocatorBase::_use_contains_point_tol, and libMesh::TOLERANCE.
|
protected |
How the underlying tree is built.
Definition at line 195 of file point_locator_tree.h.
Referenced by init(), perform_fuzzy_linear_search(), perform_linear_search(), and PointLocatorTree().
|
protectedinherited |
The tolerance to use.
Definition at line 230 of file point_locator_base.h.
Referenced by libMesh::PointLocatorBase::get_close_to_point_tol(), operator()(), libMesh::PointLocatorBase::PointLocatorBase(), libMesh::PointLocatorBase::set_close_to_point_tol(), and libMesh::PointLocatorBase::unset_close_to_point_tol().
|
protectedinherited |
The tolerance to use when locating an element in the tree.
Definition at line 241 of file point_locator_base.h.
Referenced by libMesh::PointLocatorBase::get_contains_point_tol(), libMesh::PointLocatorNanoflann::operator()(), operator()(), perform_linear_search(), libMesh::PointLocatorBase::set_contains_point_tol(), and libMesh::PointLocatorBase::unset_contains_point_tol().
|
staticprotectedinherited |
Actually holds the data.
Definition at line 124 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::get_info().
|
mutableprotected |
Pointer to the last element that was found by the tree.
Chances are that this may be close to the next call to operator()
...
Definition at line 179 of file point_locator_tree.h.
Referenced by init(), and operator()().
|
staticprotectedinherited |
Flag to control whether reference count information is printed when print_info is called.
Definition at line 143 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().
|
protectedinherited |
true
when properly initialized, false
otherwise.
Definition at line 219 of file point_locator_base.h.
Referenced by clear(), libMesh::PointLocatorNanoflann::clear(), init(), libMesh::PointLocatorNanoflann::init(), libMesh::PointLocatorBase::initialized(), libMesh::PointLocatorNanoflann::operator()(), and operator()().
|
protectedinherited |
Const pointer to our master, initialized to nullptr
if none given.
When using multiple PointLocators, one can be assigned master and be in charge of something that all can have access to.
Definition at line 209 of file point_locator_base.h.
Referenced by init(), libMesh::PointLocatorNanoflann::init(), and libMesh::PointLocatorBase::PointLocatorBase().
|
protectedinherited |
constant reference to the mesh in which the point is looked for.
Definition at line 214 of file point_locator_base.h.
Referenced by libMesh::PointLocatorBase::get_mesh(), init(), libMesh::PointLocatorNanoflann::init(), perform_fuzzy_linear_search(), and perform_linear_search().
|
staticprotectedinherited |
Mutual exclusion object to enable thread-safe reference counting.
Definition at line 137 of file reference_counter.h.
|
staticprotectedinherited |
The number of objects.
Print the reference count information when the number returns to 0.
Definition at line 132 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().
|
protected |
true
if out-of-mesh mode is enabled.
See enable_out_of_mesh_mode()
for details.
Definition at line 185 of file point_locator_tree.h.
Referenced by disable_out_of_mesh_mode(), enable_out_of_mesh_mode(), and operator()().
|
protected |
Target bin size, which gets passed to the constructor of _tree.
Definition at line 190 of file point_locator_tree.h.
Referenced by get_target_bin_size(), and set_target_bin_size().
|
protected |
Pointer to our tree.
The tree is built at run-time through init()
. For non-master PointLocators, this simply points to the tree of the master.
Definition at line 172 of file point_locator_tree.h.
Referenced by clear(), init(), and operator()().
|
protectedinherited |
true
if we will use a user-specified tolerance for locating the element in an exhaustive search.
Definition at line 225 of file point_locator_base.h.
Referenced by operator()(), libMesh::PointLocatorBase::PointLocatorBase(), libMesh::PointLocatorBase::set_close_to_point_tol(), and libMesh::PointLocatorBase::unset_close_to_point_tol().
|
protectedinherited |
true
if we will use a user-specified tolerance for locating the element.
Definition at line 236 of file point_locator_base.h.
Referenced by libMesh::PointLocatorBase::get_use_contains_point_tol(), libMesh::PointLocatorNanoflann::operator()(), operator()(), libMesh::PointLocatorBase::set_contains_point_tol(), and libMesh::PointLocatorBase::unset_contains_point_tol().
|
inherited |
Boolean flag to indicate whether to print out extra info.
Definition at line 201 of file point_locator_base.h.
Referenced by operator()().