Poster of Linux kernelThe best gift for a Linux geek
Tree

Tree

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

NAME

Tree -  

SYNOPSIS


#include <tree.h>

Inherits TreeBase.  

Public Member Functions


Tree (const MeshBase &m, const unsigned int level, Trees::BuildType bt=Trees::NODES)

Tree (const Tree< N > &other_tree)

~Tree ()

void print_nodes () const

void print_elements () const

unsigned int n_active_bins () const

const Elem * find_element (const Point &p) const

const Elem * operator() (const Point &p) const
 

Static Public Member Functions


static std::string get_info ()

static void print_info ()

static unsigned int n_objects ()
 

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


const MeshBase & mesh
 

Static Protected Attributes


static Counts _counts

static Threads::atomic< unsigned int > _n_objects

static Threads::spin_mutex _mutex
 

Private Attributes


TreeNode< N > root

const Trees::BuildType build_type
 

Detailed Description

 

template<unsigned int N> class Tree< N >

This class defines a tree that may be used for fast point location in space.

Author:

Benjamin S. Kirk, 2002

Definition at line 44 of file tree.h.  

Member Typedef Documentation

 

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.

Definition at line 105 of file reference_counter.h.  

Constructor & Destructor Documentation

 

template<unsigned int N> Tree< N >::Tree (const MeshBase &m, const unsigned intlevel, Trees::BuildTypebt = Trees::NODES)Constructor.

Definition at line 36 of file tree.C.

References MeshBase::active_elements_begin(), MeshBase::active_elements_end(), MeshTools::bounding_box(), MeshTools::build_nodes_to_elem_map(), Tree< N >::build_type, Trees::ELEMENTS, TreeBase::mesh, Trees::NODES, MeshBase::nodes_begin(), MeshBase::nodes_end(), and Tree< N >::root.

                                        :
  TreeBase(m),
  root(m,level),
  build_type(bt)
{
  // Set the root node bounding box equal to the bounding
  // box for the entire domain.
  root.set_bounding_box (MeshTools::bounding_box(mesh));


  if (build_type == Trees::NODES)
    {
      // Add all the nodes to the root node.  It will 
      // automagically build the tree for us.
      MeshBase::const_node_iterator       it  = mesh.nodes_begin();
      const MeshBase::const_node_iterator end = mesh.nodes_end();

      for (; it != end; ++it)
        root.insert (*it);
      
      // Now the tree contains the nodes.
      // However, we want element pointers, so here we
      // convert between the two.
      std::vector<std::vector<const Elem*> > nodes_to_elem;
      
      MeshTools::build_nodes_to_elem_map (mesh, nodes_to_elem);      
      root.transform_nodes_to_elements (nodes_to_elem);
    }

  else if (build_type == Trees::ELEMENTS)
    {
      // Add all active elements to the root node.  It will
      // automatically build the tree for us.
      MeshBase::const_element_iterator       it  = mesh.active_elements_begin();
      const MeshBase::const_element_iterator end = mesh.active_elements_end();

      
      for (; it != end; ++it)
        root.insert (*it);
    }
}
 

template<unsigned int N> Tree< N >::Tree (const Tree< N > &other_tree) [inline]Copy-constructor.

Definition at line 137 of file tree.h.

                                        :
  TreeBase   (other_tree),
  root       (other_tree.root),
  build_type (other_tree.build_type)
{
  libmesh_error();
}
 

template<unsigned int N> Tree< N >::~Tree () [inline]Destructor.

Definition at line 61 of file tree.h.

{}
 

Member Function Documentation

 

template<unsigned int N> const Elem * Tree< N >::find_element (const Point &p) const [virtual]Returns:

a pointer to the element containing point p.

Implements TreeBase.

Definition at line 83 of file tree.C.

{
  return root.find_element(p);
}
 

std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.

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
}
 

void ReferenceCounter::increment_constructor_count (const std::string &name) [inline, protected, inherited]Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

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

void ReferenceCounter::increment_destructor_count (const std::string &name) [inline, protected, inherited]Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

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

template<unsigned int N> unsigned int Tree< N >::n_active_bins () const [inline, virtual]Returns:

the number of active bins.

Implements TreeBase.

Definition at line 78 of file tree.h.

References Tree< N >::root.

{ return root.n_active_bins(); }
 

static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.

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

template<unsigned int N> const Elem * Tree< N >::operator() (const Point &p) const [inline]Returns:

a pointer to the element containing point p.

Definition at line 149 of file tree.h.

{
  return this->find_element(p);
}
 

template<unsigned int N> void Tree< N >::print_elements () const [inline, virtual]Prints the nodes.

Implements TreeBase.

Definition at line 72 of file tree.h.

References Tree< N >::root.

  { std::cout << 'Printing elements...; root.print_elements(); }
 

void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.

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
}
 

template<unsigned int N> void Tree< N >::print_nodes () const [inline, virtual]Prints the nodes.

Implements TreeBase.

Definition at line 66 of file tree.h.

References Tree< N >::root.

  { std::cout << 'Printing nodes...; root.print_nodes(); }
 

Member Data Documentation

 

ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.

Definition at line 110 of file reference_counter.h.

Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().  

Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.

Definition at line 123 of file reference_counter.h.  

Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.

Definition at line 118 of file reference_counter.h.

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

template<unsigned int N> const Trees::BuildType Tree< N >::build_type [private]How the tree is built.

Definition at line 102 of file tree.h.

Referenced by Tree< N >::Tree().  

const MeshBase& TreeBase::mesh [protected, inherited]Constant reference to a mesh. Declared at construction.

Definition at line 101 of file tree_base.h.

Referenced by Tree< N >::Tree().  

template<unsigned int N> TreeNode<N> Tree< N >::root [private]The tree root.

Definition at line 97 of file tree.h.

Referenced by Tree< N >::n_active_bins(), Tree< N >::print_elements(), Tree< N >::print_nodes(), and Tree< N >::Tree().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Static Public Member Functions
Protected Types
Protected Member Functions
Protected Attributes
Static Protected Attributes
Private Attributes
Detailed Description
template<unsigned int N> class Tree< N >
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.
Constructor & Destructor Documentation
template<unsigned int N> Tree< N >::Tree (const MeshBase &m, const unsigned intlevel, Trees::BuildTypebt = Trees::NODES)Constructor.
template<unsigned int N> Tree< N >::Tree (const Tree< N > &other_tree) [inline]Copy-constructor.
template<unsigned int N> Tree< N >::~Tree () [inline]Destructor.
Member Function Documentation
template<unsigned int N> const Elem * Tree< N >::find_element (const Point &p) const [virtual]Returns:
std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.
void ReferenceCounter::increment_constructor_count (const std::string &name) [inline, protected, inherited]Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
void ReferenceCounter::increment_destructor_count (const std::string &name) [inline, protected, inherited]Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
template<unsigned int N> unsigned int Tree< N >::n_active_bins () const [inline, virtual]Returns:
static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.
template<unsigned int N> const Elem * Tree< N >::operator() (const Point &p) const [inline]Returns:
template<unsigned int N> void Tree< N >::print_elements () const [inline, virtual]Prints the nodes.
void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.
template<unsigned int N> void Tree< N >::print_nodes () const [inline, virtual]Prints the nodes.
Member Data Documentation
ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.
Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.
template<unsigned int N> const Trees::BuildType Tree< N >::build_type [private]How the tree is built.
const MeshBase& TreeBase::mesh [protected, inherited]Constant reference to a mesh. Declared at construction.
template<unsigned int N> TreeNode<N> Tree< N >::root [private]The tree root.
Author

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