#include <point_locator_tree.h>
PointLocatorTree (const MeshBase &mesh, const PointLocatorBase *master=NULL)
PointLocatorTree (const MeshBase &mesh, const Trees::BuildType build_type, const PointLocatorBase *master=NULL)
~PointLocatorTree ()
virtual void clear ()
void init (const Trees::BuildType build_type)
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)
TreeBase * _tree
const Elem * _element
bool _out_of_mesh_mode
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 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:
Definition at line 52 of file point_locator_tree.h.
Definition at line 105 of file reference_counter.h.
Definition at line 35 of file point_locator_tree.C.
References init(), and Trees::NODES.
:
PointLocatorBase (mesh,master),
_tree (NULL),
_element (NULL),
_out_of_mesh_mode(false)
{
this->init(Trees::NODES);
}
Definition at line 48 of file point_locator_tree.C.
References init().
:
PointLocatorBase (mesh,master),
_tree (NULL),
_element (NULL),
_out_of_mesh_mode(false)
{
this->init(build_type);
}
Definition at line 62 of file point_locator_tree.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 70 of file point_locator_tree.C.
References PointLocatorBase::_master, and _tree.
Referenced by ~PointLocatorTree().
{
// only delete the tree when we are the master
if (this->_tree != NULL)
{
if (this->_master == NULL)
// we own the tree
delete this->_tree;
else
// someone else owns and therefore deletes the tree
this->_tree = NULL;
}
}
Implements PointLocatorBase.
Definition at line 246 of file point_locator_tree.C.
References _out_of_mesh_mode.
{
_out_of_mesh_mode = false;
}
Implements PointLocatorBase.
Definition at line 221 of file point_locator_tree.C.
References PointLocatorBase::_mesh, _out_of_mesh_mode, MeshBase::active_elements_begin(), and MeshBase::active_elements_end().
{
/* Out-of-mesh mode is currently only supported if all of the
elements have affine mappings. The reason is that for quadratic
mappings, it is not easy to construct a relyable bounding box of
the element, and thus, the fallback linear search in
operator() is required. Hence, out-of-mesh mode would be
extremely slow. */
if(!_out_of_mesh_mode)
{
#ifdef DEBUG
MeshBase::const_element_iterator pos = this->_mesh.active_elements_begin();
const MeshBase::const_element_iterator end_pos = this->_mesh.active_elements_end();
for ( ; pos != end_pos; ++pos)
if (!(*pos)->has_affine_map())
{
std::cerr << 'ERROR: Out-of-mesh mode is currently only supported if all elements have affine mappings.' << std::endl;
libmesh_error();
}
#endif
_out_of_mesh_mode = true;
}
}
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++;
}
Definition at line 88 of file point_locator_tree.C.
References _element, PointLocatorBase::_initialized, PointLocatorBase::_master, PointLocatorBase::_mesh, _tree, MeshTools::bounding_box(), PointLocatorBase::initialized(), and MeshBase::mesh_dimension().
{
libmesh_assert (this->_tree == NULL);
if (this->_initialized)
{
std::cerr << 'ERROR: Already initialized! Will ignore this call...'
<< std::endl;
}
else
{
if (this->_master == NULL)
{
if (this->_mesh.mesh_dimension() == 3)
_tree = new Trees::OctTree (this->_mesh, 200, build_type);
else
{
// A 1D/2D mesh in 3D space needs special consideration.
// If the mesh is planar XY, we want to build a QuadTree
// to search efficiently. If the mesh is truly a manifold,
// then we need an octree
bool is_planar_xy = false;
// Build the bounding box for the mesh. If the delta-z bound is
// negligibly small then we can use a quadtree.
{
MeshTools::BoundingBox bbox = MeshTools::bounding_box(this->_mesh);
const Real
Dx = bbox.second(0) - bbox.first(0),
Dz = bbox.second(2) - bbox.first(2);
if (std::abs(Dz/(Dx + 1.e-20)) < 1e-10)
is_planar_xy = true;
}
if (is_planar_xy)
_tree = new Trees::QuadTree (this->_mesh, 200, build_type);
else
_tree = new Trees::OctTree (this->_mesh, 200, build_type);
}
}
else
{
// We are _not_ the master. Let our Tree point to
// the master's tree. But for this we first transform
// the master in a state for which we are friends.
// And make sure the master @e has a tree!
const PointLocatorTree* my_master =
libmesh_cast_ptr<const PointLocatorTree*>(this->_master);
if (my_master->initialized())
this->_tree = my_master->_tree;
else
{
std::cerr << 'ERROR: Initialize master first, then servants!'
<< std::endl;
libmesh_error();
}
}
// Not all PointLocators may own a tree, but all of them
// use their own element pointer. Let the element pointer
// be unique for every interpolator.
// Suppose the interpolators are used concurrently
// at different locations in the mesh, then it makes quite
// sense to have unique start elements.
this->_element = NULL;
}
// ready for take-off
this->_initialized = true;
}
Implements PointLocatorBase.
Definition at line 108 of file point_locator_tree.h.
References init(), and Trees::NODES.
Referenced by init(), and PointLocatorTree().
{ this->init(Trees::NODES); };
Definition at line 150 of file point_locator_base.h.
References PointLocatorBase::_initialized.
Referenced by init(), and PointLocatorList::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 173 of file point_locator_tree.C.
References _element, PointLocatorBase::_initialized, PointLocatorBase::_mesh, _out_of_mesh_mode, _tree, Elem::active(), MeshBase::active_elements_begin(), MeshBase::active_elements_end(), Elem::contains_point(), and TreeBase::find_element().
{
libmesh_assert (this->_initialized);
// First check the element from last time before asking the tree
if (this->_element==NULL || !(this->_element->contains_point(p)))
{
// ask the tree
this->_element = this->_tree->find_element (p);
if (this->_element == NULL)
{
/* No element seems to contain this point. If out-of-mesh
mode is enabled, just return NULL. If not, however, we
have to perform a linear search before we call
libmesh_error() since in the case of curved elements, the
bounding box computed in
TreeNode::insert(const
Elem*) might be slightly inaccurate. */
if(!_out_of_mesh_mode)
{
MeshBase::const_element_iterator pos = this->_mesh.active_elements_begin();
const MeshBase::const_element_iterator end_pos = this->_mesh.active_elements_end();
for ( ; pos != end_pos; ++pos)
if ((*pos)->contains_point(p))
return this->_element = (*pos);
if (this->_element == NULL)
{
std::cerr << std::endl
<< ' ******** Serious Problem. Could not find an Element '
<< 'in the Mesh'
<< std:: endl
<< ' ******** that contains the Point '
<< p;
libmesh_error();
}
}
}
}
// the element should be active
libmesh_assert (this->_element->active());
// return the element
return this->_element;
}
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 147 of file point_locator_tree.h.
Referenced by init(), and operator()().
Definition at line 142 of file point_locator_base.h.
Referenced by init(), PointLocatorList::init(), PointLocatorBase::initialized(), operator()(), and PointLocatorList::operator()().
Definition at line 132 of file point_locator_base.h.
Referenced by clear(), PointLocatorList::clear(), init(), and PointLocatorList::init().
Definition at line 137 of file point_locator_base.h.
Referenced by enable_out_of_mesh_mode(), init(), PointLocatorList::init(), and 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().
Definition at line 153 of file point_locator_tree.h.
Referenced by disable_out_of_mesh_mode(), enable_out_of_mesh_mode(), and operator()().
Definition at line 140 of file point_locator_tree.h.
Referenced by clear(), init(), and operator()().
Generated automatically by Doxygen for libMesh from the source code.