libMesh::PointLocatorTree Class Reference

#include <point_locator_tree.h>

Inheritance diagram for libMesh::PointLocatorTree:

Public Member Functions

 PointLocatorTree (const MeshBase &mesh, const PointLocatorBase *master=libmesh_nullptr)
 
 PointLocatorTree (const MeshBase &mesh, const Trees::BuildType build_type, const PointLocatorBase *master=libmesh_nullptr)
 
 ~PointLocatorTree ()
 
virtual void clear () libmesh_override
 
void init (Trees::BuildType build_type)
 
virtual void init () libmesh_override
 
virtual const Elemoperator() (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=libmesh_nullptr) const libmesh_override
 
virtual void operator() (const Point &p, std::set< const Elem * > &candidate_elements, const std::set< subdomain_id_type > *allowed_subdomains=libmesh_nullptr) const libmesh_override
 
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
 
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
 
virtual void enable_out_of_mesh_mode () libmesh_override
 
virtual void disable_out_of_mesh_mode () libmesh_override
 
void set_target_bin_size (unsigned int target)
 
unsigned int get_target_bin_size () const
 
virtual const Nodelocate_node (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=libmesh_nullptr, Real tol=TOLERANCE) const
 
bool initialized () const
 
virtual void set_close_to_point_tol (Real close_to_point_tol)
 
virtual void unset_close_to_point_tol ()
 

Static Public Member Functions

static UniquePtr< PointLocatorBasebuild (PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=libmesh_nullptr)
 
static std::string get_info ()
 
static void print_info (std::ostream &out=libMesh::out)
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Public Attributes

bool _verbose
 

Protected Types

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

Protected Member Functions

void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Protected Attributes

TreeBase_tree
 
const Elem_element
 
bool _out_of_mesh_mode
 
unsigned int _target_bin_size
 
Trees::BuildType _build_type
 
const PointLocatorBase_master
 
const MeshBase_mesh
 
bool _initialized
 
bool _use_close_to_point_tol
 
Real _close_to_point_tol
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic< unsigned int > _n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 

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

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 119 of file reference_counter.h.

Constructor & Destructor Documentation

