[MOAB-dev] commit/MOAB: nray: Removed unnecessary printouts. Added two examples for comparing timing

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Jul 4 17:47:48 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/5bbb2609118c/
Changeset:   5bbb2609118c
Branch:      nray/feature_ahf
User:        nray
Date:        2014-07-05 00:45:37
Summary:     Removed unnecessary printouts. Added two examples for comparing timing
and memory efficiency of MOAB and MOAB_AHF adjacencies.

Affected #:  6 files

diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 18a8a0d..af8c187 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -179,7 +179,6 @@ namespace moab {
 
     MESHTYPE mesh_type = get_mesh_type(nverts, nedges, nfaces, ncells);
     thismeshtype = mesh_type;
-    std::cout<<"MeshType = "<<thismeshtype<<std::endl;
   
     //Initialize mesh type specific maps
     if (mesh_type == CURVE){
@@ -812,7 +811,6 @@ namespace moab {
           }
       }
 
-    std::cout<<"Finished creating sibling half-verts map"<<std::endl;
 
     delete [] is_index;
     delete [] v2hv_map_eid;
@@ -846,7 +844,6 @@ namespace moab {
 	}
       }      
     }  
-    std::cout<<"Finished creating incident half-verts map"<<std::endl;
 
     return MB_SUCCESS;
   }
@@ -1155,7 +1152,6 @@ namespace moab {
      delete [] v2he_map_fid;
      delete [] v2he_map_leid;
 
-     std::cout<<"Finished creating sibling half-edges map"<<std::endl;
      return MB_SUCCESS;
 
   }
@@ -1190,10 +1186,10 @@ namespace moab {
 	  if (MB_SUCCESS != error) return error;
 	  error = mb->tag_set_data(v2he_leid, &v, 1, &lid);
 	  if (MB_SUCCESS != error) return error;
-	}
-      }      
+    }
+      }
     }     
-    std::cout<<"Finished creating incident half-edges map"<<std::endl;
+
     
     return MB_SUCCESS;
   }
@@ -1837,7 +1833,6 @@ namespace moab {
      delete [] v2hf_map_cid;
      delete [] v2hf_map_lfid;
 
-     std::cout<<"Finished creating sibling half-faces map"<<std::endl;
 
      return MB_SUCCESS;
 
@@ -1891,7 +1886,6 @@ namespace moab {
       }
     }
     
-    std::cout<<"Finished creating incident half-faces"<<std::endl;
     return MB_SUCCESS;
   }
   ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index 32e2a57..556554c 100644
--- a/test/perf/Makefile.am
+++ b/test/perf/Makefile.am
@@ -7,7 +7,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
             
 LDADD = $(top_builddir)/src/libMOAB.la
 
-check_PROGRAMS = perf seqperf adj_time perftool ahf_mem_time
+check_PROGRAMS = perf seqperf adj_time perftool ahf_mem_time adj_without_ahf
 noinst_PROGRAMS = 
 
 perf_SOURCES = perf.cpp
@@ -15,6 +15,7 @@ seqperf_SOURCES = seqperf.cpp
 adj_time_SOURCES = adj_time.cpp
 perftool_SOURCES = perftool.cpp
 ahf_mem_time_SOURCES = test_ahf_mem_time.cpp
+adj_without_ahf_SOURCES = adj_without_ahf_mem_time.cpp
 
 if ENABLE_imesh
   LDADD += $(top_builddir)/itaps/imesh/libiMesh.la
@@ -24,4 +25,9 @@ if ENABLE_imesh
   tstt_perf_binding_SOURCES = tstt_perf_binding.cpp
 endif
 
+if ENABLE_ahf
+  check_PROGRAMS += adj_with_ahf
+  adj_with_ahf_SOURCES = adj_with_ahf_mem_time.cpp
+endif 
+
 

