[MOAB-dev] r3537 - MOAB/trunk/tools/dagmc

sjackson at cae.wisc.edu sjackson at cae.wisc.edu
Wed Feb 10 15:01:05 CST 2010


Author: sjackson
Date: 2010-02-10 15:01:05 -0600 (Wed, 10 Feb 2010)
New Revision: 3537

Modified:
   MOAB/trunk/tools/dagmc/DagMC.cpp
   MOAB/trunk/tools/dagmc/DagMC.hpp
   MOAB/trunk/tools/dagmc/ray_fire_test.cc
Log:
Allow users to gather OBB tree traversal stats on DagMC's ray fire code.

This is used to implement the -S flag in ray_fire_test.

Modified: MOAB/trunk/tools/dagmc/DagMC.cpp
===================================================================
--- MOAB/trunk/tools/dagmc/DagMC.cpp	2010-02-10 20:28:28 UTC (rev 3536)
+++ MOAB/trunk/tools/dagmc/DagMC.cpp	2010-02-10 21:01:05 UTC (rev 3537)
@@ -140,7 +140,8 @@
                              const double uuu, const double vvv, const double www,
                              const double xxx, const double yyy, const double zzz,
                              const double huge_val,
-                             double &dist_traveled, MBEntityHandle &next_surf_hit) 
+                             double &dist_traveled, MBEntityHandle &next_surf_hit, 
+                             MBOrientedBoxTreeTool::TrvStats* stats ) 
 {
   if (debug) {
     std::cout << "Vol " << id_by_index(3, index_by_handle(vol)) << ", xyz = " 
@@ -176,7 +177,7 @@
                                      add_dist_tol(),
                                      min_tolerance_intersections,
                                      point, dir,
-                                     &len);
+                                     &len, stats);
   assert( MB_SUCCESS == rval );
 
 

Modified: MOAB/trunk/tools/dagmc/DagMC.hpp
===================================================================
--- MOAB/trunk/tools/dagmc/DagMC.hpp	2010-02-10 20:28:28 UTC (rev 3536)
+++ MOAB/trunk/tools/dagmc/DagMC.hpp	2010-02-10 21:01:05 UTC (rev 3537)
@@ -35,7 +35,8 @@
                        const double uuu, const double vvv, const double www,
                        const double xxx, const double yyy, const double zzz,
                        const double huge_val,
-                       double &dist_traveled, MBEntityHandle &next_surf_hit);
+                       double &dist_traveled, MBEntityHandle &next_surf_hit,
+                       MBOrientedBoxTreeTool::TrvStats* stats = NULL );
 
     // Test if point is inside or outside of a volume using unit sphere area method
     // Requires sense of surfaces wrt volume.

Modified: MOAB/trunk/tools/dagmc/ray_fire_test.cc
===================================================================
--- MOAB/trunk/tools/dagmc/ray_fire_test.cc	2010-02-10 20:28:28 UTC (rev 3536)
+++ MOAB/trunk/tools/dagmc/ray_fire_test.cc	2010-02-10 21:01:05 UTC (rev 3537)
@@ -80,7 +80,7 @@
   if( !error ){
     str << "-h  print this help" << std::endl;
     str << "-s  print OBB tree structural statistics" << std::endl;
-    str << "-S  track and print OBB tree traversal statistics (to be implemented soon)" << std::endl;
+    str << "-S  track and print OBB tree traversal statistics" << std::endl;
     str << "-i <int>   specify volume to upon which to test ray intersections (default 1)" << std::endl;
     str << "-t <real>  specify faceting tolerance (default 1e-4)" << std::endl;
     str << "-n <int>   specify number of random rays to fire (default 1000)" << std::endl;
@@ -202,6 +202,8 @@
   MBEntityHandle surf = 0, vol = 0;
   double x, y, z, u, v, w, dist;
 
+  MBOrientedBoxTreeTool::TrvStats* trv_stats = NULL;
+  if( do_trv_stats ){ trv_stats = new MBOrientedBoxTreeTool::TrvStats; }
 
   /* Initialize DAGMC and find the appropriate volume */
   std::cout << "Initializing DagMC, facet_tol = " << facet_tol << std::endl;
@@ -236,7 +238,7 @@
       rval = dagmc.ray_fire( vol, 0, 1, 
                              ray.v[0], ray.v[1], ray.v[2], 
                              ray.p[0], ray.p[1], ray.p[2], 
-                             DBL_MAX, dist, surf ); 
+                             DBL_MAX, dist, surf, trv_stats ); 
 
       if(MB_SUCCESS != rval) {
         std::cerr << "ERROR: ray_fire() failed!" << std::endl;
@@ -288,7 +290,7 @@
 #endif
     
     dagmc.ray_fire(vol, 0, 1, u, v, w, x, y, z, DBL_MAX,
-                   dist, surf);
+                   dist, surf, trv_stats);
 
   }
   get_time_mem(ttime2, utime2, stime2, tmem1);
@@ -312,11 +314,12 @@
 
   std::cout << " done." << std::endl;
   
-   
-  std::cout << "Total time per ray fire: " << timewith/num_random_rays 
-            << " sec" << std::endl;
-  std::cout << "Estimated time per call (excluding ray generation): " 
-            << (timewith - timewithout) / num_random_rays << " sec" << std::endl;
+  if( num_random_rays > 0 ){
+    std::cout << "Total time per ray fire: " << timewith/num_random_rays 
+	      << " sec" << std::endl;
+    std::cout << "Estimated time per call (excluding ray generation): " 
+	      << (timewith - timewithout) / num_random_rays << " sec" << std::endl;
+  }
   std::cout << "Program memory used: " 
             << tmem2 << " bytes (" << tmem2/(1024*1024) << " MB)" << std::endl;
 
@@ -343,6 +346,11 @@
     std::cout << "   num leaves: " << num_leaves << ", num nodes: " << node_count << std::endl;
   }
 
+  if( do_trv_stats ){
+    std::cout << "Traversal statistics:" << std::endl;
+    trv_stats->print( std::cout );
+  }
+
 #ifdef DEBUG
   std::cout << "uavg, vavg, wavg = " << uavg << " " << vavg << " " << wavg << std::endl;
 #endif



More information about the moab-dev mailing list