Poster of Linux kernelThe best gift for a Linux geek
LocationMap

LocationMap

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

LocationMap -  

SYNOPSIS


#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 Elem &elem) const
 

Protected Member Functions


unsigned int key (const Point &)

void fill (MeshBase &)

template<> void fill (MeshBase &mesh)
 

Private Types


typedef std::unordered_multimap< unsigned int, T * > map_type

typedef std::tr1::unordered_multimap< unsigned int, T * > map_type

typedef std::hash_multimap< unsigned int, T * > map_type

typedef std::hash_multimap< unsigned int, T * > map_type

typedef __gnu_cxx::hash_multimap< unsigned int, T * > map_type

typedef std::multimap< unsigned int, T * > map_type

typedef std::multimap< unsigned int, T * > map_type
 

Private Attributes


map_type _map

std::vector< Real > _lower_bound

std::vector< Real > _upper_bound
 

Detailed Description

 

template<typename T> class LocationMap< T >

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 59 of file location_maps.h.  

Member Typedef Documentation

 

template<typename T> typedef std::unordered_multimap<unsigned int, T*> LocationMap< T >::map_type [private]

Definition at line 62 of file location_maps.h.  

template<typename T> typedef std::multimap<unsigned int, T*> LocationMap< T >::map_type [private]

Definition at line 78 of file location_maps.h.  

template<typename T> typedef std::multimap<unsigned int, T*> LocationMap< T >::map_type [private]

Definition at line 75 of file location_maps.h.  

template<typename T> typedef __gnu_cxx::hash_multimap<unsigned int, T*> LocationMap< T >::map_type [private]

Definition at line 71 of file location_maps.h.  

template<typename T> typedef std::hash_multimap<unsigned int, T*> LocationMap< T >::map_type [private]

Definition at line 69 of file location_maps.h.  

template<typename T> typedef std::hash_multimap<unsigned int, T*> LocationMap< T >::map_type [private]

Definition at line 66 of file location_maps.h.  

template<typename T> typedef std::tr1::unordered_multimap<unsigned int, T*> LocationMap< T >::map_type [private]

Definition at line 64 of file location_maps.h.  

Member Function Documentation

 

template<typename T> void LocationMap< T >::clear () [inline]

Definition at line 83 of file location_maps.h.

Referenced by MeshRefinement::clear().

{ _map.clear(); }
 

template<typename T> bool LocationMap< T >::empty () const [inline]

Definition at line 87 of file location_maps.h.

Referenced by MeshTools::correct_node_proc_ids(), MeshCommunication::make_nodes_parallel_consistent(), and Parallel::sync_dofobject_data_by_xyz().

{ return _map.empty(); }
 

template<typename T> void LocationMap< T >::fill (MeshBase &) [protected]

 

template<> void LocationMap< Elem >::fill (MeshBase &mesh) [protected]

Definition at line 215 of file location_maps.C.

References MeshBase::active_elements_begin(), and MeshBase::active_elements_end().

{
  // Populate the elem map
  MeshBase::element_iterator       it  = mesh.active_elements_begin(),
                                   end = mesh.active_elements_end();
  for (; it != end; ++it)
    this->insert(**it);
}
 

template<typename T > T * LocationMap< T >::find (const Point &p, const Realtol = TOLERANCE)

Definition at line 128 of file location_maps.C.

References TypeVector< T >::absolute_fuzzy_equals().

Referenced by MeshRefinement::add_point(), and 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>
                pos = _map.equal_range(pointkey +
                                       xoffset*chunkmax*chunkmax +
                                       yoffset*chunkmax +
                                       zoffset);
              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;
            }
        }
    }
  
  STOP_LOG('find()','LocationMap');
  return NULL;
}
 

template<typename T > void LocationMap< T >::init (MeshBase &mesh)

Definition at line 49 of file location_maps.C.

References MeshBase::is_serial(), std::max(), std::min(), MeshBase::nodes_begin(), and MeshBase::nodes_end().

Referenced by MeshCommunication::make_nodes_parallel_consistent(), and MeshRefinement::update_nodes_map().

