Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::TreeStats Class Reference

Traversal statistics accumulating and reporting. More...

#include <TreeStats.hpp>

Public Member Functions

 TreeStats ()
 constructor More...
 
ErrorCode compute_stats (Interface *impl, EntityHandle root_node)
 Given a root node, compute the stats for a tree. More...
 
void reset_trav_stats ()
 reset traversal counters More...
 
void reset ()
 reset all counters More...
 
void print () const
 print the contents of this structure More...
 
void output_all_stats (const bool with_endl=true) const
 output all the contents of this structure on a single line More...
 
void output_trav_stats (const bool with_endl=true) const
 output just the traversal stats of this structure on a single line More...
 

Public Attributes

double initTime
 
unsigned int maxDepth
 
unsigned int numNodes
 
unsigned int numLeaves
 
double avgObjPerLeaf
 
unsigned int minObjPerLeaf
 
unsigned int maxObjPerLeaf
 
unsigned int nodesVisited
 
unsigned int leavesVisited
 
unsigned int numTraversals
 
unsigned int constructLeafObjectTests
 
unsigned int traversalLeafObjectTests
 
unsigned int boxElemTests
 

Private Member Functions

ErrorCode traverse (Interface *impl, EntityHandle node, unsigned int &depth)
 

Detailed Description

Traversal statistics accumulating and reporting.

Class to accumulate statistics on traversal performance. This structure contains the count of nodes visited at each level in a tree, and the count of traversals that ended at each level. One TrvStats structure can be used with multiple trees or multiple queries, or used on only a single tree or a single query.

Note that these traversal statistics are not related to the stats() query below, which calculates static information about a tree. These statistics relate to a tree's dynamic behavior on particular operations.

Definition at line 26 of file TreeStats.hpp.

Constructor & Destructor Documentation

◆ TreeStats()

moab::TreeStats::TreeStats ( )
inline

constructor

Definition at line 30 of file TreeStats.hpp.

31  {
32  reset();
33  }

References reset().

Member Function Documentation

◆ compute_stats()

ErrorCode moab::TreeStats::compute_stats ( Interface impl,
EntityHandle  root_node 
)
inline

Given a root node, compute the stats for a tree.

Parameters
implMOAB instance pointer
root_nodeRoot entity set for the tree

Definition at line 81 of file TreeStats.hpp.

82 {
83  maxDepth = 0;
84  numNodes = 0;
85  numLeaves = 0;
86  avgObjPerLeaf = 0.0;
87  minObjPerLeaf = 0;
88  maxObjPerLeaf = 0;
89 
90  ErrorCode rval = traverse( impl, root_node, maxDepth );
91  avgObjPerLeaf = ( avgObjPerLeaf > 0 ? avgObjPerLeaf / (double)numLeaves : 0.0 );
92  return rval;
93 }

References avgObjPerLeaf, ErrorCode, maxDepth, maxObjPerLeaf, minObjPerLeaf, numLeaves, numNodes, and traverse().

Referenced by moab::AdaptiveKDTree::build_tree(), and moab::BVHTree::build_tree().

◆ output_all_stats()

void moab::TreeStats::output_all_stats ( const bool  with_endl = true) const
inline

output all the contents of this structure on a single line

Definition at line 170 of file TreeStats.hpp.

171 {
172  std::cout << initTime << " " << numNodes << " " << numLeaves << " " << maxDepth << " " << avgObjPerLeaf << " "
173  << minObjPerLeaf << " " << maxObjPerLeaf << " " << constructLeafObjectTests << " " << boxElemTests << " "
174  << nodesVisited << " " << leavesVisited << " " << numTraversals << " " << traversalLeafObjectTests << " ";
175  if( with_endl ) std::cout << std::endl;
176 }

References avgObjPerLeaf, boxElemTests, constructLeafObjectTests, initTime, leavesVisited, maxDepth, maxObjPerLeaf, minObjPerLeaf, nodesVisited, numLeaves, numNodes, numTraversals, and traversalLeafObjectTests.

◆ output_trav_stats()

void moab::TreeStats::output_trav_stats ( const bool  with_endl = true) const
inline

output just the traversal stats of this structure on a single line

Definition at line 178 of file TreeStats.hpp.

179 {
180  std::cout << nodesVisited << " " << leavesVisited << " " << numTraversals << " " << traversalLeafObjectTests << " ";
181  if( with_endl ) std::cout << std::endl;
182 }

References leavesVisited, nodesVisited, numTraversals, and traversalLeafObjectTests.

◆ print()

void moab::TreeStats::print ( ) const
inline

print the contents of this structure

Definition at line 149 of file TreeStats.hpp.

150 {
151  std::cout << "Tree initialization time = " << initTime << " seconds" << std::endl;
152 
153  std::cout << "Num nodes = " << numNodes << std::endl;
154  std::cout << "Num leaves = " << numLeaves << std::endl;
155  std::cout << "Max depth = " << maxDepth << std::endl << std::endl;
156 
157  std::cout << "Avg objs per leaf = " << avgObjPerLeaf << std::endl;
158  std::cout << "Min objs per leaf = " << minObjPerLeaf << std::endl;
159  std::cout << "Max objs per leaf = " << maxObjPerLeaf << std::endl;
160 
161  std::cout << "Construction Leaf Object Tests = " << constructLeafObjectTests << std::endl;
162  std::cout << "Box-Element Tests = " << boxElemTests << std::endl;
163 
164  std::cout << "NodesVisited = " << nodesVisited << std::endl;
165  std::cout << "LeavesVisited = " << leavesVisited << std::endl;
166  std::cout << "Num Traversals = " << numTraversals << std::endl;
167  std::cout << "Traversal Leaf Object Tests = " << traversalLeafObjectTests << std::endl;
168 }

