$extrastylesheet
#include <location_maps.h>
Public Member Functions | |
| void | init (MeshBase &) |
| void | clear () |
| void | insert (T &) |
| bool | empty () const |
| T * | find (const Point &, const Real tol=TOLERANCE) |
| Point | point_of (const T &) const |
| template<> | |
| Point | point_of (const Node &node) const |
| template<> | |
| Point | point_of (const Elem &elem) const |
Protected Member Functions | |
| unsigned int | key (const Point &) |
| void | fill (MeshBase &) |
| template<> | |
| void | fill (MeshBase &mesh) |
| template<> | |
| void | fill (MeshBase &mesh) |
Private Types | |
| typedef LIBMESH_BEST_UNORDERED_MULTIMAP < unsigned int, T * > | map_type |
Private Attributes | |
| map_type | _map |
| std::vector< Real > | _lower_bound |
| std::vector< Real > | _upper_bound |
Data structures that enable location-based lookups The key is a hash of the Point location. For efficiency we will use a hashed multimap if it is available, otherwise a regular multimap.
Definition at line 49 of file location_maps.h.
typedef LIBMESH_BEST_UNORDERED_MULTIMAP<unsigned int, T*> libMesh::LocationMap< T >::map_type [private] |
Definition at line 51 of file location_maps.h.
| void libMesh::LocationMap< T >::clear | ( | ) | [inline] |
Definition at line 55 of file location_maps.h.
Referenced by libMesh::MeshRefinement::clear().
{ _map.clear(); }
| bool libMesh::LocationMap< T >::empty | ( | ) | const [inline] |
Definition at line 59 of file location_maps.h.
Referenced by libMesh::Parallel::sync_dofobject_data_by_xyz().
{ return _map.empty(); }
| void libMesh::LocationMap< T >::fill | ( | MeshBase & | ) | [protected] |
| void libMesh::LocationMap< Node >::fill | ( | MeshBase & | mesh | ) | [protected] |
Definition at line 215 of file location_maps.C.
References end, libMesh::MeshBase::nodes_begin(), and libMesh::MeshBase::nodes_end().
| void libMesh::LocationMap< Elem >::fill | ( | MeshBase & | mesh | ) | [protected] |
Definition at line 227 of file location_maps.C.
References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), and end.
| T * libMesh::LocationMap< T >::find | ( | const Point & | p, |
| const Real | tol = TOLERANCE |
||
| ) |
Definition at line 124 of file location_maps.C.
References libMesh::TypeVector< T >::absolute_fuzzy_equals(), and libMesh::START_LOG().
Referenced by libMesh::MeshRefinement::add_point(), and libMesh::Parallel::sync_dofobject_data_by_xyz().
{
START_LOG("find()","LocationMap");
// Look for a likely key in the multimap
unsigned int pointkey = this->key(p);
// Look for the exact key first
std::pair<typename map_type::iterator,
typename map_type::iterator>
pos = _map.equal_range(pointkey);
while (pos.first != pos.second)
if (p.absolute_fuzzy_equals
(this->point_of(*(pos.first->second)), tol))
{
STOP_LOG("find()","LocationMap");
return pos.first->second;
}
else
++pos.first;
// Look for neighboring bins' keys next
for (int xoffset = -1; xoffset != 2; ++xoffset)
{
for (int yoffset = -1; yoffset != 2; ++yoffset)
{
for (int zoffset = -1; zoffset != 2; ++zoffset)
{
std::pair<typename map_type::iterator,
typename map_type::iterator>
key_pos = _map.equal_range(pointkey +
xoffset*chunkmax*chunkmax +
yoffset*chunkmax +
zoffset);
while (key_pos.first != key_pos.second)
if (p.absolute_fuzzy_equals
(this->point_of(*(key_pos.first->second)), tol))
{
STOP_LOG("find()","LocationMap");
return key_pos.first->second;
}
else
++key_pos.first;
}
}
}
STOP_LOG("find()","LocationMap");
return NULL;
}
| void libMesh::LocationMap< T >::init | ( | MeshBase & | mesh | ) |
Definition at line 50 of file location_maps.C.
References libMesh::ParallelObject::comm(), end, libMesh::MeshBase::is_serial(), std::max(), libMesh::Parallel::Communicator::max(), std::min(), libMesh::Parallel::Communicator::min(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), and libMesh::START_LOG().
Referenced by libMesh::MeshRefinement::update_nodes_map().
{
// This function must be run on all processors at once
// for non-serial meshes
if (!mesh.is_serial())
libmesh_parallel_only(mesh.comm());
START_LOG("init()", "LocationMap");
// Clear the old map
_map.clear();
// Cache a bounding box
_lower_bound.clear();
_lower_bound.resize(LIBMESH_DIM, std::numeric_limits<Real>::max());
_upper_bound.clear();
_upper_bound.resize(LIBMESH_DIM, -std::numeric_limits<Real>::max());
MeshBase::node_iterator it = mesh.nodes_begin();
const MeshBase::node_iterator end = mesh.nodes_end();
for (; it != end; ++it)
{
Node* node = *it;
for (unsigned int i=0; i != LIBMESH_DIM; ++i)
{
// Expand the bounding box if necessary
_lower_bound[i] = std::min(_lower_bound[i],
(*node)(i));
_upper_bound[i] = std::max(_upper_bound[i],
(*node)(i));
}
}
// On a parallel mesh we might not yet have a full bounding box
if (!mesh.is_serial())
{
mesh.comm().min(_lower_bound);
mesh.comm().max(_upper_bound);
}
this->fill(mesh);
STOP_LOG("init()", "LocationMap");
}
| void libMesh::LocationMap< T >::insert | ( | T & | t | ) |
Definition at line 100 of file location_maps.C.
Referenced by libMesh::MeshRefinement::add_point().
| unsigned int libMesh::LocationMap< T >::key | ( | const Point & | p | ) | [protected] |
Definition at line 180 of file location_maps.C.
References std::abs(), libMesh::Real, and libMesh::TOLERANCE.
{
Real xscaled = 0., yscaled = 0., zscaled = 0.;
Real deltax = _upper_bound[0] - _lower_bound[0];
if (std::abs(deltax) > TOLERANCE)
xscaled = (p(0) - _lower_bound[0])/deltax;
// Only check y-coords if libmesh is compiled with LIBMESH_DIM>1
#if LIBMESH_DIM > 1
Real deltay = _upper_bound[1] - _lower_bound[1];
if (std::abs(deltay) > TOLERANCE)
yscaled = (p(1) - _lower_bound[1])/deltay;
#endif
// Only check z-coords if libmesh is compiled with LIBMESH_DIM>2
#if LIBMESH_DIM > 2
Real deltaz = _upper_bound[2] - _lower_bound[2];
if (std::abs(deltaz) > TOLERANCE)
zscaled = (p(2) - _lower_bound[2])/deltaz;
#endif
unsigned int n0 = static_cast<unsigned int> (chunkfloat * xscaled),
n1 = static_cast<unsigned int> (chunkfloat * yscaled),
n2 = static_cast<unsigned int> (chunkfloat * zscaled);
return chunkmax*chunkmax*n0 + chunkmax*n1 + n2;
}
| Point libMesh::LocationMap< T >::point_of | ( | const T & | ) | const |
Referenced by libMesh::Parallel::sync_dofobject_data_by_xyz().
| Point libMesh::LocationMap< Node >::point_of | ( | const Node & | node | ) | const |
Definition at line 108 of file location_maps.C.
{
return node;
}
| Point libMesh::LocationMap< Elem >::point_of | ( | const Elem & | elem | ) | const |
Definition at line 116 of file location_maps.C.
References libMesh::Elem::centroid().
{
return elem.centroid();
}
std::vector<Real> libMesh::LocationMap< T >::_lower_bound [private] |
Definition at line 73 of file location_maps.h.
map_type libMesh::LocationMap< T >::_map [private] |
Definition at line 72 of file location_maps.h.
Referenced by libMesh::LocationMap< Node >::clear(), and libMesh::LocationMap< Node >::empty().
std::vector<Real> libMesh::LocationMap< T >::_upper_bound [private] |
Definition at line 74 of file location_maps.h.