{
  // This function must be run on all processors at once
  // for non-serial meshes
  if (!mesh.is_serial())
    parallel_only();

  START_LOG('init()', 'LocationMap');

  // Clear the old map
  _map.clear();

  // Cache a bounding box
  _lower_bound.clear();
  _lower_bound.resize(3, std::numeric_limits<Real>::max());
  _upper_bound.clear();
  _upper_bound.resize(3, -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;

      // Expand the bounding box if necessary
      _lower_bound[0] = std::min(_lower_bound[0],
                                 (*node)(0));
      _lower_bound[1] = std::min(_lower_bound[1],
                                 (*node)(1));
      _lower_bound[2] = std::min(_lower_bound[2],
                                 (*node)(2));
      _upper_bound[0] = std::max(_upper_bound[0],
                                 (*node)(0));
      _upper_bound[1] = std::max(_upper_bound[1],
                                 (*node)(1));
      _upper_bound[2] = std::max(_upper_bound[2],
                                 (*node)(2));
    }

  // On a parallel mesh we might not yet have a full bounding box
  if (!mesh.is_serial())
    {
      Parallel::min(_lower_bound);
      Parallel::max(_upper_bound);
    }

  this->fill(mesh);

  STOP_LOG('init()', 'LocationMap');
}
 

template<typename T> void LocationMap< T >::insert (T &t)

Definition at line 104 of file location_maps.C.

Referenced by MeshRefinement::add_point(), and LocationMap< Node >::fill().

{
  this->_map.insert(std::make_pair(this->key(this->point_of(t)), &t));
}
 

template<typename T > unsigned int LocationMap< T >::key (const Point &p) [protected]

Definition at line 184 of file location_maps.C.

{
  Real xscaled = (p(0) - _lower_bound[0])/
                 (_upper_bound[0] - _lower_bound[0]),
       yscaled = (p(1) - _lower_bound[1])/
                 (_upper_bound[1] - _lower_bound[1]),
       zscaled = (p(2) - _lower_bound[2])/
                 (_upper_bound[2] - _lower_bound[2]);

  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;
}
 

template<> Point LocationMap< Elem >::point_of (const Elem &elem) const

Definition at line 120 of file location_maps.C.

References Elem::centroid().

{
  return elem.centroid();
}
 

template<typename T> Point LocationMap< T >::point_of (const T &) const

Referenced by Parallel::sync_dofobject_data_by_xyz().  

Member Data Documentation

 

template<typename T> std::vector<Real> LocationMap< T >::_lower_bound [private]

Definition at line 101 of file location_maps.h.  

template<typename T> map_type LocationMap< T >::_map [private]

Definition at line 100 of file location_maps.h.

Referenced by LocationMap< Node >::clear(), and LocationMap< Node >::empty().  

template<typename T> std::vector<Real> LocationMap< T >::_upper_bound [private]

Definition at line 102 of file location_maps.h.

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Protected Member Functions
Private Types
Private Attributes
Detailed Description
template<typename T> class LocationMap< T >
Member Typedef Documentation
template<typename T> typedef std::unordered_multimap<unsigned int, T*> LocationMap< T >::map_type [private]
template<typename T> typedef std::multimap<unsigned int, T*> LocationMap< T >::map_type [private]
template<typename T> typedef std::multimap<unsigned int, T*> LocationMap< T >::map_type [private]
template<typename T> typedef __gnu_cxx::hash_multimap<unsigned int, T*> LocationMap< T >::map_type [private]
template<typename T> typedef std::hash_multimap<unsigned int, T*> LocationMap< T >::map_type [private]
template<typename T> typedef std::hash_multimap<unsigned int, T*> LocationMap< T >::map_type [private]
template<typename T> typedef std::tr1::unordered_multimap<unsigned int, T*> LocationMap< T >::map_type [private]
Member Function Documentation
template<typename T> void LocationMap< T >::clear () [inline]
template<typename T> bool LocationMap< T >::empty () const [inline]
template<typename T> void LocationMap< T >::fill (MeshBase &) [protected]
template<> void LocationMap< Elem >::fill (MeshBase &mesh) [protected]
template<typename T > T * LocationMap< T >::find (const Point &p, const Realtol = TOLERANCE)
template<typename T > void LocationMap< T >::init (MeshBase &mesh)
template<typename T> void LocationMap< T >::insert (T &t)
template<typename T > unsigned int LocationMap< T >::key (const Point &p) [protected]
template<> Point LocationMap< Elem >::point_of (const Elem &elem) const
template<typename T> Point LocationMap< T >::point_of (const T &) const
Member Data Documentation
template<typename T> std::vector<Real> LocationMap< T >::_lower_bound [private]
template<typename T> map_type LocationMap< T >::_map [private]
template<typename T> std::vector<Real> LocationMap< T >::_upper_bound [private]
Author

This document was created by man2html, using the manual pages.
Time: 21:49:35 GMT, April 16, 2011