libMesh
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
libMesh::PointLocatorTree Class Reference

This is a point locator. More...

#include <point_locator_tree.h>

Inheritance diagram for libMesh::PointLocatorTree:
[legend]

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
 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
 Initializes the locator, so that the operator() methods can be used. More...
 
virtual const Elemoperator() (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 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
 Locates a set of elements in proximity to the point with global coordinates p Pure virtual. More...
 
const Elemperform_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
 Enables out-of-mesh mode. More...
 
virtual void disable_out_of_mesh_mode () override
 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 Nodelocate_node (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real tol=TOLERANCE) const
 
bool initialized () const
 
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...
 
const MeshBaseget_mesh () const
 Get a const reference to this PointLocator's mesh. More...
 

Static Public Member Functions

static std::unique_ptr< PointLocatorBasebuild (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=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)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

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. More...
 
Real _close_to_point_tol
 The tolerance to use. 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
 Flag to control whether reference count information is printed when print_info is called. More...
 

Detailed Description

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.

Author
Daniel Dreyer
Date
2003

Definition at line 48 of file point_locator_tree.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 117 of file reference_counter.h.

Constructor & Destructor Documentation

◆ PointLocatorTree() [1/2]

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.

◆ PointLocatorTree() [2/2]

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.

◆ ~PointLocatorTree()

libMesh::PointLocatorTree::~PointLocatorTree ( )

Destructor.

Member Function Documentation

◆ build()

static std::unique_ptr<PointLocatorBase> libMesh::PointLocatorBase::build ( PointLocatorType  t,
const MeshBase mesh,
const PointLocatorBase master = nullptr 
)
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.

◆ clear()

virtual void libMesh::PointLocatorTree::clear ( )
overridevirtual

Clears the locator.

This function frees dynamic memory with "delete".

Implements libMesh::PointLocatorBase.

◆ disable_out_of_mesh_mode()

virtual void libMesh::PointLocatorTree::disable_out_of_mesh_mode ( )
overridevirtual

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.

◆ disable_print_counter_info()

static void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

◆ enable_out_of_mesh_mode()

virtual void libMesh::PointLocatorTree::enable_out_of_mesh_mode ( )
overridevirtual

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.

◆ enable_print_counter_info()

static void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

◆ get_info()

static std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

◆ get_mesh()

const MeshBase& libMesh::PointLocatorBase::get_mesh ( ) const
inherited

Get a const reference to this PointLocator's mesh.

◆ get_target_bin_size()

unsigned int libMesh::PointLocatorTree::get_target_bin_size ( ) const

Get the target bin size.

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
protectedinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 181 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
protectedinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 194 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ init() [1/2]

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".

◆ init() [2/2]

virtual void libMesh::PointLocatorTree::init ( )
overridevirtual

Initializes the locator, so that the operator() methods can be used.

This function allocates dynamic memory with "new".

Implements libMesh::PointLocatorBase.

◆ initialized()

bool libMesh::PointLocatorBase::initialized ( ) const
inherited
Returns
true when this object is properly initialized and ready for use, false otherwise.

◆ locate_node()

virtual const Node* libMesh::PointLocatorBase::locate_node ( const Point p,
const std::set< subdomain_id_type > *  allowed_subdomains = nullptr,
Real  tol = TOLERANCE 
) const
virtualinherited
Returns
A pointer to a Node with global coordinates p or nullptr if no such Node can be found.

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.

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
staticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 83 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

84  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ operator()() [1/2]

virtual const Elem* libMesh::PointLocatorTree::operator() ( const Point p,
const std::set< subdomain_id_type > *  allowed_subdomains = nullptr 
) const
overridevirtual

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.

◆ operator()() [2/2]

virtual void libMesh::PointLocatorTree::operator() ( const Point p,
std::set< const Elem *> &  candidate_elements,
const std::set< subdomain_id_type > *  allowed_subdomains = nullptr 
) const
overridevirtual

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.

◆ perform_fuzzy_linear_search()

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.

◆ perform_linear_search()

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.

◆ print_info()

static void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

◆ set_close_to_point_tol()

virtual void libMesh::PointLocatorBase::set_close_to_point_tol ( Real  close_to_point_tol)
virtualinherited

Set a tolerance to use when determining if a point is contained within the mesh.

◆ set_target_bin_size()

void libMesh::PointLocatorTree::set_target_bin_size ( unsigned int  target)

Set the target bin size.

◆ unset_close_to_point_tol()

virtual void libMesh::PointLocatorBase::unset_close_to_point_tol ( )
virtualinherited

Specify that we do not want to use a user-specified tolerance to determine if a point is contained within the mesh.

Member Data Documentation

◆ _build_type

Trees::BuildType libMesh::PointLocatorTree::_build_type
protected

How the underlying tree is built.

Definition at line 194 of file point_locator_tree.h.

◆ _close_to_point_tol

Real libMesh::PointLocatorBase::_close_to_point_tol
protectedinherited

The tolerance to use.

Definition at line 207 of file point_locator_base.h.

◆ _counts

Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _element

const Elem* libMesh::PointLocatorTree::_element
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 178 of file point_locator_tree.h.

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 141 of file reference_counter.h.

◆ _initialized

bool libMesh::PointLocatorBase::_initialized
protectedinherited

true when properly initialized, false otherwise.

Definition at line 196 of file point_locator_base.h.

◆ _master

const PointLocatorBase* libMesh::PointLocatorBase::_master
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 186 of file point_locator_base.h.

◆ _mesh

const MeshBase& libMesh::PointLocatorBase::_mesh
protectedinherited

constant reference to the mesh in which the point is looked for.

Definition at line 191 of file point_locator_base.h.

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 of file reference_counter.h.

◆ _n_objects

Threads::atomic<unsigned int> libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 130 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _out_of_mesh_mode

bool libMesh::PointLocatorTree::_out_of_mesh_mode
protected

true if out-of-mesh mode is enabled.

See enable_out_of_mesh_mode() for details.

Definition at line 184 of file point_locator_tree.h.

◆ _target_bin_size

unsigned int libMesh::PointLocatorTree::_target_bin_size
protected

Target bin size, which gets passed to the constructor of _tree.

Definition at line 189 of file point_locator_tree.h.

◆ _tree

TreeBase* libMesh::PointLocatorTree::_tree
protected

Pointer to our tree.

The tree is built at run-time through init(). For servant PointLocators (not master), this simply points to the tree of the master.

Definition at line 171 of file point_locator_tree.h.

◆ _use_close_to_point_tol

bool libMesh::PointLocatorBase::_use_close_to_point_tol
protectedinherited

true if we will use a user-specified tolerance for locating the element.

Definition at line 202 of file point_locator_base.h.

◆ _verbose

bool libMesh::PointLocatorBase::_verbose
inherited

Boolean flag to indicate whether to print out extra info.

Definition at line 178 of file point_locator_base.h.


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