[MOAB-dev] r3558 - in MOAB/trunk: . tools/dagmc
sjackson at cae.wisc.edu
sjackson at cae.wisc.edu
Fri Feb 26 14:57:00 CST 2010
Author: sjackson
Date: 2010-02-26 14:57:00 -0600 (Fri, 26 Feb 2010)
New Revision: 3558
Modified:
MOAB/trunk/MBOrientedBoxTreeTool.cpp
MOAB/trunk/MBOrientedBoxTreeTool.hpp
MOAB/trunk/tools/dagmc/ray_fire_test.cc
Log:
Add to OBB tree traversal statistics a count of the number of
tree leaves that were visited during traversals. Output this
information from the ray_fire_test benchmark in dagmc.
Modified: MOAB/trunk/MBOrientedBoxTreeTool.cpp
===================================================================
--- MOAB/trunk/MBOrientedBoxTreeTool.cpp 2010-02-25 22:24:08 UTC (rev 3557)
+++ MOAB/trunk/MBOrientedBoxTreeTool.cpp 2010-02-26 20:57:00 UTC (rev 3558)
@@ -504,6 +504,7 @@
if (MB_SUCCESS != rval)
return rval;
if (children.empty()) {
+ if( accum ){ accum->increment_leaf( data.depth ); }
rval = operation.leaf( data.set );
if (MB_SUCCESS != rval)
return rval;
@@ -607,6 +608,7 @@
continue;
}
+ if(accum){ accum->increment_leaf( current_depth ); }
// if leaf, intersect sphere with triangles
#ifndef MB_OBB_USE_VECTOR_QUERIES
# ifdef MB_OBB_USE_TYPE_QUERIES
@@ -1133,6 +1135,8 @@
}
}
else { // LEAF NODE
+ if( accum ){ accum->increment_leaf( current_depth ); }
+
MBRange facets;
rval = instance->get_entities_by_dimension( node, 2, facets );
if (MB_SUCCESS != rval)
@@ -1267,6 +1271,8 @@
}
}
else { // LEAF NODE
+ if( accum ){ accum->increment_leaf( current_depth ); }
+
MBRange facets;
rval = instance->get_entities_by_dimension( node, 2, facets );
if (MB_SUCCESS != rval)
@@ -1596,6 +1602,7 @@
void MBOrientedBoxTreeTool::TrvStats::reset(){
nodes_visited_count.clear();
+ leaves_visited_count.clear();
traversals_ended_count.clear();
}
@@ -1603,11 +1610,17 @@
while( nodes_visited_count.size() <= depth ){
nodes_visited_count.push_back(0);
+ leaves_visited_count.push_back(0);
traversals_ended_count.push_back(0);
}
nodes_visited_count[depth] += 1;
}
+void MBOrientedBoxTreeTool::TrvStats::increment_leaf( unsigned depth ){
+ //assume safe depth, because increment is called first
+ leaves_visited_count[depth] += 1;
+}
+
void MBOrientedBoxTreeTool::TrvStats::end_traversal( unsigned depth ){
// assume safe depth, because increment is always called on a given
// tree level first
@@ -1618,25 +1631,29 @@
const std::string h1 = "OBBTree Depth";
const std::string h2 = " - NodesVisited";
- const std::string h3 = " - TraversalsEnded";
+ const std::string h3 = " - LeavesVisited";
+ const std::string h4 = " - TraversalsEnded";
- str << h1 << h2 << h3 << std::endl;
+ str << h1 << h2 << h3 << h4 << std::endl;
- unsigned num_visited = 0, num_traversals = 0;
+ unsigned num_visited = 0, num_leaves = 0, num_traversals = 0;
for( unsigned i = 0; i < traversals_ended_count.size(); ++i){
num_visited += nodes_visited_count[i];
+ num_leaves += leaves_visited_count[i];
num_traversals += traversals_ended_count[i];
str << std::setw(h1.length()) << i
<< std::setw(h2.length()) << nodes_visited_count[i]
- << std::setw(h3.length()) << traversals_ended_count[i]
+ << std::setw(h3.length()) << leaves_visited_count[i]
+ << std::setw(h4.length()) << traversals_ended_count[i]
<< std::endl;
}
str << std::setw(h1.length()) << "---- Totals:"
<< std::setw(h2.length()) << num_visited
- << std::setw(h3.length()) << num_traversals
+ << std::setw(h3.length()) << num_leaves
+ << std::setw(h4.length()) << num_traversals
<< std::endl;
}
Modified: MOAB/trunk/MBOrientedBoxTreeTool.hpp
===================================================================
--- MOAB/trunk/MBOrientedBoxTreeTool.hpp 2010-02-25 22:24:08 UTC (rev 3557)
+++ MOAB/trunk/MBOrientedBoxTreeTool.hpp 2010-02-26 20:57:00 UTC (rev 3558)
@@ -136,9 +136,13 @@
class TrvStats{
public:
- //! return counts of nodes visited, indexed by tree depth
+ //! return counts of nodes visited, indexed by tree depth.
+ //! the counts include both leaves and interior nodes
const std::vector< unsigned >& nodes_visited() const
{ return nodes_visited_count; }
+ //! return counts of tree leaves visited, indexed by tree depth
+ const std::vector< unsigned >& leaves_visited() const
+ { return leaves_visited_count; }
//! return counts of traversals ended, indexed by tree depth
const std::vector< unsigned >& traversals_ended() const
{ return traversals_ended_count; }
@@ -150,9 +154,11 @@
private:
std::vector< unsigned > nodes_visited_count;
+ std::vector< unsigned > leaves_visited_count;
std::vector< unsigned > traversals_ended_count;
void increment( unsigned depth );
+ void increment_leaf( unsigned depth );
void end_traversal( unsigned depth );
friend class MBOrientedBoxTreeTool;
Modified: MOAB/trunk/tools/dagmc/ray_fire_test.cc
===================================================================
--- MOAB/trunk/tools/dagmc/ray_fire_test.cc 2010-02-25 22:24:08 UTC (rev 3557)
+++ MOAB/trunk/tools/dagmc/ray_fire_test.cc 2010-02-26 20:57:00 UTC (rev 3558)
@@ -561,7 +561,13 @@
out << trv_stats->nodes_visited()[i] << ",";
}
out << "]," << std::endl;
-
+
+ out << "'leaves_visited':[";
+ for( unsigned i = 0; i < stat_depth; ++i){
+ out << trv_stats->leaves_visited()[i] << ",";
+ }
+ out << "]," << std::endl;
+
out << "'traversals_ended':[";
for( unsigned i = 0; i < stat_depth; ++i){
out << trv_stats->traversals_ended()[i] << ",";
More information about the moab-dev
mailing list