References avgObjPerLeaf, boxElemTests, constructLeafObjectTests, initTime, leavesVisited, maxDepth, maxObjPerLeaf, minObjPerLeaf, nodesVisited, numLeaves, numNodes, numTraversals, and traversalLeafObjectTests.

Referenced by DeformMeshRemap::execute().

◆ reset()

void moab::TreeStats::reset ( )
inline

reset all counters

Definition at line 125 of file TreeStats.hpp.

126 {
127  initTime = 0.0;
128 
129  maxDepth = 0;
130  numNodes = 0;
131  numLeaves = 0;
133  boxElemTests = 0;
134  avgObjPerLeaf = 0.0;
135  minObjPerLeaf = 0.0;
136  maxObjPerLeaf = 0.0;
137 
139 }

References avgObjPerLeaf, boxElemTests, constructLeafObjectTests, initTime, maxDepth, maxObjPerLeaf, minObjPerLeaf, numLeaves, numNodes, and reset_trav_stats().

Referenced by moab::AdaptiveKDTree::build_tree(), moab::BVHTree::build_tree(), and TreeStats().

◆ reset_trav_stats()

void moab::TreeStats::reset_trav_stats ( )
inline

reset traversal counters

Definition at line 141 of file TreeStats.hpp.

142 {
143  nodesVisited = 0;
144  leavesVisited = 0;
145  numTraversals = 0;
147 }

References leavesVisited, nodesVisited, numTraversals, and traversalLeafObjectTests.

Referenced by reset().

◆ traverse()

ErrorCode moab::TreeStats::traverse ( Interface impl,
EntityHandle  node,
unsigned int &  depth 
)
inlineprivate

Definition at line 95 of file TreeStats.hpp.

96 {
97  depth++;
98  numNodes++;
99  std::vector< EntityHandle > children;
100  children.reserve( 2 );
101  ErrorCode rval = impl->get_child_meshsets( node, children );
102  if( MB_SUCCESS != rval ) return rval;
103  if( children.empty() )
104  {
105  numLeaves++;
106  rval = impl->get_entities_by_handle( node, children );
107  if( MB_SUCCESS != rval ) return rval;
108  avgObjPerLeaf += children.size();
109  minObjPerLeaf = std::min( (unsigned int)children.size(), minObjPerLeaf );
110  maxObjPerLeaf = std::max( (unsigned int)children.size(), maxObjPerLeaf );
111  return MB_SUCCESS;
112  }
113  else
114  {
115  unsigned int right_depth = depth, left_depth = depth;
116  rval = traverse( impl, children[0], left_depth );
117  if( MB_SUCCESS != rval ) return rval;
118  rval = traverse( impl, children[1], right_depth );
119  if( MB_SUCCESS != rval ) return rval;
120  depth = std::max( left_depth, right_depth );
121  return MB_SUCCESS;
122  }
123 }

References avgObjPerLeaf, children, ErrorCode, moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_handle(), maxObjPerLeaf, MB_SUCCESS, minObjPerLeaf, numLeaves, and numNodes.

Referenced by compute_stats().

Member Data Documentation

◆ avgObjPerLeaf

double moab::TreeStats::avgObjPerLeaf

Definition at line 63 of file TreeStats.hpp.

Referenced by compute_stats(), output_all_stats(), print(), reset(), and traverse().

◆ boxElemTests

unsigned int moab::TreeStats::boxElemTests

◆ constructLeafObjectTests

unsigned int moab::TreeStats::constructLeafObjectTests

◆ initTime

double moab::TreeStats::initTime

◆ leavesVisited

◆ maxDepth

unsigned int moab::TreeStats::maxDepth

Definition at line 60 of file TreeStats.hpp.

Referenced by compute_stats(), output_all_stats(), print(), and reset().

◆ maxObjPerLeaf

unsigned int moab::TreeStats::maxObjPerLeaf

Definition at line 65 of file TreeStats.hpp.

Referenced by compute_stats(), output_all_stats(), print(), reset(), and traverse().

◆ minObjPerLeaf

unsigned int moab::TreeStats::minObjPerLeaf

Definition at line 64 of file TreeStats.hpp.

Referenced by compute_stats(), output_all_stats(), print(), reset(), and traverse().

◆ nodesVisited

◆ numLeaves

unsigned int moab::TreeStats::numLeaves

Definition at line 62 of file TreeStats.hpp.

Referenced by compute_stats(), output_all_stats(), print(), reset(), and traverse().

◆ numNodes

unsigned int moab::TreeStats::numNodes

Definition at line 61 of file TreeStats.hpp.

Referenced by compute_stats(), output_all_stats(), print(), reset(), and traverse().

◆ numTraversals

◆ traversalLeafObjectTests


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