diff --git a/test/perf/adj_with_ahf_mem_time.cpp b/test/perf/adj_with_ahf_mem_time.cpp
new file mode 100755
index 0000000..dbf4558
--- /dev/null
+++ b/test/perf/adj_with_ahf_mem_time.cpp
@@ -0,0 +1,209 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+  double y = -1;
+  struct timeval cur_time;  
+  gettimeofday(&cur_time, NULL);  
+  y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;  
+  return (y);
+}
+
+int main(int argc, char **argv)
+{
+  // Read the input mesh
+    filename = TestDir + "/hexes_mixed.vtk";
+
+    if (argc==1)
+        std::cout<<"Using default input file:"<<filename<<std::endl;
+    else if (argc==2)
+        filename = argv[1];
+    else {
+            std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+            return 1;
+    }
+
+  ErrorCode error;
+  Core moab;
+  Interface* mbImpl = &moab;
+  MeshTopoUtil mtu(mbImpl);
+
+  error = mbImpl->load_file( filename.c_str());
+  if (MB_SUCCESS != error) {
+    std::cerr << filename <<": failed to load file." << std::endl;
+    return error;
+  }
+
+  //Create ranges for handles of explicit elements of the mixed mesh
+  Range verts, edges, faces, cells;
+  error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+  error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+  error = mbImpl->get_entities_by_dimension( 0, 2, faces); 
+  error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+  
+  int nverts = verts.size(); 
+  int nedges = edges.size();
+  int nfaces = faces.size();
+  int ncells = cells.size();
+
+  std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+  //Storage Costs before calling ahf functionalities
+  std::cout<<std::endl;
+  std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
+  unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+  sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+  mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+  std::cout<<std::endl;
+  std::cout<<"Total storage = "<<sTotS<<std::endl;
+  std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+  std::cout<<"Entity storage = "<<sES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+  std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+  std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+  std::cout<<"Tag storage = "<<sTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+  std::cout<<std::endl;
+
+
+  double time_start, time_avg;
+
+  //Perform queries
+  std::vector<EntityHandle> adjents;
+
+  // This call should create all the necessary ahf maps
+  error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
+
+  //1D Queries //
+  //IQ1: For every vertex, obtain incident edges
+  std::cout<<"1D QUERIES"<<std::endl;
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {    
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)verts.size();
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time =  "<< time_avg<<" secs" <<std::endl;
+
+  //NQ1:  For every edge, obtain neighbor edges  
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {    
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
+
+  // 2D Queries
+  std::cout<<"2D QUERIES"<<std::endl;
+  //IQ21: For every vertex, obtain incident faces
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+
+
+  //IQ22: For every edge, obtain incident faces
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {   
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+
+
+  //NQ2: For every face, obtain neighbor faces 
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {   
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+
+
+  // 3D Queries
+  std::cout<<"3D QUERIES"<<std::endl;
+  //IQ31: For every vertex, obtain incident cells
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+
+
+  // IQ 32: For every edge, obtain incident cells
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+
+
+  //IQ32: For every face, obtain incident cells
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+
+
+  //NQ3: For every cell, obtain neighbor cells
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {   
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+  std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time =  "<< time_avg <<" secs" << std::endl;
+
+
+  //Storage Costs after calling ahf deinitialize
+  std::cout<<std::endl;
+  std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
+  unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+  eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+  mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+  std::cout<<std::endl;
+  std::cout<<"Total storage = "<<eTotS<<std::endl;
+  std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+  std::cout<<"Entity storage = "<<eES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+  std::cout<<"Adjacency storage = "<<eAS<<std::endl;
+  std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
+  std::cout<<"Tag storage = "<<eTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+  std::cout<<std::endl;
+
+  return 0;
+}
+

diff --git a/test/perf/adj_without_ahf_mem_time.cpp b/test/perf/adj_without_ahf_mem_time.cpp
new file mode 100755
index 0000000..cd4d58c
--- /dev/null
+++ b/test/perf/adj_without_ahf_mem_time.cpp
@@ -0,0 +1,223 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+  double y = -1;
+  struct timeval cur_time;  
+  gettimeofday(&cur_time, NULL);  
+  y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;  
+  return (y);
+}
+
+int main(int argc, char **argv)
+{
+  // Read the input mesh
+    filename = TestDir + "/hexes_mixed.vtk";
+
+    if (argc==1)
+        std::cout<<"Using default input file:"<<filename<<std::endl;
+    else if (argc==2)
+        filename = argv[1];
+    else {
+            std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+            return 1;
+    }
+
+  ErrorCode error;
+  Core moab;
+  Interface* mbImpl = &moab;
+  MeshTopoUtil mtu(mbImpl);
+
+  error = mbImpl->load_file( filename.c_str());
+  if (MB_SUCCESS != error) {
+    std::cerr << filename <<": failed to load file." << std::endl;
+    return error;
+  }
+
+  //Create ranges for handles of explicit elements of the mixed mesh
+  Range verts, edges, faces, cells;
+  error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+  error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+  error = mbImpl->get_entities_by_dimension( 0, 2, faces); 
+  error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+  
+  int nverts = verts.size(); 
+  int nedges = edges.size();
+  int nfaces = faces.size();
+  int ncells = cells.size();
+
+  std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+  //Storage Costs before calling ahf functionalities
+  std::cout<<std::endl;
+  std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
+  unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+  sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+  mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+  std::cout<<std::endl;
+  std::cout<<"Total storage = "<<sTotS<<std::endl;
+  std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+  std::cout<<"Entity storage = "<<sES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+  std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+  std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+  std::cout<<"Tag storage = "<<sTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+  std::cout<<std::endl;
+
+
+  double time_start, time_avg;
+
+  //Perform queries
+  std::vector<EntityHandle> mbents;
+  Range ngbents;
+
+  // This call should create all the necessary moab adjacency lists
+  error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
+
+  //1D Queries //
+  //IQ1: For every vertex, obtain incident edges
+  std::cout<<"1D QUERIES"<<std::endl;
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+      mbents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+  }
+  time_avg = (wtime()-time_start)/(double)verts.size();
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time =  "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+  //NQ1:  For every edge, obtain neighbor edges
+  error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, ngbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+      ngbents.clear();
+      error = mtu.get_bridge_adjacencies( *i, 0, 1, ngbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
+  std::cout<<std::endl;
+
+
+  // 2D Queries
+  std::cout<<"2D QUERIES"<<std::endl;
+  //IQ21: For every vertex, obtain incident faces
+  error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+      mbents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+  //IQ22: For every edge, obtain incident faces
+   error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+      mbents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+  //NQ2: For every face, obtain neighbor faces 
+  error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, ngbents);
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    ngbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 1, 2, ngbents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+
+  // 3D Queries
+  std::cout<<"3D QUERIES"<<std::endl;
+  //IQ31: For every vertex, obtain incident cells
+  error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    mbents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+
+
+  // IQ 32: For every edge, obtain incident cells
+  error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    mbents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+
+  //IQ32: For every face, obtain incident cells
+  error = mbImpl->get_adjacencies(&*faces.begin(), 1, 3, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    mbents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"QUERY: Face -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+
+  //NQ3: For every cell, obtain neighbor cells
+  error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, ngbents);
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+    ngbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 2, 3, ngbents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+  std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time =  "<< time_avg <<" secs" << std::endl;
+  std::cout<<std::endl;
+
+  //Storage Costs after calling ahf deinitialize
+  std::cout<<std::endl;
+  std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
+  unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+  eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+  mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+  std::cout<<std::endl;
+  std::cout<<"Total storage = "<<eTotS<<std::endl;
+  std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+  std::cout<<"Entity storage = "<<eES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+  std::cout<<"Adjacency storage = "<<eAS<<std::endl;
+  std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
+  std::cout<<"Tag storage = "<<eTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+  std::cout<<std::endl;
+
+  return 0;
+}
+

diff --git a/test/perf/ahf_intfc_mem_time.cpp b/test/perf/ahf_intfc_mem_time.cpp
new file mode 100755
index 0000000..6d8ef14
--- /dev/null
+++ b/test/perf/ahf_intfc_mem_time.cpp
@@ -0,0 +1,309 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+  double y = -1;
+  struct timeval cur_time;  
+  gettimeofday(&cur_time, NULL);  
+  y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;  
+  return (y);
+}
+
+int main(int argc, char **argv)
+{
+  // Read the input mesh
+    filename = TestDir + "/hexes_mixed.vtk";
+
+    if (argc==1)
+        std::cout<<"Using default input file:"<<filename<<std::endl;
+    else if (argc==2)
+        filename = argv[1];
+    else {
+            std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+            return 1;
+    }
+
+  ErrorCode error;
+  Core moab;
+  Interface* mbImpl = &moab;
+  MeshTopoUtil mtu(mbImpl);
+
+  error = mbImpl->load_file( filename.c_str());
+  if (MB_SUCCESS != error) {
+    std::cerr << filename <<": failed to load file." << std::endl;
+    return error;
+  }
+
+  //Create ranges for handles of explicit elements of the mixed mesh
+  Range verts, edges, faces, cells;
+  error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+  error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+  error = mbImpl->get_entities_by_dimension( 0, 2, faces); 
+  error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+  
+  int nverts = verts.size(); 
+  int nedges = edges.size();
+  int nfaces = faces.size();
+  int ncells = cells.size();
+
+  std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+  //Storage Costs before calling ahf functionalities
+  unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+  sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+  mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+  std::cout<<std::endl;
+  std::cout<<"Total storage = "<<sTotS<<std::endl;
+  std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+  std::cout<<"Entity storage = "<<sES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+  std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+  std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+  std::cout<<"Tag storage = "<<sTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+  std::cout<<std::endl;
+
+
+  double time_start, time_avg;
+
+  //Storage Costs after calling ahf initialize
+  unsigned long TotS, TAS, ES, AES, AS, AAS, TS, ATS;
+  TotS = TAS = ES = AES = AS = AAS = TS = ATS = 0;
+  mbImpl->estimated_memory_use(NULL, 0, &TotS, &TAS, &ES, &AES, &AS, &AAS, NULL, 0, &TS, &ATS);
+  std::cout<<std::endl;
+  std::cout<<"Total storage = "<<TotS<<std::endl;
+  std::cout<<"Total amortized storage = "<<TAS<<std::endl;
+  std::cout<<"Entity storage = "<<ES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<AES<<std::endl;
+  std::cout<<"Adjacency storage = "<<AS<<std::endl;
+  std::cout<<"Amortized adjacency storage = "<<AAS<<std::endl;
+  std::cout<<"Tag storage = "<<TS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<ATS<<std::endl;
+  std::cout<<std::endl;
+
+  //Perform queries
+  std::vector<EntityHandle> adjents;
+  Range mbents;
+
+  // This call should create all the necessary ahf maps
+  error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
+
+  // This call should create all the necessary moab adjacency lists
+  error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
+
+  //1D Queries //
+  //IQ1: For every vertex, obtain incident edges
+  std::cout<<"1D QUERIES"<<std::endl;
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {    
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)verts.size();
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time =  "<< time_avg<<" secs" <<std::endl;
+
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+    mbents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+  }
+  time_avg = (wtime()-time_start)/(double)verts.size();
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time =  "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+  //NQ1:  For every edge, obtain neighbor edges  
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {    
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
+
+  error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    mbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
+  std::cout<<std::endl;
+
+
+  // 2D Queries
+  std::cout<<"2D QUERIES"<<std::endl;
+  //IQ21: For every vertex, obtain incident faces
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+
+  error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+      mbents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+  //IQ22: For every edge, obtain incident faces
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {   
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+
+  error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+      mbents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+  //NQ2: For every face, obtain neighbor faces 
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {   
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+
+  error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, mbents);
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    mbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+
+  // 3D Queries
+  std::cout<<"3D QUERIES"<<std::endl;
+  //IQ31: For every vertex, obtain incident cells
+  time_start = wtime();
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+
+  error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    mbents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+
+
+  // IQ 32: For every edge, obtain incident cells
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+
+  error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    mbents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+
+  //IQ32: For every face, obtain incident cells
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+
+  error = mbImpl->get_adjacencies(&*faces.begin(), 1, 3, false, mbents);
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    mbents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"QUERY: Face -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+
+  //NQ3: For every cell, obtain neighbor cells
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {   
+    adjents.clear();
+    error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+  std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time =  "<< time_avg <<" secs" << std::endl;
+
+  error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, mbents);
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+    mbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+  std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time =  "<< time_avg <<" secs" << std::endl;
+  std::cout<<std::endl;
+
+  //Storage Costs after calling ahf deinitialize
+  unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+  eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+  mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+  std::cout<<std::endl;
+  std::cout<<"Total storage = "<<eTotS<<std::endl;
+  std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+  std::cout<<"Entity storage = "<<eES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+  std::cout<<"Adjacency storage = "<<eAS<<std::endl;
+  std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
+  std::cout<<"Tag storage = "<<eTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+  std::cout<<std::endl;
+
+  return 0;
+}
+

diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
index 3d8257f..f4f754f 100755
--- a/test/test_ahf_mb_interface.cpp
+++ b/test/test_ahf_mb_interface.cpp
@@ -73,7 +73,24 @@ void ahf_mbintf_test()
   }
 
   // 2D Queries
-  //IQ2: For every edge, obtain incident faces
+  // IQ21: For every vertex, obtain incident faces
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+      adjents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+      CHECK_ERR(error);
+      mbents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+      CHECK_ERR(error);
+
+      CHECK_EQUAL(adjents.size(), mbents.size());
+
+      std::sort(adjents.begin(), adjents.end());
+      std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+      mbents = subtract(mbents, ahfents);
+      CHECK(!mbents.size());
+  }
+
+  //IQ22: For every edge, obtain incident faces
   for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
     adjents.clear();
     error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
@@ -108,7 +125,24 @@ void ahf_mbintf_test()
   }
 
   // 3D Queries
-  // IQ 31: For every edge, obtain incident cells
+  //IQ 31: For every vertex, obtain incident cells
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+      adjents.clear();
+      error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+      CHECK_ERR(error);
+      mbents.clear();
+      error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+      CHECK_ERR(error);
+
+      CHECK_EQUAL(adjents.size(), mbents.size());
+
+      std::sort(adjents.begin(), adjents.end());
+      std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+      mbents = subtract(mbents, ahfents);
+      CHECK(!mbents.size());
+  }
+
+  // IQ 32: For every edge, obtain incident cells
   for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
     adjents.clear();
     error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list