libMesh::Tree< N > Class Template Reference

#include <tree.h>

Inheritance diagram for libMesh::Tree< N >:

Public Member Functions

 Tree (const MeshBase &m, const unsigned int target_bin_size, 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
protectedinherited

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  target_bin_size,
Trees::BuildType  bt = Trees::NODES 
)

Constructor. Requires a mesh and the target bin size. Optionally takes the build method.

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.

39  :
40  TreeBase(m),
41  root(m,target_bin_size),
42  build_type(bt)
43 {
44  // Set the root node bounding box equal to the bounding
45  // box for the entire domain.
46  root.set_bounding_box (MeshTools::bounding_box(mesh));
47 
48 
49  if (build_type == Trees::NODES)
50  {
51  // Add all the nodes to the root node. It will
52  // automagically build the tree for us.
53  MeshBase::const_node_iterator it = mesh.nodes_begin();
54  const MeshBase::const_node_iterator end = mesh.nodes_end();
55 
56  for (; it != end; ++it)
57  root.insert (*it);
58 
59  // Now the tree contains the nodes.
60  // However, we want element pointers, so here we
61  // convert between the two.
62  std::vector<std::vector<const Elem*> > nodes_to_elem;
63 
65  root.transform_nodes_to_elements (nodes_to_elem);
66  }
67 
68  else if (build_type == Trees::ELEMENTS)
69  {
70  // Add all active elements to the root node. It will
71  // automatically build the tree for us.
72  MeshBase::const_element_iterator it = mesh.active_elements_begin();
73  const MeshBase::const_element_iterator end = mesh.active_elements_end();
74 
75 
76  for (; it != end; ++it)
77  root.insert (*it);
78  }
79 }
template<unsigned int N>
libMesh::Tree< N >::Tree ( const Tree< N > &  other_tree)
inline

Copy-constructor.

Definition at line 144 of file tree.h.

144  :
145  TreeBase (other_tree),
146  root (other_tree.root),
147  build_type (other_tree.build_type)
148 {
149  libmesh_error();
150 }
template<unsigned int N>
libMesh::Tree< N >::~Tree ( )
inline

Destructor.

Definition at line 62 of file tree.h.

62 {}

Member Function Documentation

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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.

101 {
102  _enable_print_counter = true;
103  return;
104 }
template<unsigned int N>
const Elem * libMesh::Tree< N >::find_element ( const Point p) const
virtual
Returns
a pointer to the element containing point p.

Implements libMesh::TreeBase.

Definition at line 84 of file tree.C.

85 {
86  return root.find_element(p);
87 }
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

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().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

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, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

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

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

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, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

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

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
template<unsigned int N>
unsigned int libMesh::Tree< N >::n_active_bins ( ) const
inlinevirtual
Returns
the number of active bins.

Implements libMesh::TreeBase.

Definition at line 79 of file tree.h.

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

79 { return root.n_active_bins(); }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

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.

80  { 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.

157 {
158  return this->find_element(p);
159 }
template<unsigned int N>
void libMesh::Tree< N >::print_elements ( std::ostream &  my_out = libMesh::out) const
inlinevirtual

Prints the nodes.

Implements libMesh::TreeBase.

Definition at line 73 of file tree.h.

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

74  { my_out << "Printing elements...\n"; root.print_elements(my_out); }
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

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().

89 {
91 }
template<unsigned int N>
void libMesh::Tree< N >::print_nodes ( std::ostream &  my_out = libMesh::out) const
inlinevirtual

Prints the nodes.

Implements libMesh::TreeBase.

Definition at line 67 of file tree.h.

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

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

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

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().

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

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
staticprotectedinherited

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
protectedinherited

Constant reference to a mesh. Declared at construction.

Definition at line 103 of file tree_base.h.

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

template<unsigned int N>
TreeNode<N> libMesh::Tree< N >::root
private

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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:02 UTC

Hosted By:
SourceForge.net Logo