#include <point_locator_list.h>
PointLocatorList (const MeshBase &mesh, const PointLocatorBase *master=NULL)
~PointLocatorList ()
virtual void clear ()
virtual void init ()
virtual const Elem * operator() (const Point &p) const
virtual void enable_out_of_mesh_mode (void)
virtual void disable_out_of_mesh_mode (void)
bool initialized () const
static AutoPtr< PointLocatorBase > build (const PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=NULL)
static std::string get_info ()
static void print_info ()
static unsigned int n_objects ()
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)
std::vector< std::pair< Point, const Elem * > > * _list
const PointLocatorBase * _master
const MeshBase & _mesh
bool _initialized
static Counts _counts
static Threads::atomic< unsigned int > _n_objects
static Threads::spin_mutex _mutex
This is a point locator. It locates points in space using a list of element centroids: given a mesh this locator returns the element that is closest to the given point in global coordinates. Note that this may yield severe difficulties in case of extremely distorted elements, e.g. infinite elements.
This list version is not efficient, but especially reliable for the case of finding the closest dim-1 element (nearest-surface-element, e.g. used for projecting boundary conditions from a surface mesh onto a volumetric mesh). It should be noted that this class only works when the element list in the associated mesh object is not modified (like refinement etc). Otherwise, the point locator has to be cleared and re-initialized. Use PointLocatorBase::build() to create objects of this type at run time.
Author:
Definition at line 67 of file point_locator_list.h.
Definition at line 105 of file reference_counter.h.
Definition at line 36 of file point_locator_list.C.
References init().
:
PointLocatorBase (mesh,master),
_list (NULL)
{
// This code will only work if your mesh is the Voroni mesh of it's
// own elements' centroids. If your mesh is that regular you might
// as well hand-code an O(1) algorithm for locating points within
// it. - RHS
libmesh_experimental();
this->init();
}
Definition at line 53 of file point_locator_list.C.
References clear().
{
this->clear ();
}
Definition at line 55 of file point_locator_base.C.
References MeshEnums::LIST, and MeshEnums::TREE.
Referenced by MeshBase::point_locator().
{
switch (t)
{
case TREE:
{
AutoPtr<PointLocatorBase> ap(new PointLocatorTree(mesh,
master));
return ap;
}
case LIST:
{
AutoPtr<PointLocatorBase> ap(new PointLocatorList(mesh,
master));
return ap;
}
default:
{
std::cerr << 'ERROR: Bad PointLocatorType = ' << t << std::endl;
libmesh_error();
}
}
libmesh_error();
AutoPtr<PointLocatorBase> ap(NULL);
return ap;
}
Implements PointLocatorBase.
Definition at line 61 of file point_locator_list.C.
References _list, and PointLocatorBase::_master.
Referenced by ~PointLocatorList().
{
// only delete the list when we are the master
if (this->_list != NULL)
{
if (this->_master == NULL)
{
// we own the list
this->_list->clear();
delete this->_list;
}
else
// someone else owns and therefore deletes the list
this->_list = NULL;
}
}
Implements PointLocatorBase.
Definition at line 208 of file point_locator_list.C.
{
/* This functionality is not yet implemented for PointLocatorList. */
libmesh_error();
}
Implements PointLocatorBase.
Definition at line 202 of file point_locator_list.C.
{
/* This functionality is not yet implemented for PointLocatorList. */
libmesh_error();
}
Definition at line 45 of file reference_counter.C.
References ReferenceCounter::_counts, and Quality::name().
Referenced by ReferenceCounter::print_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::ostringstream out;
out << '
<< ' ----------------------------------------------------------------------------
<< '| Reference count information |
<< ' ---------------------------------------------------------------------------- ;
for (Counts::iterator it = _counts.begin();
it != _counts.end(); ++it)
{
const std::string name(it->first);
const unsigned int creations = it->second.first;
const unsigned int destructions = it->second.second;
out << '| ' << name << ' reference count information:
<< '| Creations: ' << creations << '
<< '| Destructions: ' << destructions << ';
}
out << ' ---------------------------------------------------------------------------- ;
return out.str();
#else
return '';
#endif
}
Definition at line 149 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.first++;
}
Definition at line 167 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.second++;
}
Implements PointLocatorBase.
Definition at line 82 of file point_locator_list.C.
References PointLocatorBase::_initialized, _list, PointLocatorBase::_master, PointLocatorBase::_mesh, MeshBase::active_elements_begin(), MeshBase::active_elements_end(), PointLocatorBase::initialized(), and MeshBase::n_active_elem().
Referenced by PointLocatorList().
{
libmesh_assert (this->_list == NULL);
if (this->_initialized)
{
std::cerr << 'ERROR: Already initialized! Will ignore this call...'
<< std::endl;
}
else
{
if (this->_master == NULL)
{
// We are the master, so we have to build the list.
// First create it, then get a handy reference, and
// then try to speed up by reserving space...
this->_list = new std::vector<std::pair<Point, const Elem *> >;
std::vector<std::pair<Point, const Elem *> >& my_list = *(this->_list);
my_list.clear();
my_list.reserve(this->_mesh.n_active_elem());
// fill our list with the centroids and element
// pointers of the mesh. For this use the handy
// element iterators.
// const_active_elem_iterator el (this->_mesh.elements_begin());
// const const_active_elem_iterator end(this->_mesh.elements_end());
MeshBase::const_element_iterator el = _mesh.active_elements_begin();
const MeshBase::const_element_iterator end = _mesh.active_elements_end();
for (; el!=end; ++el)
my_list.push_back(std::make_pair((*el)->centroid(), *el));
}
else
{
// We are _not_ the master. Let our _list point to
// the master's list. But for this we first transform
// the master in a state for which we are friends
// (this should also beware of a bad master pointer?).
// And make sure the master @e has a list!
const PointLocatorList* my_master =
libmesh_cast_ptr<const PointLocatorList*>(this->_master);
if (my_master->initialized())
this->_list = my_master->_list;
else
{
std::cerr << 'ERROR: Initialize master first, then servants!'
<< std::endl;
libmesh_error();
}
}
}
// ready for take-off
this->_initialized = true;
}
Definition at line 150 of file point_locator_base.h.
References PointLocatorBase::_initialized.
Referenced by PointLocatorTree::init(), and init().
{
return (this->_initialized);
}
Definition at line 76 of file reference_counter.h.
References ReferenceCounter::_n_objects.
Referenced by System::read_serialized_blocked_dof_objects(), and System::write_serialized_blocked_dof_objects().
{ return _n_objects; }
Implements PointLocatorBase.
Definition at line 152 of file point_locator_list.C.
References PointLocatorBase::_initialized, _list, Elem::active(), and TypeVector< T >::size_sq().
{
libmesh_assert (this->_initialized);
// Ask the list. This is quite expensive, since
// we loop through the whole list to try to find
// the @e nearest element.
// However, there is not much else to do: when
// we would use bounding boxes like in a tree,
// it may happen that a surface element is just
// in plane with a bounding box face, and quite
// close to it. But when a point comes, this
// point may belong to the bounding box (where the
// coplanar element does @e not belong to). Then
// we would search through the elements in this
// bounding box, while the other bounding box'es
// element is closer, but we simply don't consider
// it!
//
// We _can_, however, use size_sq() instead of size()
// here to avoid repeated calls to std::sqrt(), which is
// pretty expensive.
{
std::vector<std::pair<Point, const Elem *> >& my_list = *(this->_list);
Real last_distance_sq = Point(my_list[0].first -p).size_sq();
const Elem * last_elem = NULL;
const unsigned int max_index = my_list.size();
for (unsigned int n=1; n<max_index; n++)
{
const Real current_distance_sq = Point(my_list[n].first -p).size_sq();
if (current_distance_sq < last_distance_sq)
{
last_distance_sq = current_distance_sq;
last_elem = my_list[n].second;
}
}
// the element should be active
libmesh_assert (last_elem->active());
// return the element
return (last_elem);
}
}
Definition at line 83 of file reference_counter.C.
References ReferenceCounter::get_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::cout << ReferenceCounter::get_info();
#endif
}
Definition at line 110 of file reference_counter.h.
Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().
Definition at line 142 of file point_locator_base.h.
Referenced by PointLocatorTree::init(), init(), PointLocatorBase::initialized(), PointLocatorTree::operator()(), and operator()().
Definition at line 133 of file point_locator_list.h.
Referenced by clear(), init(), and operator()().
Definition at line 132 of file point_locator_base.h.
Referenced by PointLocatorTree::clear(), clear(), PointLocatorTree::init(), and init().
Definition at line 137 of file point_locator_base.h.
Referenced by PointLocatorTree::enable_out_of_mesh_mode(), PointLocatorTree::init(), init(), and PointLocatorTree::operator()().
Definition at line 123 of file reference_counter.h.
Definition at line 118 of file reference_counter.h.
Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().
Generated automatically by Doxygen for libMesh from the source code.