libMesh::Tree< N > Class Template Reference

#include <tree.h>

Inheritance diagram for libMesh::Tree< N >:

List of all members.

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 (std::ostream &my_out=libMesh::out) const
void print_elements (std::ostream &my_out=libMesh::out) const
unsigned int n_active_bins () const
const Elemfind_element (const Point &p) const
const Elemoperator() (const Point &p) const

Static Public Member Functions

static std::string get_info ()
static void print_info (std::ostream &out=libMesh::out)
static unsigned int n_objects ()
static void enable_print_counter_info ()
static void disable_print_counter_info ()

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 MeshBasemesh

Static Protected Attributes

static Counts _counts
static Threads::atomic
< unsigned int > 
_n_objects
static Threads::spin_mutex _mutex
static bool _enable_print_counter = true

Private Attributes

TreeNode< N > root
const Trees::BuildType build_type

Detailed Description

template<unsigned int N>
class libMesh::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 45 of file tree.h.


Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited]

Data structure to log the information. The log is identified by the class name.

Definition at line 113 of file reference_counter.h.


Constructor & Destructor Documentation

template<unsigned int N>
libMesh::Tree< N >::Tree ( const MeshBase m,
const unsigned int  level,
Trees::BuildType  bt = Trees::NODES 
) [inline]

Constructor.

Definition at line 37 of file tree.C.

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

00039                                         :
00040   TreeBase(m),
00041   root(m,level),
00042   build_type(bt)
00043 {
00044   // Set the root node bounding box equal to the bounding
00045   // box for the entire domain.
00046   root.set_bounding_box (MeshTools::bounding_box(mesh));
00047 
00048 
00049   if (build_type == Trees::NODES)
00050     {
00051       // Add all the nodes to the root node.  It will
00052       // automagically build the tree for us.
00053       MeshBase::const_node_iterator       it  = mesh.nodes_begin();
00054       const MeshBase::const_node_iterator end = mesh.nodes_end();
00055 
00056       for (; it != end; ++it)
00057         root.insert (*it);
00058 
00059       // Now the tree contains the nodes.
00060       // However, we want element pointers, so here we
00061       // convert between the two.
00062       std::vector<std::vector<const Elem*> > nodes_to_elem;
00063 
00064       MeshTools::build_nodes_to_elem_map (mesh, nodes_to_elem);
00065       root.transform_nodes_to_elements (nodes_to_elem);
00066     }
00067 
00068   else if (build_type == Trees::ELEMENTS)
00069     {
00070       // Add all active elements to the root node.  It will
00071       // automatically build the tree for us.
00072       MeshBase::const_element_iterator       it  = mesh.active_elements_begin();
00073       const MeshBase::const_element_iterator end = mesh.active_elements_end();
00074 
00075 
00076       for (; it != end; ++it)
00077         root.insert (*it);
00078     }
00079 }

template<unsigned int N>
libMesh::Tree< N >::Tree ( const Tree< N > &  other_tree  )  [inline]

Copy-constructor.

Definition at line 144 of file tree.h.

00144                                         :
00145   TreeBase   (other_tree),
00146   root       (other_tree.root),
00147   build_type (other_tree.build_type)
00148 {
00149   libmesh_error();
00150 }

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

Destructor.

Definition at line 62 of file tree.h.

00062 {}


Member Function Documentation

void libMesh::ReferenceCounter::disable_print_counter_info (  )  [static, inherited]

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00107 {
00108   _enable_print_counter = false;
00109   return;
00110 }

void libMesh::ReferenceCounter::enable_print_counter_info (  )  [static, inherited]

Methods to enable/disable the reference counter output from print_info()

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00101 {
00102   _enable_print_counter = true;
00103   return;
00104 }

template<unsigned int N>
const Elem * libMesh::Tree< N >::find_element ( const Point p  )  const [inline, virtual]
Returns:
a pointer to the element containing point p.

Implements libMesh::TreeBase.

Definition at line 84 of file tree.C.

References libMesh::Tree< N >::root.

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

00085 {
00086   return root.find_element(p);
00087 }

std::string libMesh::ReferenceCounter::get_info (  )  [static, inherited]

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

00048 {
00049 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00050 
00051   std::ostringstream oss;
00052 
00053   oss << '\n'
00054       << " ---------------------------------------------------------------------------- \n"
00055       << "| Reference count information                                                |\n"
00056       << " ---------------------------------------------------------------------------- \n";
00057 
00058   for (Counts::iterator it = _counts.begin();
00059        it != _counts.end(); ++it)
00060     {
00061       const std::string name(it->first);
00062       const unsigned int creations    = it->second.first;
00063       const unsigned int destructions = it->second.second;
00064 
00065       oss << "| " << name << " reference count information:\n"
00066           << "|  Creations:    " << creations    << '\n'
00067           << "|  Destructions: " << destructions << '\n';
00068     }
00069 
00070   oss << " ---------------------------------------------------------------------------- \n";
00071 
00072   return oss.str();
00073 
00074 #else
00075 
00076   return "";
00077 
00078 #endif
00079 }

void libMesh::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 163 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

00164 {
00165   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00166   std::pair<unsigned int, unsigned int>& p = _counts[name];
00167 
00168   p.first++;
00169 }

void libMesh::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 176 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

00177 {
00178   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00179   std::pair<unsigned int, unsigned int>& p = _counts[name];
00180 
00181   p.second++;
00182 }

template<unsigned int N>
unsigned int libMesh::Tree< N >::n_active_bins (  )  const [inline, virtual]
Returns:
the number of active bins.

Implements libMesh::TreeBase.

Definition at line 79 of file tree.h.

References libMesh::Tree< N >::root.

00079 { return root.n_active_bins(); }

static unsigned int libMesh::ReferenceCounter::n_objects (  )  [inline, static, inherited]

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

00080   { return _n_objects; }

template<unsigned int N>
const Elem * libMesh::Tree< N >::operator() ( const Point p  )  const [inline]
Returns:
a pointer to the element containing point p.

Definition at line 156 of file tree.h.

References libMesh::Tree< N >::find_element().

00157 {
00158   return this->find_element(p);
00159 }

template<unsigned int N>
void libMesh::Tree< N >::print_elements ( std::ostream &  my_out = libMesh::out  )  const [inline, virtual]

Prints the nodes.

Implements libMesh::TreeBase.

Definition at line 73 of file tree.h.

References libMesh::Tree< N >::root.

00074   { my_out << "Printing elements...\n"; root.print_elements(my_out); }

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out  )  [static, inherited]

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

00089 {
00090   if( _enable_print_counter ) out_stream << ReferenceCounter::get_info();
00091 }

template<unsigned int N>
void libMesh::Tree< N >::print_nodes ( std::ostream &  my_out = libMesh::out  )  const [inline, virtual]

Prints the nodes.

Implements libMesh::TreeBase.

Definition at line 67 of file tree.h.

References libMesh::Tree< N >::root.

00068   { my_out << "Printing nodes...\n"; root.print_nodes(my_out); }


Member Data Documentation

bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited]

Flag to control whether reference count information is printed when print_info is called.

Definition at line 137 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited]

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

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

template<unsigned int N>
const Trees::BuildType libMesh::Tree< N >::build_type [private]

How the tree is built.

Definition at line 103 of file tree.h.

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

const MeshBase& libMesh::TreeBase::mesh [protected, inherited]

Constant reference to a mesh. Declared at construction.

Definition at line 103 of file tree_base.h.

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


The documentation for this class was generated from the following files:

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:41 UTC

Hosted By:
SourceForge.net Logo