libMesh::PointLocatorTree::PointLocatorTree ( const MeshBase mesh,
const PointLocatorBase master = libmesh_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().

38  :
39  PointLocatorBase (mesh,master),
42  _out_of_mesh_mode(false),
43  _target_bin_size (200),
45 {
46  this->init(_build_type);
47 }
virtual void init() libmesh_override
MeshBase & mesh
const class libmesh_nullptr_t libmesh_nullptr
PointLocatorBase(const MeshBase &mesh, const PointLocatorBase *master)
libMesh::PointLocatorTree::PointLocatorTree ( const MeshBase mesh,
const Trees::BuildType  build_type,
const PointLocatorBase master = libmesh_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().

53  :
54  PointLocatorBase (mesh,master),
57  _out_of_mesh_mode(false),
58  _target_bin_size (200),
59  _build_type(build_type)
60 {
61  this->init(_build_type);
62 }
virtual void init() libmesh_override
MeshBase & mesh
const class libmesh_nullptr_t libmesh_nullptr
PointLocatorBase(const MeshBase &mesh, const PointLocatorBase *master)
libMesh::PointLocatorTree::~PointLocatorTree ( )

Destructor.

Definition at line 66 of file point_locator_tree.C.

References clear().

67 {
68  this->clear ();
69 }
virtual void clear() libmesh_override

Member Function Documentation

UniquePtr< PointLocatorBase > libMesh::PointLocatorBase::build ( PointLocatorType  t,
const MeshBase mesh,
const PointLocatorBase master = libmesh_nullptr 
)
staticinherited

Builds an PointLocator for the mesh mesh. Optionally takes a master PointLocator to save memory. An UniquePtr<PointLocatorBase> is returned to prevent memory leak. This way the user need not remember to delete the object.

Definition at line 65 of file point_locator_base.C.

References libMesh::Trees::ELEMENTS, libMesh::Trees::LOCAL_ELEMENTS, libMesh::TREE, libMesh::TREE_ELEMENTS, and libMesh::TREE_LOCAL_ELEMENTS.

Referenced by libMesh::MeshBase::point_locator(), and libMesh::MeshBase::sub_point_locator().

68 {
69  switch (t)
70  {
71  case TREE:
72  return UniquePtr<PointLocatorBase>(new PointLocatorTree(mesh, /*Trees::NODES,*/ master));
73 
74  case TREE_ELEMENTS:
75  return UniquePtr<PointLocatorBase>(new PointLocatorTree(mesh, Trees::ELEMENTS, master));
76 
78  return UniquePtr<PointLocatorBase>(new PointLocatorTree(mesh, Trees::LOCAL_ELEMENTS, master));
79 
80  default:
81  libmesh_error_msg("ERROR: Bad PointLocatorType = " << t);
82  }
83 
84  libmesh_error_msg("We'll never get here!");
85  return UniquePtr<PointLocatorBase>();
86 }
MeshBase & mesh
void libMesh::PointLocatorTree::clear ( )
virtual

Clears the locator. This function frees dynamic memory with "delete".

Implements libMesh::PointLocatorBase.

Definition at line 73 of file point_locator_tree.C.

References libMesh::PointLocatorBase::_initialized, libMesh::PointLocatorBase::_master, _tree, and libmesh_nullptr.

Referenced by ~PointLocatorTree().

74 {
75  // only delete the tree when we are the master
76  if (this->_tree != libmesh_nullptr)
77  {
78  if (this->_master == libmesh_nullptr)
79  // we own the tree
80  delete this->_tree;
81  else
82  // someone else owns and therefore deletes the tree
83  this->_tree = libmesh_nullptr;
84 
85  // make sure operator () throws an assertion
86  this->_initialized = false;
87  }
88 }
const class libmesh_nullptr_t libmesh_nullptr
const PointLocatorBase * _master
void libMesh::PointLocatorTree::disable_out_of_mesh_mode ( void  )
virtual

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 348 of file point_locator_tree.C.

References _out_of_mesh_mode.

349 {
350  _out_of_mesh_mode = false;
351 }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited
void libMesh::PointLocatorTree::enable_out_of_mesh_mode ( )
virtual

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 a NULL pointer instead of crashing. Per default, this mode is off.

Implements libMesh::PointLocatorBase.

Definition at line 340 of file point_locator_tree.C.

References _out_of_mesh_mode.

341 {
342  // Out-of-mesh mode should now work properly even on meshes with
343  // non-affine elements.
344  _out_of_mesh_mode = true;
345 }
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::ReferenceCounter::n_objects().

102 {
103  _enable_print_counter = true;
104  return;
105 }
std::string libMesh::ReferenceCounter::get_info ( )
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().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
unsigned int libMesh::PointLocatorTree::get_target_bin_size ( ) const

Get the target bin size.

Definition at line 360 of file point_locator_tree.C.

References _target_bin_size.

Referenced by init().

361 {
362  return _target_bin_size;
363 }
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

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

Definition at line 185 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

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

Definition at line 198 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
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 99 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(), libmesh_nullptr, libMesh::MeshBase::mesh_dimension(), and libMesh::Real.

100 {
101  libmesh_assert (!this->_tree);
102 
103  if (this->_initialized)
104  {
105  // Warn that we are already initialized
106  libMesh::err << "Warning: PointLocatorTree already initialized! Will ignore this call..." << std::endl;
107 
108  // Further warn if we try to init() again with a different build_type
109  if (_build_type != build_type)
110  {
111  libMesh::err << "Warning: PointLocatorTree is using build_type = " << _build_type << ".\n"
112  << "Your requested build_type, " << build_type << " will not be used!" << std::endl;
113  }
114  }
115 
116  else
117  {
118  // Let the requested build_type override the _build_type we were
119  // constructed with. This is no big deal since we have not been
120  // initialized before.
121  _build_type = build_type;
122 
123  if (this->_master == libmesh_nullptr)
124  {
125  LOG_SCOPE("init(no master)", "PointLocatorTree");
126 
127  if (this->_mesh.mesh_dimension() == 3)
129  else
130  {
131  // A 1D/2D mesh in 3D space needs special consideration.
132  // If the mesh is planar XY, we want to build a QuadTree
133  // to search efficiently. If the mesh is truly a manifold,
134  // then we need an octree
135 #if LIBMESH_DIM > 2
136  bool is_planar_xy = false;
137 
138  // Build the bounding box for the mesh. If the delta-z bound is
139  // negligibly small then we can use a quadtree.
140  {
141  BoundingBox bbox = MeshTools::create_bounding_box(this->_mesh);
142 
143  const Real
144  Dx = bbox.second(0) - bbox.first(0),
145  Dz = bbox.second(2) - bbox.first(2);
146 
147  if (std::abs(Dz/(Dx + 1.e-20)) < 1e-10)
148  is_planar_xy = true;
149  }
150 
151  if (!is_planar_xy)
153  else
154 #endif
155 #if LIBMESH_DIM > 1
157 #else
159 #endif
160  }
161  }
162 
163  else
164  {
165  // We are _not_ the master. Let our Tree point to
166  // the master's tree. But for this we first transform
167  // the master in a state for which we are friends.
168  // And make sure the master has a tree!
169  const PointLocatorTree * my_master =
170  cast_ptr<const PointLocatorTree *>(this->_master);
171 
172  if (my_master->initialized())
173  this->_tree = my_master->_tree;
174  else
175  libmesh_error_msg("ERROR: Initialize master first, then servants!");
176  }
177 
178  // Not all PointLocators may own a tree, but all of them
179  // use their own element pointer. Let the element pointer
180  // be unique for every interpolator.
181  // Suppose the interpolators are used concurrently
182  // at different locations in the mesh, then it makes quite
183  // sense to have unique start elements.
184  this->_element = libmesh_nullptr;
185  }
186 
187  // ready for take-off
188  this->_initialized = true;
189 }
unsigned int get_target_bin_size() const
double abs(double a)
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:341
Tree< 8 > OctTree
Definition: tree.h:134
const class libmesh_nullptr_t libmesh_nullptr
PointLocatorTree(const MeshBase &mesh, const PointLocatorBase *master=libmesh_nullptr)
libmesh_assert(j)
Tree< 4 > QuadTree
Definition: tree.h:128
OStreamProxy err(std::cerr)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int mesh_dimension() const
Definition: mesh_base.C:147
const PointLocatorBase * _master
Tree< 2 > BinaryTree
Definition: tree.h:122
void libMesh::PointLocatorTree::init ( )
virtual

Initializes the locator, so that the operator() methods can be used. This function allocates dynamic memory with "new".

Implements libMesh::PointLocatorBase.

Definition at line 92 of file point_locator_tree.C.

References _build_type.

Referenced by PointLocatorTree().

93 {
94  this->init(_build_type);
95 }
virtual void init() libmesh_override
bool libMesh::PointLocatorBase::initialized ( ) const
inherited
Returns
true when this object is properly initialized and ready for use, false otherwise.

Definition at line 58 of file point_locator_base.C.

References libMesh::PointLocatorBase::_initialized.

Referenced by init().

59 {
60  return this->_initialized;
61 }
const Node * libMesh::PointLocatorBase::locate_node ( const Point p,
const std::set< subdomain_id_type > *  allowed_subdomains = libmesh_nullptr,
Real  tol = TOLERANCE 
) const
virtualinherited
Returns
A pointer to a Node with global coordinates p or NULL 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.

Definition at line 104 of file point_locator_base.C.

References libMesh::Elem::hmax(), libmesh_nullptr, libMesh::Elem::n_nodes(), libMesh::Elem::node_ptr(), libMesh::TensorTools::norm_sq(), libMesh::PointLocatorBase::operator()(), libMesh::Elem::point(), and libMesh::Real.

Referenced by libMesh::PointLocatorBase::unset_close_to_point_tol().

107 {
108  std::set<const Elem *> candidate_elements;
109  this->operator()(p, candidate_elements, allowed_subdomains);
110 
111  for (std::set<const Elem *>::const_iterator
112  it = candidate_elements.begin();
113  it != candidate_elements.end(); ++it)
114  {
115  const Elem * elem = *it;
116  const int elem_n_nodes = elem->n_nodes();
117  const Real hmax = elem->hmax();
118  const Real dist_tol_sq = (tol * hmax) * (tol * hmax);
119 
120  for (int n=0; n != elem_n_nodes; ++n)
121  if ((elem->point(n) - p).norm_sq() < dist_tol_sq)
122  return elem->node_ptr(n);
123  }
124 
125  return libmesh_nullptr;
126 }
virtual const Elem * operator()(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=libmesh_nullptr) const =0
const class libmesh_nullptr_t libmesh_nullptr
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited
const Elem * libMesh::PointLocatorTree::operator() ( const Point p,
const std::set< subdomain_id_type > *  allowed_subdomains = libmesh_nullptr 
) const
virtual

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 193 of file point_locator_tree.C.

References libMesh::PointLocatorBase::_close_to_point_tol, _element, libMesh::PointLocatorBase::_initialized, _out_of_mesh_mode, _tree, libMesh::PointLocatorBase::_use_close_to_point_tol, libMesh::PointLocatorBase::_verbose, libMesh::Elem::active(), libMesh::Elem::contains_point(), libMesh::TreeBase::find_element(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::out, and perform_linear_search().

195 {
197 
198  LOG_SCOPE("operator()", "PointLocatorTree");
199 
200  // If we're provided with an allowed_subdomains list and have a cached element, make sure it complies
201  if (allowed_subdomains && this->_element && !allowed_subdomains->count(this->_element->subdomain_id())) this->_element = libmesh_nullptr;
202 
203  // First check the element from last time before asking the tree
204  if (this->_element==libmesh_nullptr || !(this->_element->contains_point(p)))
205  {
206  // ask the tree
207  this->_element = this->_tree->find_element (p,allowed_subdomains);
208 
209  if (this->_element == libmesh_nullptr)
210  {
211  // If we haven't found the element, we may want to do a linear
212  // search using a tolerance.
214  {
215  if (_verbose)
216  {
217  libMesh::out << "Performing linear search using close-to-point tolerance "
219  << std::endl;
220  }
221 
222  this->_element =
223  this->perform_linear_search(p,
224  allowed_subdomains,
225  /*use_close_to_point*/ true,
227 
228  return this->_element;
229  }
230 
231  // No element seems to contain this point. In theory, our
232  // tree now correctly handles curved elements. In
233  // out-of-mesh mode this is sometimes expected, and we can
234  // just return NULL without searching further. Out of
235  // out-of-mesh mode, something must have gone wrong.
236  libmesh_assert_equal_to (_out_of_mesh_mode, true);
237 
238  return this->_element;
239  }
240  }
241 
242  // If we found an element, it should be active
243  libmesh_assert (!this->_element || this->_element->active());
244 
245  // If we found an element and have a restriction list, they better match
246  libmesh_assert (!this->_element || !allowed_subdomains || allowed_subdomains->count(this->_element->subdomain_id()));
247 
248  // return the element
249  return this->_element;
250 }
bool active() const
Definition: elem.h:2059
const class libmesh_nullptr_t libmesh_nullptr
virtual const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=libmesh_nullptr, Real relative_tol=TOLERANCE) const =0
libmesh_assert(j)
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
OStreamProxy out(std::cout)
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition: elem.C:2469
void libMesh::PointLocatorTree::operator() ( const Point p,
std::set< const Elem * > &  candidate_elements,
const std::set< subdomain_id_type > *  allowed_subdomains = libmesh_nullptr 
) const
virtual

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 253 of file point_locator_tree.C.

References libMesh::PointLocatorBase::_close_to_point_tol, libMesh::PointLocatorBase::_initialized, libMesh::libmesh_assert(), and perform_fuzzy_linear_search().

256 {
258 
259  LOG_SCOPE("operator() - Version 2", "PointLocatorTree");
260 
261  // forward call to perform_linear_search
262  candidate_elements = this->perform_fuzzy_linear_search(p, allowed_subdomains, _close_to_point_tol);
263 }
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
libmesh_assert(j)
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 308 of file point_locator_tree.C.

References _build_type, libMesh::PointLocatorBase::_mesh, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), and libMesh::Trees::LOCAL_ELEMENTS.

Referenced by operator()().

311 {
312  LOG_SCOPE("perform_fuzzy_linear_search", "PointLocatorTree");
313 
314  std::set<const Elem *> candidate_elements;
315 
316  // The type of iterator depends on the Trees::BuildType
317  // used for this PointLocator. If it's
318  // TREE_LOCAL_ELEMENTS, we only want to double check
319  // local elements during this linear search.
320  MeshBase::const_element_iterator pos =
323 
324  const MeshBase::const_element_iterator end_pos =
327 
328  for ( ; pos != end_pos; ++pos)
329  {
330  if ((!allowed_subdomains || allowed_subdomains->count((*pos)->subdomain_id())) &&
331  (*pos)->close_to_point(p, close_to_point_tolerance))
332  candidate_elements.insert(*pos);
333  }
334 
335  return candidate_elements;
336 }
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
virtual element_iterator active_local_elements_end()=0
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 NULL if no element is found.

Definition at line 267 of file point_locator_tree.C.

References _build_type, libMesh::PointLocatorBase::_mesh, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libmesh_nullptr, and libMesh::Trees::LOCAL_ELEMENTS.

Referenced by operator()().

271 {
272  LOG_SCOPE("perform_linear_search", "PointLocatorTree");
273 
274  // The type of iterator depends on the Trees::BuildType
275  // used for this PointLocator. If it's
276  // TREE_LOCAL_ELEMENTS, we only want to double check
277  // local elements during this linear search.
278  MeshBase::const_element_iterator pos =
281 
282  const MeshBase::const_element_iterator end_pos =
285 
286  for ( ; pos != end_pos; ++pos)
287  {
288  if (!allowed_subdomains ||
289  allowed_subdomains->count((*pos)->subdomain_id()))
290  {
291  if (!use_close_to_point)
292  {
293  if ((*pos)->contains_point(p))
294  return (*pos);
295  }
296  else
297  {
298  if ((*pos)->close_to_point(p, close_to_point_tolerance))
299  return (*pos);
300  }
301  }
302  }
303 
304  return libmesh_nullptr;
305 }
const class libmesh_nullptr_t libmesh_nullptr
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
virtual element_iterator active_local_elements_end()=0
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

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

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::LibMeshInit().

89 {
91  out_stream << ReferenceCounter::get_info();
92 }
static std::string get_info()
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.

Definition at line 88 of file point_locator_base.C.

References libMesh::PointLocatorBase::_close_to_point_tol, and libMesh::PointLocatorBase::_use_close_to_point_tol.

Referenced by libMesh::MeshFunction::set_point_locator_tolerance().

89 {
91  _close_to_point_tol = close_to_point_tol;
92 }
void libMesh::PointLocatorTree::set_target_bin_size ( unsigned int  target)

Set the target bin size.

Definition at line 354 of file point_locator_tree.C.

References _target_bin_size.

355 {
356  _target_bin_size = target_bin_size;
357 }
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.

Definition at line 95 of file point_locator_base.C.

References libMesh::PointLocatorBase::_close_to_point_tol, libMesh::PointLocatorBase::_use_close_to_point_tol, libMesh::PointLocatorBase::locate_node(), and libMesh::TOLERANCE.

Referenced by libMesh::MeshFunction::unset_point_locator_tolerance().

Member Data Documentation

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

How the underlying tree is built.

Definition at line 194 of file point_locator_tree.h.

Referenced by init(), perform_fuzzy_linear_search(), perform_linear_search(), and PointLocatorTree().

Real libMesh::PointLocatorBase::_close_to_point_tol
protectedinherited
ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
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.

Referenced by init(), and operator()().

bool libMesh::ReferenceCounter::_enable_print_counter = true
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().

bool libMesh::PointLocatorBase::_initialized
protectedinherited

true when properly initialized, false otherwise.

Definition at line 185 of file point_locator_base.h.

Referenced by clear(), init(), libMesh::PointLocatorBase::initialized(), and operator()().

const PointLocatorBase* libMesh::PointLocatorBase::_master
protectedinherited

Const pointer to our master, initialized to NULL 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 175 of file point_locator_base.h.

Referenced by clear(), and init().

const MeshBase& libMesh::PointLocatorBase::_mesh
protectedinherited

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

Definition at line 180 of file point_locator_base.h.

Referenced by init(), perform_fuzzy_linear_search(), and perform_linear_search().

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

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

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 132 of file reference_counter.h.

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

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.

Referenced by disable_out_of_mesh_mode(), enable_out_of_mesh_mode(), and operator()().

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.

Referenced by get_target_bin_size(), and set_target_bin_size().

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.

Referenced by clear(), init(), and operator()().

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 191 of file point_locator_base.h.

Referenced by operator()(), libMesh::PointLocatorBase::set_close_to_point_tol(), and libMesh::PointLocatorBase::unset_close_to_point_tol().

bool libMesh::PointLocatorBase::_verbose
inherited

Boolean flag to indicate whether to print out extra info.

Definition at line 167 of file point_locator_base.h.

Referenced by operator()().


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