[MOAB-dev] commit/MOAB: 9 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Jul 12 21:19:01 CDT 2014


9 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/7310978da774/
Changeset:   7310978da774
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Added the HalfFacetRep class and one test code.

Affected #:  7 files

diff --git a/MeshFiles/unittest/Makefile.am b/MeshFiles/unittest/Makefile.am
index bc4f522..2bd2a8a 100644
--- a/MeshFiles/unittest/Makefile.am
+++ b/MeshFiles/unittest/Makefile.am
@@ -34,5 +34,6 @@ EXTRA_DIST  = 125hex.g \
               BedCrop2.h5m \
               mpas_p8.h5m \
               Homme_2pt.h5m \
-              surfrandomtris-4part.h5m
+              surfrandomtris-4part.h5m \
+	      hexes_mixed.vtk
 

diff --git a/MeshFiles/unittest/hexes_mixed.vtk b/MeshFiles/unittest/hexes_mixed.vtk
new file mode 100755
index 0000000..8ee5c11
--- /dev/null
+++ b/MeshFiles/unittest/hexes_mixed.vtk
@@ -0,0 +1,45 @@
+# vtk DataFile Version 3.0
+This file was written using writevtk_unstr.m
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 18 double
+0 -1 0
+0 1 0
+1 -1 0
+1 1 0
+-1 1 0
+-1 -1 0
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+-1 1 1
+-1 -1 1
+0 -1 -1
+0 1 -1
+1 -1 -1 
+1 1 -1
+-1 1 -1
+-1 -1 -1
+
+CELLS 9 59
+2 0 1
+4 0 1 7 6
+4 0 2 3 1
+4 0 12 13 1
+4 0 1 4 5
+8 0 2 3 1 6 8 9 7
+8 5 0 1 4 11 6 7 10
+8 12 14 15 13 0 2 3 1
+8 17 12 13 16 5 0 1 4
+
+CELL_TYPES 9
+3
+9
+9
+9
+9
+12
+12
+12
+12

This diff is so big that we needed to truncate the remainder.

https://bitbucket.org/fathomteam/moab/commits/796dd1576217/
Changeset:   796dd1576217
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Added interface to AHF functionalities through the get_adjacencies
functions.

Affected #:  10 files

diff --git a/configure.ac b/configure.ac
index 890f70d..b0905cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -657,6 +657,13 @@ MB_OPTIONAL_TOOL([mbdepth],      [yes])
 MB_OPTIONAL_TOOL([refiner],      [no])
 MB_OPTIONAL_TOOL([h5mtools],     [yes])
 MB_OPTIONAL_TOOL([mbcslam],      [no])
+MB_OPTIONAL_TOOL([ahf],          [no])
+
+
+if test "xyes" = "x$ENABLE_ahf"; then
+  AM_CPPFLAGS="$AM_CPPFLAGS -DUSE_AHF"
+fi
+
 
 if test "xyes" = "x$ENABLE_refiner"; then
   if test "xyes" != "x$WITH_MPI"; then
@@ -1333,3 +1340,27 @@ if test "x$WARN_PARALLEL_HDF5_NO_COMPLEX" = "xyes"; then
 *************************************************************************])
 fi
 
+################################################################################
+#                             AHF OPTIONS
+################################################################################
+#AC_ARG_ENABLE([ahf],
+#[AC_HELP_STRING([--enable-ahf],[use the half facet representation])],
+#[ case "${enableval}" in 
+#	yes) ahf1=true ;;
+#        no) ahf1=false ;;
+#	*) AC_MSG_ERROR([bad value]) ;; 
+#esac],[ahf1=false])	
+ #ENABLE_AHF=$enableval],[ENABLE_AHF=no] )
+
+#if test "x$ENABLE_AHF" = "xyes"; then
+#   AM_CPPFLAGS="$AM_CPPFLAGS -DUSE_AHF"
+#fi
+#AM_CONDITIONAL([ENABLE_AHF],[test x$ahf1 = xtrue])
+#AC_SUBST(ENABLE_AHF)
+
+
+#test "xyes" != "x$WITH_AHF" || AM_CPPFLAGS="$AM_CPPFLAGS -DUSE_AHF"
+#AM_CONDITIONAL(USE_AHF, [test "xno" != "x$WITH_AHF"])
+
+
+

diff --git a/src/Core.cpp b/src/Core.cpp
index 0bd882f..3641fd5 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -56,6 +56,10 @@
 #include <errno.h>
 #include <string.h>
 
+#ifdef USE_AHF
+#include "moab/HalfFacetRep.hpp"
+#endif
+
 #ifdef USE_MPI
 /* Leave ParallelComm.hpp before mpi.h or MPICH2 will fail
  * because its C++ headers do not like SEEK_* macros.
@@ -272,6 +276,12 @@ ErrorCode Core::initialize()
   geom_dimension_tag();
   globalId_tag();
 
+#ifdef USE_AHF
+  ahfRep = new HalfFacetRep(this);
+  if (!ahfRep)
+    return MB_MEMORY_ALLOCATION_FAILED;
+#endif
+
   return MB_SUCCESS;
 }
 
@@ -322,6 +332,11 @@ void Core::deinitialize()
   if (mpiFinalize)
     MPI_Finalize();
 #endif
+
+#ifdef USE_AHF
+  delete ahfRep;
+  ahfRep = 0;
+#endif
 }
 
 ErrorCode Core::query_interface_type( const std::type_info& type, void*& ptr )
@@ -1338,6 +1353,80 @@ ErrorCode get_adjacencies_union( Core* gMB,
   return result;
 }
 
+
+///////////////////////////
+///
+#ifdef USE_AHF
+template <typename ITER> static inline
+ErrorCode get_adjacencies_intersection_ahf(Core *mb,
+                             ITER begin, ITER end,
+                             const int to_dimension,
+                             std::vector<EntityHandle>& adj_entities )
+{
+  const size_t SORT_THRESHOLD = 200;
+  std::vector<EntityHandle> temp_vec;
+  std::vector<EntityHandle>::iterator adj_it, w_it;
+  ErrorCode result = MB_SUCCESS;
+
+  if (begin == end) {
+    adj_entities.clear(); // intersection
+    return MB_SUCCESS;
+  }
+
+    // First iteration is a special case if input list is empty.
+    // Rather than returning nothing (intersecting with empty
+    // input list), we begin with the adjacencies for the first entity.
+  if (adj_entities.empty()) {
+    EntityType type = TYPE_FROM_HANDLE(*begin);
+
+    if(to_dimension == 0 && type != MBPOLYHEDRON)
+      result = mb->get_connectivity(&(*begin), 1, adj_entities);
+    else
+      result = mb->a_half_facet_rep()->get_adjacencies(*begin, to_dimension, adj_entities);
+    if (MB_SUCCESS != result)
+      return result;
+    ++begin;
+  }
+
+  for (ITER from_it = begin; from_it != end; from_it++)
+  {
+      // running results kept in adj_entities; clear temp_vec, which is working space
+    temp_vec.clear();
+
+      // get the next set of adjacencies
+    EntityType type = TYPE_FROM_HANDLE(*from_it);
+    if(to_dimension == 0 && type != MBPOLYHEDRON)
+      result = mb->get_connectivity(&(*from_it), 1, temp_vec);
+    else
+      result = mb->a_half_facet_rep()->get_adjacencies(*from_it, to_dimension, temp_vec);
+    if (MB_SUCCESS != result)
+      return result;
+
+      // otherwise intersect with the current set of results
+    w_it = adj_it = adj_entities.begin();
+    if (temp_vec.size()*adj_entities.size() < SORT_THRESHOLD) {
+      for (; adj_it != adj_entities.end(); ++adj_it)
+        if (std::find(temp_vec.begin(), temp_vec.end(), *adj_it) != temp_vec.end())
+          { *w_it = *adj_it; ++w_it; }
+    }
+    else {
+      std::sort( temp_vec.begin(), temp_vec.end() );
+      for (; adj_it != adj_entities.end(); ++adj_it)
+        if (std::binary_search(temp_vec.begin(), temp_vec.end(), *adj_it))
+          { *w_it = *adj_it; ++w_it; }
+    }
+    adj_entities.erase( w_it, adj_entities.end() );
+
+      // we're intersecting, so if there are no more results, we're done
+    if (adj_entities.empty())
+      break;
+  }
+
+  return MB_SUCCESS;
+}
+#endif
+///////////////////////////////////////////
+
 template <typename ITER> static inline
 ErrorCode get_adjacencies_intersection( Core* mb,
                              ITER begin, ITER end,
@@ -1445,37 +1534,116 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
                                      const int to_dimension,
                                      const bool create_if_missing,
                                      std::vector<EntityHandle> &adj_entities,
-                                     const int operation_type )
+                                     const int operation_type
+#ifdef USE_AHF
+                                 , const bool use_ahf)
+#else
+                                 )
+#endif
 {
-  if (operation_type == Interface::INTERSECT)
-    return get_adjacencies_intersection( this, from_entities, from_entities+num_entities,
-                                         to_dimension, create_if_missing, adj_entities );
-  else if (operation_type != Interface::UNION)
-    return MB_FAILURE;
 
-    // do union
-  ErrorCode result;
-  std::vector<EntityHandle> tmp_storage;
-  const EntityHandle* conn;
-  int len;
-  for (int i = 0; i < num_entities; ++i) {
-    if(to_dimension == 0 && TYPE_FROM_HANDLE(from_entities[0]) != MBPOLYHEDRON) {
-      result = get_connectivity(from_entities[i], conn, len, false, &tmp_storage);
-      adj_entities.insert( adj_entities.end(), conn, conn+len );
-      if (MB_SUCCESS != result)
-        return result;
+#ifdef USE_AHF
+    bool can_handle = true;
+    int source_dim = this->dimension_from_handle(from_entities[0]);
+
+    if ((source_dim > to_dimension) && (to_dimension != 0))
+    {
+        std::cout<<"Currently Not Supported by MOAB_AHF: Down Adjacencies"<<std::endl;
+        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+        can_handle = false;
     }
-    else {
-      result = aEntityFactory->get_adjacencies(from_entities[i], to_dimension,
-                                               create_if_missing, adj_entities);
-      if (MB_SUCCESS != result)
-        return result;
+    else if (((source_dim == 0) && (to_dimension == 2))||((source_dim == 0) && (to_dimension == 3)))
+    {
+        std::cout<<"Currently Not Supported by MOAB_AHF: Vertex to face/cell"<<std::endl;
+        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+        can_handle = false;
+    }
+    else if (TYPE_FROM_HANDLE(from_entities[0]) == MBPOLYHEDRON)
+    {
+        std::cout<<"Currently Not Supported by MOAB_AHF: Polyhedron Meshes"<<std::endl;
+        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+        can_handle = false;
+    }
+    else if (create_if_missing)
+    {
+        std::cout<<"Currently Not Supporteded by MOAB_AHF: create_if_missing capability "<<std::endl;
+        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+        can_handle = false;
     }
-  }
-  std::sort( adj_entities.begin(), adj_entities.end() );
-  adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
 
-  return MB_SUCCESS;
+    if ((use_ahf) && (can_handle))
+    {
+
+        if (operation_type == Interface::INTERSECT)
+            return get_adjacencies_intersection_ahf(this, from_entities, from_entities+num_entities,
+                                                    to_dimension, adj_entities );
+        else if (operation_type != Interface::UNION)
+            return MB_FAILURE;
+
+        // do union
+        ErrorCode result;
+        std::vector<EntityHandle> tmp_storage;
+        const EntityHandle* conn;
+        int len;
+        for (int i = 0; i < num_entities; ++i) {
+            if(to_dimension == 0 && TYPE_FROM_HANDLE(from_entities[0]) != MBPOLYHEDRON) {
+                result = get_connectivity(from_entities[i], conn, len, false, &tmp_storage);
+                adj_entities.insert( adj_entities.end(), conn, conn+len );
+                if (MB_SUCCESS != result)
+                    return result;
+            }
+            else {
+                result = ahfRep->get_adjacencies(from_entities[i], to_dimension, adj_entities);
+                if (MB_SUCCESS != result)
+                    return result;
+            }
+        }
+        std::sort( adj_entities.begin(), adj_entities.end() );
+        adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
+
+    }
+    else
+    {
+
+#endif
+
+        if (operation_type == Interface::INTERSECT)
+            return get_adjacencies_intersection( this, from_entities, from_entities+num_entities,
+                                                 to_dimension, create_if_missing, adj_entities );
+        else if (operation_type != Interface::UNION)
+            return MB_FAILURE;
+
+        // do union
+        ErrorCode result;
+        std::vector<EntityHandle> tmp_storage;
+        const EntityHandle* conn;
+        int len;
+        for (int i = 0; i < num_entities; ++i) {
+            if(to_dimension == 0 && TYPE_FROM_HANDLE(from_entities[0]) != MBPOLYHEDRON) {
+                result = get_connectivity(from_entities[i], conn, len, false, &tmp_storage);
+                adj_entities.insert( adj_entities.end(), conn, conn+len );
+                if (MB_SUCCESS != result)
+                    return result;
+            }
+            else {
+                result = aEntityFactory->get_adjacencies(from_entities[i], to_dimension,
+                                                         create_if_missing, adj_entities);
+                if (MB_SUCCESS != result)
+                    return result;
+            }
+        }
+        std::sort( adj_entities.begin(), adj_entities.end() );
+        adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
+
+        //return MB_SUCCESS;
+
+
+#ifdef USE_AHF
+    }
+#endif
+
+return MB_SUCCESS;
+
 }
 
 

diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 95efb7e..f3818a6 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -17,21 +17,32 @@
 #pragma warning (disable : 4786)
 #endif
 
+#include "moab/HalfFacetRep.hpp"
 #include <iostream>
 #include <assert.h>
-#include <time.h>
 #include <vector>
-#include <queue>
-#include <stack>
 #include "moab/Core.hpp"
 #include "moab/Range.hpp"
 #include "moab/CN.hpp"
-#include "moab/HalfFacetRep.hpp"
 
 namespace moab {
 
   const int MAXSIZE = 500;
 
+  HalfFacetRep::HalfFacetRep(Core *impl)
+  {
+    assert(NULL != impl);
+    mb = impl;
+    mInitAHFmaps = false;
+  }
+
+  HalfFacetRep::~HalfFacetRep()
+  {
+    ErrorCode result;
+    result = deinitialize();
+    //if (MB_SUCCESS != result) return result;
+  }
+
   MESHTYPE HalfFacetRep::get_mesh_type(int nverts, int nedges, int nfaces, int ncells)
   {
     MESHTYPE mesh_type;
@@ -58,7 +69,9 @@ namespace moab {
    * initialize                                          *
    ******************************************************/
 
-  ErrorCode HalfFacetRep::initialize(){
+  ErrorCode HalfFacetRep::initialize()
+  {
+    mInitAHFmaps = true;
 
     ErrorCode error;
 
@@ -436,36 +449,100 @@ namespace moab {
    *      User interface for adjacency functions            *
    ********************************************************/
 
-   ErrorCode HalfFacetRep::get_upward_incidences(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * lids)
+  ErrorCode HalfFacetRep::get_adjacencies(const EntityHandle source_entity,
+                                          const unsigned int target_dimension,
+                                          std::vector<EntityHandle> &target_entities)
+  {
+
+      ErrorCode error;
+
+      unsigned int source_dimension = mb->dimension_from_handle(source_entity);
+
+      if (mInitAHFmaps == false)
+      {
+       error = initialize();
+       if (MB_SUCCESS != error) return error;
+      }
+
+      if ((source_dimension == 0) && (target_dimension == 1))
+      {
+          error = get_up_adjacencies_1d(source_entity, target_entities);
+          if (MB_SUCCESS != error) return error;
+      }
+
+      else if ((source_dimension == 1) && (target_dimension == 2))
+      {
+          error = get_up_adjacencies_2d(source_entity, target_entities);
+          if (MB_SUCCESS != error) return error;
+      }
+      else if ((source_dimension == 1) && (target_dimension == 3))
+      {
+          error = get_up_adjacencies_edg_3d(source_entity, target_entities);
+          if (MB_SUCCESS != error) return error;
+      }
+      else if ((source_dimension == 2) && (target_dimension ==3))
+      {
+          error = get_up_adjacencies_face_3d(source_entity, target_entities);
+          if (MB_SUCCESS != error) return error;
+      }
+      else if (source_dimension == target_dimension)
+      {
+          if (target_dimension == 1)
+          {
+              error = get_neighbor_adjacencies_1d(source_entity, target_entities);
+              if (MB_SUCCESS != error) return error;
+          }
+
+          else if (target_dimension == 2)
+          {
+              error = get_neighbor_adjacencies_2d(source_entity, target_entities);
+              if (MB_SUCCESS != error) return error;
+          }
+          else if (target_dimension == 3)
+          {
+              error = get_neighbor_adjacencies_3d(source_entity, target_entities);
+              if (MB_SUCCESS != error) return error;
+          }
+      }
+      return MB_SUCCESS;
+  }
+
+
+   ErrorCode HalfFacetRep::get_up_adjacencies(EntityHandle ent,
+                                              int out_dim,
+                                              std::vector<EntityHandle> &adjents,
+                                              bool local_id,
+                                              std::vector<int> * lids)
    {
     ErrorCode error;
     int in_dim = mb->dimension_from_handle(ent);
 
     if ((in_dim == 0) && (out_dim == 1))
       {
-        error = get_upward_incidences_1d(ent, adjents, local_id, lids);
+        error = get_up_adjacencies_1d(ent, adjents, local_id, lids);
         if (MB_SUCCESS != error) return error;
       }
 
     else if ((in_dim == 1) && (out_dim == 2))
       {
-        error = get_upward_incidences_2d(ent, adjents, local_id, lids);
+        error = get_up_adjacencies_2d(ent, adjents, local_id, lids);
         if (MB_SUCCESS != error) return error;
       }
     else if ((in_dim == 1) && (out_dim == 3))
       {
-        error = get_upward_incidences_edg_3d(ent, adjents, local_id, lids);
+        error = get_up_adjacencies_edg_3d(ent, adjents, local_id, lids);
         if (MB_SUCCESS != error) return error;
       }
     else if ((in_dim == 2) && (out_dim ==3))
       {
-        error = get_upward_incidences_face_3d(ent, adjents, local_id, lids);
+        error = get_up_adjacencies_face_3d(ent, adjents, local_id, lids);
         if (MB_SUCCESS != error) return error;
       }
     return MB_SUCCESS;
    }
 
-   ErrorCode HalfFacetRep::get_neighbor_adjacencies(EntityHandle ent, std::vector<EntityHandle> &adjents)
+   ErrorCode HalfFacetRep::get_neighbor_adjacencies(EntityHandle ent,
+                                                    std::vector<EntityHandle> &adjents)
    {
      ErrorCode error;
      int in_dim = mb->dimension_from_handle(ent);
@@ -619,8 +696,11 @@ namespace moab {
     return MB_SUCCESS;
   }
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode  HalfFacetRep::get_upward_incidences_1d( EntityHandle vid, std::vector< EntityHandle > &adjents, bool local_id, std::vector<int> * lvids){
-    ErrorCode error;     
+  ErrorCode  HalfFacetRep::get_up_adjacencies_1d( EntityHandle vid,
+                                                  std::vector< EntityHandle > &adjents,
+                                                  bool local_id,
+                                                  std::vector<int> * lvids){
+    ErrorCode error;
     EntityHandle start_eid, eid, sibeid[2];
     int start_lid, lid, siblid[2];    
    
@@ -655,7 +735,8 @@ namespace moab {
     return MB_SUCCESS;
   }
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode  HalfFacetRep::get_neighbor_adjacencies_1d( EntityHandle eid, std::vector<EntityHandle> &adjents){
+  ErrorCode  HalfFacetRep::get_neighbor_adjacencies_1d( EntityHandle eid,
+                                                        std::vector<EntityHandle> &adjents){
 
     ErrorCode error;
 
@@ -912,9 +993,65 @@ namespace moab {
     
     return MB_SUCCESS;
   }
+  ///////////////////////////////////////////////////////////////////
+ /* ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle vid, std::vector<EntityHandle> &adjents)
+  {
+    ErrorCode error;
+
+    EntityHandle fid; int lid;
+    error = mb->tag_get_data(v2he_fid, &vid, 1, &fid);
+    if (MB_SUCCESS != error) return error;
+    error = mb->tag_get_data(v2he_leid, &vid, 1, &lid);
+    if (MB_SUCCESS != error) return error;
+
+    if (fid != 0)
+      {
+        adjents.push_back(fid);
+
+        EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
+        int queue_lid[MAXSIZE];
+        for (int i = 0; i< MAXSIZE; i++)
+          {
+            queue_fid[i] = 0;
+            queue_lid[i] = 0;
+            trackfaces[i] = 0;
+          }
+        int qsize = 0, tcount = -1;
+        int num_qvals = 0;
+        error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &tcount);
+        if (MB_SUCCESS != error) return error;
+
+        while (num_qvals < *qsize)
+          {
+            EntityHandle curfid = queue_fid[num_qvals];
+            int curlid = queue_lid[num_qvals];
+            num_qvals += 1;
+
+            EntityHandle he2_fid; int he2_lid;
+            error = another_halfedge(vid, curfid, curlid, &he2_fid, &he2_lid);
+            if (MB_SUCCESS != error) return error;
 
+            bool found_ent = find_match_in_array(he2_fid, trackfaces, tcount[0]);
+
+            if (found_ent)
+              continue;
+            tcount[0] += 1;
+            trackfaces[tcount[0]] = he2_fid;
+
+            error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+            if (MB_SUCCESS != error) return error;
+
+            adjents.push_back(he2_fid);
+
+          }
+      }
+  }
+*/
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode  HalfFacetRep::get_upward_incidences_2d( EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int>  * leids)
+  ErrorCode  HalfFacetRep::get_up_adjacencies_2d( EntityHandle eid,
+                                                  std::vector<EntityHandle> &adjents,
+                                                  bool local_id,
+                                                  std::vector<int>  * leids)
 {
 
   // Given an explicit edge eid, find the incident faces.
@@ -928,7 +1065,7 @@ namespace moab {
     // Step 2: If there is a corresponding half-edge, collect all sibling half-edges and store the incident faces.
     if (found)
       { 
-        error = get_upward_incidences_2d(he_fid, he_lid, true, adjents, local_id, leids);
+        error = get_up_adjacencies_2d(he_fid, he_lid, true, adjents, local_id, leids);
         if (MB_SUCCESS != error) return error;
       }
 
@@ -936,7 +1073,12 @@ namespace moab {
   }
 
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode HalfFacetRep::get_upward_incidences_2d( EntityHandle fid,  int leid, bool add_inent, std::vector<EntityHandle> &fids, bool local_id, std::vector<int> * leids)
+  ErrorCode HalfFacetRep::get_up_adjacencies_2d( EntityHandle fid,
+                                                 int leid,
+                                                 bool add_inent,
+                                                 std::vector<EntityHandle> &fids,
+                                                 bool local_id,
+                                                 std::vector<int> * leids)
   {
     // Given an implicit half-edge <fid, leid>, find the incident half-edges.
     ErrorCode error;
@@ -982,7 +1124,13 @@ namespace moab {
   }
 
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-   ErrorCode HalfFacetRep::get_upward_incidences_2d(EntityHandle fid,  int lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount)
+   ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle fid,
+                                                 int lid,
+                                                 EntityHandle *queue_fid,
+                                                 int *queue_lid,
+                                                 int *qsize,
+                                                 EntityHandle *trackfaces,
+                                                 int *tcount)
   {
 
     ErrorCode error; 
@@ -1035,7 +1183,9 @@ namespace moab {
    }
 
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  bool HalfFacetRep::find_matching_halfedge( EntityHandle eid, EntityHandle *hefid, int *helid){
+  bool HalfFacetRep::find_matching_halfedge( EntityHandle eid,
+                                             EntityHandle *hefid,
+                                             int *helid){
     ErrorCode error;
     std::vector<EntityHandle> conn(2);
     error = mb->get_connectivity(&eid, 1, conn);
@@ -1071,7 +1221,14 @@ namespace moab {
     return found;
   }
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-   ErrorCode HalfFacetRep::gather_halfedges( EntityHandle vid,  EntityHandle he_fid,  int he_lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount)
+   ErrorCode HalfFacetRep::gather_halfedges( EntityHandle vid,
+                                             EntityHandle he_fid,
+                                             int he_lid,
+                                             EntityHandle *queue_fid,
+                                             int *queue_lid,
+                                             int *qsize,
+                                             EntityHandle *trackfaces,
+                                             int *tcount)
   {  
     ErrorCode error;
     EntityHandle he2_fid = 0; int he2_lid = 0;
@@ -1086,16 +1243,20 @@ namespace moab {
     tcount[0] += 1;
     trackfaces[tcount[0]] = he_fid;
     
-    error = get_upward_incidences_2d(he_fid, he_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+    error = get_up_adjacencies_2d(he_fid, he_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
     if (MB_SUCCESS != error) return error;
-    error = get_upward_incidences_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+    error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
     if (MB_SUCCESS != error) return error;
 
     return MB_SUCCESS;
   }
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode HalfFacetRep::another_halfedge( EntityHandle vid,  EntityHandle he_fid,  int he_lid, EntityHandle *he2_fid, int *he2_lid)
+  ErrorCode HalfFacetRep::another_halfedge( EntityHandle vid,
+                                            EntityHandle he_fid,
+                                            int he_lid,
+                                            EntityHandle *he2_fid,
+                                            int *he2_lid)
   {    
     ErrorCode error;
     int nepf;
@@ -1121,7 +1282,14 @@ namespace moab {
   }
   
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  bool HalfFacetRep::collect_and_compare(std::vector<EntityHandle> &edg_vert, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount, EntityHandle *he_fid, int *he_lid)
+  bool HalfFacetRep::collect_and_compare(std::vector<EntityHandle> &edg_vert,
+                                         EntityHandle *queue_fid,
+                                         int *queue_lid,
+                                         int *qsize,
+                                         EntityHandle *trackfaces,
+                                         int *tcount,
+                                         EntityHandle *he_fid,
+                                         int *he_lid)
   {
     ErrorCode error;
     int nepf = local_maps_2d(*_faces.begin());
@@ -1162,7 +1330,7 @@ namespace moab {
 	error = another_halfedge(edg_vert[0], curfid, curlid, &he2_fid, &he2_lid);
 
 	if (MB_SUCCESS != error) return error;
-	error = get_upward_incidences_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+	error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
 	if (MB_SUCCESS != error) return error;      
 
 	counter += 1;
@@ -1174,14 +1342,15 @@ namespace moab {
   }
   
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode  HalfFacetRep::get_neighbor_adjacencies_2d( EntityHandle fid, std::vector<EntityHandle> &adjents)
+  ErrorCode  HalfFacetRep::get_neighbor_adjacencies_2d( EntityHandle fid,
+                                                        std::vector<EntityHandle> &adjents)
   {
     ErrorCode error; 
     if (fid != 0){
       
       int nepf = local_maps_2d(fid);
       for (int lid = 0; lid < nepf; ++lid){
-        error = get_upward_incidences_2d(fid, lid, false, adjents);
+        error = get_up_adjacencies_2d(fid, lid, false, adjents);
 	if (MB_SUCCESS != error) return error;
       }
     }
@@ -1212,7 +1381,7 @@ namespace moab {
 	int id = nepf*(*f-firstF)+l;
 	if (!trackF[id])
 	  {
-	    error = get_upward_incidences_2d(*f,l, false, adj_fids, true, &adj_lids);
+	    error = get_up_adjacencies_2d(*f,l, false, adj_fids, true, &adj_lids);
 	    if (MB_SUCCESS != error) return error;
 
 	    total_edges -= adj_fids.size();
@@ -1530,7 +1699,10 @@ namespace moab {
   }
 
  //////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode HalfFacetRep::get_upward_incidences_edg_3d( EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * leids)
+  ErrorCode HalfFacetRep::get_up_adjacencies_edg_3d( EntityHandle eid,
+                                                     std::vector<EntityHandle> &adjents,
+                                                     bool local_id,
+                                                     std::vector<int> * leids)
   {
     ErrorCode error; 
     
@@ -1542,7 +1714,7 @@ namespace moab {
     //Find all incident cells     
     if (found)
       {
-        error =get_upward_incidences_edg_3d(cid, leid, adjents, local_id, leids);
+        error =get_up_adjacencies_edg_3d(cid, leid, adjents, local_id, leids);
         if (MB_SUCCESS != error) return error;
       }
 
@@ -1550,7 +1722,11 @@ namespace moab {
   }
 
   //////////////////////////////////////////////////////////////
-  ErrorCode HalfFacetRep::get_upward_incidences_edg_3d( EntityHandle cid,  int leid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * leids)
+  ErrorCode HalfFacetRep::get_up_adjacencies_edg_3d( EntityHandle cid,
+                                                     int leid,
+                                                     std::vector<EntityHandle> &adjents,
+                                                     bool local_id,
+                                                     std::vector<int> * leids)
   {
     ErrorCode error;
 
@@ -1648,7 +1824,10 @@ namespace moab {
   }
  
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  ErrorCode  HalfFacetRep::get_upward_incidences_face_3d( EntityHandle fid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * lfids)
+  ErrorCode  HalfFacetRep::get_up_adjacencies_face_3d( EntityHandle fid,
+                                                       std::vector<EntityHandle> &adjents,
+                                                       bool local_id,
+                                                       std::vector<int> * lfids)
   {
     ErrorCode error;
 
@@ -1657,14 +1836,18 @@ namespace moab {
     bool found = find_matching_halfface(fid, &cid, &lid);
 
     if (found){
-      error = get_upward_incidences_face_3d(cid, lid, adjents, local_id, lfids);
+      error = get_up_adjacencies_face_3d(cid, lid, adjents, local_id, lfids);
       if (MB_SUCCESS != error) return error;
       }
 
     return MB_SUCCESS;
   }
   ///////////////////////////////////////////
-  ErrorCode HalfFacetRep::get_upward_incidences_face_3d( EntityHandle cid,  int lfid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * lfids)
+  ErrorCode HalfFacetRep::get_up_adjacencies_face_3d( EntityHandle cid,
+                                                      int lfid,
+                                                      std::vector<EntityHandle> &adjents,
+                                                      bool local_id,
+                                                      std::vector<int> * lfids)
   {
     ErrorCode error;
 
@@ -1701,7 +1884,9 @@ namespace moab {
     return MB_SUCCESS;
   }
   /////////////////////////////////////////////////////////////////
- bool HalfFacetRep::find_matching_implicit_edge_in_cell( EntityHandle eid, EntityHandle *cid, int *leid)
+ bool HalfFacetRep::find_matching_implicit_edge_in_cell( EntityHandle eid,
+                                                         EntityHandle *cid,
+                                                         int *leid)
   {
     ErrorCode error;
 

diff --git a/src/Makefile.am b/src/Makefile.am
index e2bf713..6fac039 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -226,6 +226,12 @@ if HAVE_CGM
   AM_CPPFLAGS += @CGM_CPPFLAGS@ -DCGM @MOAB_CGM_DEFINES@
 endif
 
+# if ENABLE_ahf
+  # libMOAB_la_SOURCES += HalfFacetRep.cpp
+  # nobase_libMOAB_la_include_HEADERS += moab/HalfFacetRep.hpp
+#  AM_CPPFLAGS += -DUSE_AHF  
+# endif 
+
 MBCN_protos.h: MBCN.h $(top_srcdir)/itaps/mkprotos.sh
 	$(AM_V_GEN)$(top_srcdir)/itaps/mkprotos.sh MBCN MOAB $< $@ MOAB_FCDefs.h
 

diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index aa7d9da..941129a 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -35,6 +35,10 @@ class EntitySequence;
 class FileOptions;
 class SetIterator;
 
+#ifdef USE_AHF
+class HalfFacetRep;
+#endif
+
 #ifdef XPCOM_MB
 
 #define MBCORE_CID \
@@ -311,12 +315,18 @@ public:
             get_adjacencies( from_entities, MB_1D_ENTITY, adjacencies ); 
             \endcode */
 
-    virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
-                                         const int num_entities,
-                                         const int to_dimension,
-                                         const bool create_if_missing,
-                                         std::vector<EntityHandle>& adj_entities,
-                                         const int operation_type = Interface::INTERSECT);
+  virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+                                       const int num_entities,
+                                       const int to_dimension,
+                                       const bool create_if_missing,
+                                       std::vector<EntityHandle>& adj_entities,
+                                       const int operation_type = Interface::INTERSECT
+    #ifdef USE_AHF
+      , const bool use_ahf = false);
+    #else
+      );
+    #endif
+
 
     virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
                                         const int num_entities,
@@ -1126,7 +1136,12 @@ public:
     //! return the a_entity_factory pointer
   AEntityFactory *a_entity_factory() { return aEntityFactory; }
   const AEntityFactory *a_entity_factory() const { return aEntityFactory; }
-  
+
+#ifdef USE_AHF
+  HalfFacetRep *a_half_facet_rep() { return ahfRep; }
+  const HalfFacetRep *a_half_facet_rep() const {return ahfRep; }
+#endif
+
     //! return set of registered IO tools
   ReaderWriterSet* reader_writer_set() { return readerWriterSet; }
 
@@ -1347,6 +1362,10 @@ private:
 
     //! list of iterators 
   std::vector<SetIterator*> setIterators;
+
+#ifdef USE_AHF
+  HalfFacetRep *ahfRep;
+#endif
   
 };
 

diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index eca5e91..3d1069a 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -52,14 +52,15 @@ namespace moab {
    VOLUME_MIXED //Volume mesh with embedded curves and surfaces
   };
 
-   
+  class Core;
+
   class HalfFacetRep{
        
   public:
     
-    HalfFacetRep(Interface *impl) : mb(impl) {}
+    HalfFacetRep(Core *impl);
     
-    ~HalfFacetRep() {}
+    ~HalfFacetRep();
 
     // User interface functions
 
@@ -74,6 +75,12 @@ namespace moab {
     //! Prints the tag values.
     ErrorCode print_tags();
     
+
+    ErrorCode get_adjacencies(const EntityHandle source_entity,
+                              const unsigned int target_dimension,
+                              std::vector<EntityHandle> &target_entities);
+
+
     //! Get the upward incidences associated with an entity.
     /** Given an entity of dimension <em>d</em>, gather all the incident <em>D(>d)</em> dimensional entities.
      * Parameters:
@@ -84,7 +91,11 @@ namespace moab {
      * \param lids Vector in which the local id's are returned.
      */
 
-    ErrorCode get_upward_incidences(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * lids = NULL );
+    ErrorCode get_up_adjacencies(EntityHandle ent,
+                                 int out_dim,
+                                 std::vector<EntityHandle> &adjents,
+                                 bool local_id = false,
+                                 std::vector<int> * lids = NULL );
 
     //! Get the same-dimensional entities connected with an entity.
     /** Given an entity of dimension <em>d</em>, gather all the entities connected via <em>d-1</em> dimensional entities.
@@ -94,7 +105,8 @@ namespace moab {
      * \param adjents Vector in which the neighbor entities are returned.
      */
 
-    ErrorCode get_neighbor_adjacencies(EntityHandle ent, std::vector<EntityHandle> &adjents);
+    ErrorCode get_neighbor_adjacencies(EntityHandle ent,
+                                       std::vector<EntityHandle> &adjents);
 
     // 1D Maps and queries
 
@@ -127,7 +139,10 @@ namespace moab {
      * \param lvids Vector returning the local vertex id's
     */
 
-    ErrorCode get_upward_incidences_1d(EntityHandle vid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * lvids = NULL);
+    ErrorCode get_up_adjacencies_1d(EntityHandle vid,
+                                    std::vector<EntityHandle> &adjents,
+                                    bool local_id = false,
+                                    std::vector<int> * lvids = NULL);
 
     //! Given an edge, finds vertex-connected neighbor edges
     /** Given an edge, it gathers all the incident edges of each vertex of the edge.
@@ -136,7 +151,8 @@ namespace moab {
      * \param adjents Vector returning neighbor edges
     */
     
-    ErrorCode get_neighbor_adjacencies_1d(EntityHandle eid, std::vector<EntityHandle> &adjents);
+    ErrorCode get_neighbor_adjacencies_1d(EntityHandle eid,
+                                          std::vector<EntityHandle> &adjents);
     
     
     // 2D Maps and queries    
@@ -161,6 +177,9 @@ namespace moab {
 
     ErrorCode determine_incident_halfedges(Range &faces);
 
+   /* ErrorCode get_up_adjacencies_2d(EntityHandle vid,
+                                       std::vector<EntityHandle> &adjents);*/
+
     //! Given an edge, finds the faces incident on it.
     /** Given an edge, it first finds a matching half-edge corresponding to eid, and then
      * collects all the incident half-edges/faces via the sibhes map.
@@ -171,7 +190,10 @@ namespace moab {
      * \param leids Vector returning local edge ids
     */
 
-    ErrorCode get_upward_incidences_2d(EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+    ErrorCode get_up_adjacencies_2d(EntityHandle eid,
+                                    std::vector<EntityHandle> &adjents,
+                                    bool local_id = false,
+                                    std::vector<int> * leids = NULL);
 
     //! Given a half-edge <fid, leid>, finds the faces incident on it.
     /**
@@ -184,7 +206,12 @@ namespace moab {
      * \param leids Vector returning local edge ids
     */
 
-    ErrorCode get_upward_incidences_2d(EntityHandle fid, int leid, bool add_inent, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+    ErrorCode get_up_adjacencies_2d(EntityHandle fid,
+                                    int leid,
+                                    bool add_inent,
+                                    std::vector<EntityHandle> &adjents,
+                                    bool local_id = false,
+                                    std::vector<int> * leids = NULL);
 
     //! Given an edge, finds edge-connected neighbor face
     /** Given an face, it gathers all the neighbor faces of each local edge of the face.
@@ -193,7 +220,8 @@ namespace moab {
      * \param adjents Vector returning neighbor faces
     */
        
-    ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid, std::vector<EntityHandle> &adjents);
+    ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid,
+                                          std::vector<EntityHandle> &adjents);
 
     //! Given a range of faces, finds the total number of edges.
     
@@ -229,7 +257,8 @@ namespace moab {
      * \param isborder: A dense tag over all vertices of size 1. Value is true for a border vertex, otherwise is false.
     */
 
-    ErrorCode determine_border_vertices( Range &cells, Tag isborder);
+    ErrorCode determine_border_vertices( Range &cells,
+                                         Tag isborder);
 
     //! Given an edge, finds the cells incident on it.
     /** Given an edge, it first finds a matching local edge in a cell corresponding to eid, and then
@@ -241,7 +270,10 @@ namespace moab {
      * \param leids Vector returning local edge ids
     */
 
-    ErrorCode get_upward_incidences_edg_3d(EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+    ErrorCode get_up_adjacencies_edg_3d(EntityHandle eid,
+                                        std::vector<EntityHandle> &adjents,
+                                        bool local_id = false,
+                                        std::vector<int> * leids = NULL);
 
     //! Given a local edge <cid, leid>, finds the cells incident on it.
     /** Given a local edge, it gathers all the incident cells via the sibhfs map.
@@ -253,7 +285,10 @@ namespace moab {
      * \param leids Vector returning local edge ids
     */
 
-    ErrorCode get_upward_incidences_edg_3d(EntityHandle cid, int leid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+    ErrorCode get_up_adjacencies_edg_3d(EntityHandle cid,
+                                        int leid, std::vector<EntityHandle> &adjents,
+                                        bool local_id = false,
+                                        std::vector<int> * leids = NULL);
 
     //! Given an face, finds the cells incident on it.
     /** Given an face, it first finds a matching half-face in a cell corresponding to face, and then
@@ -265,7 +300,10 @@ namespace moab {
      * \param leids Vector returning local face ids
     */
 
-    ErrorCode get_upward_incidences_face_3d(EntityHandle fid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int>  * lfids = NULL);
+    ErrorCode get_up_adjacencies_face_3d(EntityHandle fid,
+                                         std::vector<EntityHandle> &adjents,
+                                         bool local_id = false,
+                                         std::vector<int>  * lfids = NULL);
 
     //! Given a local face <cid, lfid>, finds the cells incident on it.
     /** Given a local face, it gathers all the incident cells via the sibhfs map.
@@ -277,7 +315,11 @@ namespace moab {
      * \param lfids Vector returning local face ids
     */
 
-    ErrorCode get_upward_incidences_face_3d(EntityHandle cid, int lfid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * lfids = NULL);
+    ErrorCode get_up_adjacencies_face_3d(EntityHandle cid,
+                                         int lfid,
+                                         std::vector<EntityHandle> &adjents,
+                                         bool local_id = false,
+                                         std::vector<int> * lfids = NULL);
     
     //! Given a cell, finds face-connected neighbor cells
     /** Given a cell, it gathers all the neighbor cells of each local face of the cell.
@@ -286,12 +328,17 @@ namespace moab {
      * \param adjents Vector returning neighbor cells
     */
 
-    ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
+    ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid,
+                                          std::vector<EntityHandle> &adjents);
     
 
   protected:
 
-    Interface * mb;
+    Core * mb;
+
+    HalfFacetRep();
+
+    bool mInitAHFmaps;
 
     enum {
       MAX_VERTICES = 8,
@@ -351,14 +398,23 @@ namespace moab {
      * queue of half-edges, if they do not already exist in the queue. This function is used to increment the
      * search space for finding a matching half-edge.
      * Parameters:
-     * \param <EntityHandle he_fid, int he_lid>  The query half-edge
-     * \param queue_fid, queue_lid, qsize Array of faces and local edge ids. qsize is the current size of the queue_fid.
+     * \param he_fid EntityHandle of query half-edge
+     * \param he_lid Local id of query half-edge
+     * \param queue_fid
+     * \param queue_lid
+     * \param qsize Array of faces and local edge ids. qsize is the current size of the queue_fid.
      * \param trackfaces Array containing faces. If fid of an incident half-edge doesn't belong to trackfaces,
      *  the half-edge is added to the queue.
      * \param tcount Current size of trackfaces
      */
 
-    ErrorCode get_upward_incidences_2d(EntityHandle he_fid, int he_lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount);
+    ErrorCode get_up_adjacencies_2d(EntityHandle he_fid,
+                                    int he_lid,
+                                    EntityHandle *queue_fid,
+                                    int *queue_lid,
+                                    int *qsize,
+                                    EntityHandle *trackfaces,
+                                    int *tcount);
 
     //! Given an edge, finds a matching half-edge in the surface.
     /** Given an edge eid, it first collects few half-edges belonging to one-ring neighborhood of
@@ -369,7 +425,9 @@ namespace moab {
      * \param hefid, helid: Returns the matching half-edge corresponding to the query edge.
     */
 
-    bool find_matching_halfedge( EntityHandle eid, EntityHandle *hefid, int *helid);
+    bool find_matching_halfedge( EntityHandle eid,
+                                 EntityHandle *hefid,
+                                 int *helid);
 
     //! Gather half-edges to a queue of half-edges.
     /** Given a vertex vid, and a half-edge <he_fid,he_lid>, add another half-edge in the same face sharing the vertex
@@ -381,7 +439,14 @@ namespace moab {
      * \param trackfaces, tcount
     */
 
-    ErrorCode gather_halfedges( EntityHandle vid,  EntityHandle he_fid,  int he_lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount);
+    ErrorCode gather_halfedges( EntityHandle vid,
+                                EntityHandle he_fid,
+                                int he_lid,
+                                EntityHandle *queue_fid,
+                                int *queue_lid,
+                                int *qsize,
+                                EntityHandle *trackfaces,
+                                int *tcount);
 
     //! Obtains another half-edge belonging to the same face as the input half-edge
     /** It uses the local maps to find another half-edge that is either incident or outgoing depending
@@ -392,7 +457,11 @@ namespace moab {
      * \param <EntityHandle he2_fid, int he2_lid>: Returns another half-edge in the same he_fid sharing vid.
     */
 
-    ErrorCode another_halfedge( EntityHandle vid,  EntityHandle he_fid,  int he_lid, EntityHandle *he2_fid, int *he2_lid);
+    ErrorCode another_halfedge( EntityHandle vid,
+                                EntityHandle he_fid,
+                                int he_lid,
+                                EntityHandle *he2_fid,
+                                int *he2_lid);
 
     //! Collect and compare to find a matching half-edge with the given edge connectivity.
     /** Given edge connectivity, compare to an input list of half-edges to find a matching half-edge
@@ -404,7 +473,14 @@ namespace moab {
      * \param <EntityHandle he_fid, int he_lid>: Returns matching half-edge
     */
 
-    bool collect_and_compare(std::vector<EntityHandle> &edg_vert, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount, EntityHandle *he_fid, int *he_lid);
+    bool collect_and_compare(std::vector<EntityHandle> &edg_vert,
+                             EntityHandle *queue_fid,
+                             int *queue_lid,
+                             int *qsize,
+                             EntityHandle *trackfaces,
+                             int *tcount,
+                             EntityHandle *he_fid,
+                             int *he_lid);
 
 
     //! The local maps for 3D entities.
@@ -469,7 +545,9 @@ namespace moab {
      * \param leid Returns the local id of the edge corresponding to the input edge w.r.t the incident cell.
     */
 
-    bool find_matching_implicit_edge_in_cell( EntityHandle eid, EntityHandle *cid, int *leid);
+    bool find_matching_implicit_edge_in_cell( EntityHandle eid,
+                                              EntityHandle *cid,
+                                              int *leid);
 
     //! Given a face, finds a matching local face in an incident cell.
     /** Find a local face with the same connectivity as the input face, belonging to an incident cell.
@@ -479,9 +557,15 @@ namespace moab {
      * \param lfid Returns the local id of the face corresponding to the input face w.r.t the incident cell.
     */
 
-    bool find_matching_halfface(EntityHandle fid, EntityHandle *cid, int *leid);
+    bool find_matching_halfface(EntityHandle fid,
+                                EntityHandle *cid,
+                                int *leid);
 
-    bool find_match_in_array(EntityHandle ent, EntityHandle *ent_list, int count, bool get_index = false, int *index = NULL);
+    bool find_match_in_array(EntityHandle ent,
+                             EntityHandle *ent_list,
+                             int count,
+                             bool get_index = false,
+                             int *index = NULL);
 
   };
 

diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index 09f4219..bfd5fb0 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -624,7 +624,12 @@ public:
                                       const int to_dimension,
                                       const bool create_if_missing,
                                       std::vector<EntityHandle>& adj_entities,
-                                      const int operation_type = Interface::INTERSECT) = 0;
+                                      const int operation_type = Interface::INTERSECT
+    #ifdef USE_AHF
+      , const bool use_ahf = false) = 0;
+    #else
+      ) = 0;
+    #endif
 
     //! Get the adjacencies associated with a vector of entities to entities of a specfied dimension.
     /** Identical to vector-based get_adjacencies function, except results are returned in a

diff --git a/test/Makefile.am b/test/Makefile.am
index fe7edb6..34432d0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,6 +61,10 @@ if HDF5_FILE
         lloyd_smoother_test
 endif
 
+if ENABLE_ahf
+  TESTS += ahf_mbintf_test
+endif
+
 #                 merge_test \         # input files no longer exist?
 #                 test_tag_server \    # fails
 
@@ -154,6 +158,11 @@ lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
 
 ahf_test_SOURCES = test_ahf_moab.cpp
 
+if ENABLE_ahf
+ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
+endif
+
+
 if PARALLEL
 moab_test_CPPFLAGS += -I$(top_srcdir)/src/parallel
 kd_tree_test_CPPFLAGS += -I$(top_srcdir)/src/parallel

diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
new file mode 100755
index 0000000..9bf76ef
--- /dev/null
+++ b/test/test_ahf_mb_interface.cpp
@@ -0,0 +1,174 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include "TestUtil.hpp"
+
+using namespace moab;
+
+#ifdef MESHDIR
+static const char example[] = STRINGIFY(MESHDIR) "/hexes_mixed.vtk";
+#else
+static const char example[] = "/hexes_mixed.vtk";
+#endif
+
+void ahf_mbintf_test()
+{
+
+  Core moab;
+  Interface* mbImpl = &moab;
+  MeshTopoUtil mtu(mbImpl);
+
+  ErrorCode error = mbImpl->load_file(example);
+  CHECK_ERR(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);
+
+  //Perform queries
+  std::vector<EntityHandle> adjents;
+  Range mbents, ahfents;
+
+  //1D Queries //
+  //IQ1: For every vertex, obtain incident edges
+  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+    CHECK_ERR(error);
+    mbents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
+  }
+
+  //NQ1:  For every edge, obtain neighbor edges
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+    CHECK_ERR(error);
+    mbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 0, 1, 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());
+  }
+
+  // 2D Queries
+  //IQ2: 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, Interface::INTERSECT, true);
+    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());
+  }
+
+  //NQ2: For every face, obtain neighbor faces
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents, Interface::INTERSECT, true);
+    CHECK_ERR(error);
+    mbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 1, 2, 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());
+  }
+
+  // 3D Queries
+  // IQ 31: 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, Interface::INTERSECT, true);
+    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());
+  }
+
+  //IQ32: For every face, obtain incident cells
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+    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());
+  }
+
+  //NQ3: For every cell, obtain neighbor cells
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+    CHECK_ERR(error);
+    mbents.clear();
+    error = mtu.get_bridge_adjacencies( *i, 2, 3, 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());
+  }
+
+}
+
+int main(int argc, char *argv[])
+{
+  int result = 0;
+
+  argv[0] = argv[argc - argc]; // Followed read_mpas_nc.cpp test for removing warnings in serial mode about unused variables.
+
+  result += RUN_TEST(ahf_mbintf_test);
+
+  return result;
+}
+

diff --git a/test/test_ahf_moab.cpp b/test/test_ahf_moab.cpp
index ff97fb1..93bd947 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -34,7 +34,7 @@ void ahf_test()
   error = mbImpl->get_entities_by_dimension( 0, 3, cells);
 
   // Create an ahf instance
-  HalfFacetRep ahf(mbImpl);
+  HalfFacetRep ahf(&moab);
 
   // Call the initialize function which creates the maps for each dimension
   ahf.initialize();
@@ -47,7 +47,7 @@ void ahf_test()
   //IQ1: For every vertex, obtain incident edges
   for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
     adjents.clear();
-    error = ahf.get_upward_incidences( *i, 1, adjents);
+    error = ahf.get_up_adjacencies( *i, 1, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
@@ -82,7 +82,7 @@ void ahf_test()
   //IQ2: For every edge, obtain incident faces
   for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
     adjents.clear();
-    error = ahf.get_upward_incidences( *i, 2, adjents);
+    error = ahf.get_up_adjacencies( *i, 2, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
@@ -117,7 +117,7 @@ void ahf_test()
   // IQ 31: For every edge, obtain incident cells
   for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
     adjents.clear();
-    error = ahf.get_upward_incidences( *i, 3, adjents);
+    error = ahf.get_up_adjacencies( *i, 3, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -134,7 +134,7 @@ void ahf_test()
   //IQ32: For every face, obtain incident cells
   for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
     adjents.clear();
-    error = ahf.get_upward_incidences( *i, 3, adjents);
+    error = ahf.get_up_adjacencies( *i, 3, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -165,7 +165,7 @@ void ahf_test()
     CHECK(!mbents.size());
   }
 
-  ahf.deinitialize();
+  //ahf.deinitialize();
 
 }
 


https://bitbucket.org/fathomteam/moab/commits/7431d9311014/
Changeset:   7431d9311014
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Removed tag_iterate from sibling half-facet maps. Changed input to
test_ahf_moab to read in meshfile from command line. Added a test code
for timing and memory requirements.

Affected #:  9 files

diff --git a/src/Core.cpp b/src/Core.cpp
index 3641fd5..692495b 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -1540,6 +1540,12 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
 #else
                                  )
 #endif
+/*ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
+                                     const int num_entities,
+                                     const int to_dimension,
+                                     const bool create_if_missing,
+                                     std::vector<EntityHandle> &adj_entities,
+                                     const int operation_type)*/
 {
 
 #ifdef USE_AHF
@@ -1558,6 +1564,12 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
         std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
         can_handle = false;
     }
+    else if (to_dimension == 4)
+    {
+        std::cout<<"Currently Not Supported by MOAB_AHF: meshsets"<<std::endl;
+        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+        can_handle = false;
+    }
     else if (TYPE_FROM_HANDLE(from_entities[0]) == MBPOLYHEDRON)
     {
         std::cout<<"Currently Not Supported by MOAB_AHF: Polyhedron Meshes"<<std::endl;
@@ -1571,7 +1583,9 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
         can_handle = false;
     }
 
+
     if ((use_ahf) && (can_handle))
+    //if (can_handle)
     {
 
         if (operation_type == Interface::INTERSECT)

diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index f3818a6..449a48a 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -27,7 +27,7 @@
 
 namespace moab {
 
-  const int MAXSIZE = 500;
+  const int MAXSIZE = 150;
 
   HalfFacetRep::HalfFacetRep(Core *impl)
   {
@@ -573,15 +573,6 @@ namespace moab {
   {
     ErrorCode error;
 
-    EntityHandle start_edge = *edges.begin();
-    int count, *sibhvs_lvid_ptr; EntityHandle *sibhvs_eid_ptr;
-    error = mb->tag_iterate(sibhvs_eid, edges.begin(), edges.end(), count, (void*&)sibhvs_eid_ptr);
-    if (MB_SUCCESS != error) return error;
-    assert(count == (int) edges.size());
-    error = mb->tag_iterate(sibhvs_lvid, edges.begin(), edges.end(), count, (void*&)sibhvs_lvid_ptr);
-    if (MB_SUCCESS != error) return error;
-    assert(count == (int) edges.size());
-
     //Step 1: Create an index list storing the starting position for each vertex
     int nv = _verts.size();
     int *is_index = new int[nv+1];
@@ -595,8 +586,10 @@ namespace moab {
         error = mb->get_connectivity(&*eid, 1, conn);
         if (MB_SUCCESS != error) return error;
 
-        is_index[conn[0]-*_verts.begin()+1] += 1;
-        is_index[conn[1]-*_verts.begin()+1] += 1;
+        int index = _verts.index(conn[0]);
+        is_index[index+1] += 1;
+        index = _verts.index(conn[1]);
+        is_index[index+1] += 1;
       }
     is_index[0] = 0;
 
@@ -615,7 +608,7 @@ namespace moab {
 
         for (int j = 0; j< 2; j++)
           {
-            int v = conn[j] - *_verts.begin();
+            int v = _verts.index(conn[j]);
             v2hv_map_eid[is_index[v]] = *eid;
             v2hv_map_lvid[is_index[v]] = j;
             is_index[v] += 1;
@@ -633,26 +626,59 @@ namespace moab {
         error = mb->get_connectivity(&*eid, 1, conn);
         if (MB_SUCCESS != error) return error;
 
+        EntityHandle sibeid[2];
+        int siblvid[2];
+
+        error = mb->tag_get_data(sibhvs_eid, &*eid, 1, sibeid);
+        if (MB_SUCCESS != error) return error;
+
+        error = mb->tag_get_data(sibhvs_lvid, &*eid, 1, siblvid);
+        if (MB_SUCCESS != error) return error;
+
         for (int k =0; k<2; k++)
           {
-            if (sibhvs_eid_ptr[2*(*eid-start_edge)+k] != 0)
+
+            if (sibeid[k] != 0)
               continue;
 
-            int v = conn[k] - *_verts.begin();
+            int v = _verts.index(conn[k]);
             int last = is_index[v+1] - 1;
             if (last > is_index[v])
               {
                 EntityHandle prev_eid = v2hv_map_eid[last];
                 int prev_lvid = v2hv_map_lvid[last];
+
+                EntityHandle seteid[2];
+                int setlvid[2];
+                error = mb->tag_get_data(sibhvs_eid, &prev_eid, 1, seteid);
+                if (MB_SUCCESS != error) return error;
+
+                error = mb->tag_get_data(sibhvs_lvid, &prev_eid, 1, setlvid);
+                if (MB_SUCCESS != error) return error;
+
                 for (int i=is_index[v]; i<=last; i++)
                   {
                     EntityHandle cur_eid = v2hv_map_eid[i];
                     int cur_lvid = v2hv_map_lvid[i];
-                    sibhvs_eid_ptr[2*(prev_eid-start_edge) + prev_lvid] = cur_eid;
-                    sibhvs_lvid_ptr[2*(prev_eid-start_edge) + prev_lvid] = cur_lvid;
+
+
+                    seteid[prev_lvid] = cur_eid;
+                    setlvid[prev_lvid] = cur_lvid;
+
+                    error = mb->tag_set_data(sibhvs_eid, &prev_eid, 1, seteid);
+                    if (MB_SUCCESS != error) return error;
+
+                    error = mb->tag_set_data(sibhvs_lvid, &prev_eid, 1, setlvid);
+                    if (MB_SUCCESS != error) return error;
 
                     prev_eid = cur_eid;
                     prev_lvid = cur_lvid;
+                    error = mb->tag_get_data(sibhvs_eid, &prev_eid, 1, seteid);
+                    if (MB_SUCCESS != error) return error;
+
+                    error = mb->tag_get_data(sibhvs_lvid, &prev_eid, 1, setlvid);
+                    if (MB_SUCCESS != error) return error;
+
                   }
               }
           }
@@ -663,6 +689,7 @@ namespace moab {
     delete [] is_index;
     delete [] v2hv_map_eid;
     delete [] v2hv_map_lvid;
+
     return MB_SUCCESS;
   }
 
@@ -797,7 +824,7 @@ namespace moab {
     int nepf;
     if (type == MBTRI)  nepf = 3;
     else if (type ==MBQUAD)   nepf = 4;
-    
+
     return nepf;
   }
   /////////////////////////////////////////////////////////////////////////////////
@@ -807,16 +834,13 @@ namespace moab {
     // next: Local ids of next edges
     // prev: Local ids of prev edges
 
-    if (nepf == 3)
-    {  
-      next[0] = 1; next[1] = 2; next[2] = 0;
-      prev[0] = 2; prev[1] = 0; prev[2] = 1;
-    }
-    else if (nepf == 4)
-    {
-      next[0] = 1; next[1] = 2; next[2] = 3; next[3] = 0;
-      prev[0] = 3; prev[1] = 0; prev[2] = 1; prev[3] = 2;
-    }
+    for (int k=0; k<nepf-1; k++)
+       {
+         next[k]=k+1;
+         prev[k+1]=k;
+       }
+       next[nepf-1]=0;
+       prev[0] = nepf-1;
 
     return MB_SUCCESS;
   }
@@ -826,15 +850,6 @@ namespace moab {
     ErrorCode error;
     EntityHandle start_face = *faces.begin();
 
-    // Create pointers to the tags for direct access to memory
-    int count, *sibhes_leid_ptr; EntityHandle *sibhes_fid_ptr;
-    error = mb->tag_iterate(sibhes_fid, faces.begin(), faces.end(), count, (void*&)sibhes_fid_ptr);
-    if (MB_SUCCESS != error) return error;
-    assert(count == (int) faces.size());
-    error = mb->tag_iterate(sibhes_leid, faces.begin(), faces.end(), count, (void*&)sibhes_leid_ptr);
-    if (MB_SUCCESS != error) return error;
-    assert(count == (int) faces.size());
-
     int nepf = local_maps_2d(start_face);
     int * next = new int[nepf];
     int * prev = new int[nepf];
@@ -847,6 +862,7 @@ namespace moab {
     for (int i =0; i<nv+1; i++)
       is_index[i] = 0;
 
+    int index;
     std::vector<EntityHandle> conn(nepf);
     for (Range::iterator fid = faces.begin(); fid != faces.end(); ++fid)
        {
@@ -856,7 +872,8 @@ namespace moab {
 
          for (int i = 0; i<nepf; i++)
            {
-             is_index[conn[i]-*_verts.begin()+1] += 1;
+             index = _verts.index(conn[i]);
+             is_index[index+1] += 1;
            }
        }
      is_index[0] = 0;
@@ -877,7 +894,7 @@ namespace moab {
 
          for (int j = 0; j< nepf; j++)
            {
-             int v = conn[j] - *_verts.begin();
+             int v = _verts.index(conn[j]);
              v2nv[is_index[v]] = conn[next[j]];
              v2he_map_fid[is_index[v]] = *fid;
              v2he_map_leid[is_index[v]] = j;
@@ -889,6 +906,7 @@ namespace moab {
        is_index[i+1] = is_index[i];
      is_index[0] = 0;
 
+
      //Step 3: Fill up sibling half-verts map
      for (Range::iterator fid = faces.begin(); fid != faces.end(); ++fid)
        {
@@ -896,13 +914,22 @@ namespace moab {
          error = mb->get_connectivity(&*fid, 1, conn);
          if (MB_SUCCESS != error) return error;
 
+         EntityHandle *sibfid = new EntityHandle[nepf];
+         int *sibleid = new int[nepf];
+
+         error = mb->tag_get_data(sibhes_fid, &*fid, 1, sibfid);
+         if (MB_SUCCESS != error) return error;
+
+         error = mb->tag_get_data(sibhes_leid, &*fid, 1, sibleid);
+         if (MB_SUCCESS != error) return error;
+
          for (int k =0; k<nepf; k++)
            {
-             if (sibhes_fid_ptr[nepf*(*fid-start_face)+k] != 0)
+             if (sibfid[k] != 0)
                continue;
 
-             int v = conn[k] - *_verts.begin();
-             int vn = conn[next[k]] - *_verts.begin();
+             int v = _verts.index(conn[k]);
+             int vn = _verts.index(conn[next[k]]);
 
              EntityHandle first_fid = *fid;
              int first_leid = k;
@@ -910,38 +937,87 @@ namespace moab {
              EntityHandle prev_fid = *fid;
              int prev_leid = k;
 
-             for (int index = is_index[vn]; index <= is_index[vn+1]-1; index++)
+             EntityHandle *setfid = new EntityHandle[nepf];
+             int *setleid = new int[nepf];
+
+             for (index = is_index[vn]; index <= is_index[vn+1]-1; index++)
                {
                  if (v2nv[index] == conn[k])
                    {
                      EntityHandle cur_fid = v2he_map_fid[index];
                      int cur_leid = v2he_map_leid[index];
-                     sibhes_fid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_fid;
-                     sibhes_leid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_leid;
+
+                     error = mb->tag_get_data(sibhes_fid, &prev_fid, 1, setfid);
+                     if (MB_SUCCESS != error) return error;
+
+                     error = mb->tag_get_data(sibhes_leid, &prev_fid, 1, setleid);
+                     if (MB_SUCCESS != error) return error;
+
+                     setfid[prev_leid] = cur_fid;
+                     setleid[prev_leid] = cur_leid;
+
+                     error = mb->tag_set_data(sibhes_fid, &prev_fid, 1, setfid);
+                     if (MB_SUCCESS != error) return error;
+
+                     error = mb->tag_set_data(sibhes_leid, &prev_fid, 1, setleid);
+                     if (MB_SUCCESS != error) return error;
+
                      prev_fid = cur_fid;
                      prev_leid = cur_leid;
+
                    }
                }
 
-             for (int index = is_index[v]; index <= is_index[v+1]-1; index++)
+             for (index = is_index[v]; index <= is_index[v+1]-1; index++)
                {
                  if ((v2nv[index] == conn[next[k]])&&(v2he_map_fid[index] != *fid))
                    {
+
                      EntityHandle cur_fid = v2he_map_fid[index];
                      int cur_leid = v2he_map_leid[index];
-                     sibhes_fid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_fid;
-                     sibhes_leid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_leid;
+
+                     error = mb->tag_get_data(sibhes_fid, &prev_fid, 1, setfid);
+                     if (MB_SUCCESS != error) return error;
+
+                     error = mb->tag_get_data(sibhes_leid, &prev_fid, 1, setleid);
+                     if (MB_SUCCESS != error) return error;
+
+                     setfid[prev_leid] = cur_fid;
+                     setleid[prev_leid] = cur_leid;
+
+                     error = mb->tag_set_data(sibhes_fid, &prev_fid, 1, setfid);
+                     if (MB_SUCCESS != error) return error;
+
+                     error = mb->tag_set_data(sibhes_leid, &prev_fid, 1, setleid);
+                     if (MB_SUCCESS != error) return error;
+
                      prev_fid = cur_fid;
                      prev_leid = cur_leid;
                    }
                }
 
              if (prev_fid != first_fid){
-               sibhes_fid_ptr[nepf*(prev_fid-start_face) + prev_leid] = first_fid;
-               sibhes_leid_ptr[nepf*(prev_fid-start_face) + prev_leid] = first_leid;
-             }
+                 error = mb->tag_get_data(sibhes_fid, &prev_fid, 1, setfid);
+                 if (MB_SUCCESS != error) return error;
+
+                 error = mb->tag_get_data(sibhes_leid, &prev_fid, 1, setleid);
+                 if (MB_SUCCESS != error) return error;
+
+                 setfid[prev_leid] = first_fid;
+                 setleid[prev_leid] = first_leid;
+
+                 error = mb->tag_set_data(sibhes_fid, &prev_fid, 1, setfid);
+                 if (MB_SUCCESS != error) return error;
+
+                 error = mb->tag_set_data(sibhes_leid, &prev_fid, 1, setleid);
+                 if (MB_SUCCESS != error) return error;
 
+             }
+             delete [] setfid;
+             delete [] setleid;
            }
+         delete [] sibfid;
+         delete [] sibleid;
        }
 
      delete [] next;
@@ -1311,7 +1387,7 @@ namespace moab {
 	error = mb->get_connectivity(&curfid, 1, conn);
 	if (MB_SUCCESS != error) return error;
 
-	int id = next[curlid];
+    int id = next[curlid];
 	if (((conn[curlid]==edg_vert[0])&&(conn[id]==edg_vert[1]))||((conn[curlid]==edg_vert[1])&&(conn[id]==edg_vert[0]))){
 	    *he_fid = curfid;
 	    *he_lid = curlid;
@@ -1336,7 +1412,7 @@ namespace moab {
 	counter += 1;
       }
       
-    delete [] next; 
+    delete [] next;
     delete [] prev;
     return found;
   }
@@ -1417,7 +1493,7 @@ namespace moab {
   }
 
   /////////////////////////////////////////////
-   HalfFacetRep::LocalMaps3D HalfFacetRep::lConnMap3D[4] = 
+   const HalfFacetRep::LocalMaps3D HalfFacetRep::lConnMap3D[4] =
     {
       // Tet
       {4, 6, 4, {3,3,3,3}, {{0,1,3},{1,2,3},{2,0,3},{0,2,1}},   {3,3,3,3},   {{0,2,3},{0,1,3},{1,2,3},{0,1,2}},   {{0,1},{1,2},{2,0},{0,3},{1,3},{2,3}},   {{3,0},{3,1},{3,2},{0,2},{0,1},{1,2}},   {{0,4,3},{1,5,4},{2,3,5},{2,1,0}},     {{-1,0,2,3},{0,-1,1,4},{2,1,-1,5},{3,4,5,-1}}},
@@ -1439,16 +1515,6 @@ namespace moab {
   {
     ErrorCode error;
     EntityHandle start_cell = *cells.begin();
-
-    int count, *sibhfs_lfid_ptr;
-    EntityHandle *sibhfs_cid_ptr;
-    error = mb->tag_iterate(sibhfs_cid, cells.begin(), cells.end(), count, (void*&)sibhfs_cid_ptr);
-    if (MB_SUCCESS != error) return error;
-    assert(count == (int) cells.size());
-    error = mb->tag_iterate(sibhfs_lfid, cells.begin(), cells.end(), count, (void*&)sibhfs_lfid_ptr);
-    if (MB_SUCCESS != error) return error;
-    assert(count == (int) cells.size());
-
     int index = get_index_from_type(start_cell);
     int nvpc = lConnMap3D[index].num_verts_in_cell;
     int nfpc = lConnMap3D[index].num_faces_in_cell;
@@ -1459,6 +1525,7 @@ namespace moab {
     for (int i =0; i<nv+1; i++)
       is_index[i] = 0;
 
+    int vindex;
     std::vector<EntityHandle> conn(nvpc);
     for (Range::iterator cid = cells.begin(); cid != cells.end(); ++cid)
        {
@@ -1476,7 +1543,8 @@ namespace moab {
                 if (v <= conn[id])
                   v = conn[id];
               }
-            is_index[v-*_verts.begin()+1] += 1;
+            vindex = _verts.index(v);
+            is_index[vindex+1] += 1;
           }
       }
      is_index[0] = 0;
@@ -1518,7 +1586,7 @@ namespace moab {
              error = local_maps_2d(nvF, next, prev);
              if (MB_SUCCESS != error) return error;
 
-             int v = vmax - *_verts.begin();
+             int v = _verts.index(vmax);
              v2oe_v1[is_index[v]] = vs[next[lv]];
              v2oe_v2[is_index[v]] = vs[prev[lv]];
              v2hf_map_cid[is_index[v]] = *cid;
@@ -1542,9 +1610,18 @@ namespace moab {
          error = mb->get_connectivity(&*cid, 1, conn);
          if (MB_SUCCESS != error) return error;
 
+         EntityHandle *sibcid = new EntityHandle[nfpc];
+         int *siblfid = new int[nfpc];
+
+         error = mb->tag_get_data(sibhfs_cid, &*cid, 1, sibcid);
+         if (MB_SUCCESS != error) return error;
+
+         error = mb->tag_get_data(sibhfs_lfid, &*cid, 1, siblfid);
+         if (MB_SUCCESS != error) return error;
+
          for (int i =0; i<nfpc; i++)
            {
-             if (sibhfs_cid_ptr[nfpc*(*cid-start_cell)+i] != 0)
+             if (sibcid[i] != 0)
                continue;
 
 
@@ -1568,31 +1645,60 @@ namespace moab {
              error = local_maps_2d(nvF, next, prev);
              if (MB_SUCCESS != error) return error;
 
-             int v = vmax - *_verts.begin();
+             int v = _verts.index(vmax);
              EntityHandle v1 = vs[prev[lv]];
              EntityHandle v2 = vs[next[lv]];
 
+             EntityHandle *setcid = new EntityHandle[nfpc];
+             int *setlfid = new int[nfpc];
+
              for (int ind = is_index[v]; ind <= is_index[v+1]-1; ind++)
                {
                  if ((v2oe_v1[ind] == v1)&&(v2oe_v2[ind] == v2))
                    {
-
+                     // Map to opposite hf
                      EntityHandle cur_cid = v2hf_map_cid[ind];
                      int cur_lfid = v2hf_map_lfid[ind];
 
-                     sibhfs_cid_ptr[nfpc*(*cid-start_cell)+i] = cur_cid;
-                     sibhfs_lfid_ptr[nfpc*(*cid-start_cell)+i] = cur_lfid;
+                     error = mb->tag_get_data(sibhfs_cid, &*cid, 1, setcid);
+                     if (MB_SUCCESS != error) return error;
+
+                     error = mb->tag_get_data(sibhfs_lfid, &*cid, 1, setlfid);
+                     if (MB_SUCCESS != error) return error;
+
+                     setcid[i] = cur_cid;
+                     setlfid[i] = cur_lfid;
+
+                     error = mb->tag_set_data(sibhfs_cid, &*cid, 1, setcid);
+                     if (MB_SUCCESS != error) return error;
+                     error = mb->tag_set_data(sibhfs_lfid, &*cid, 1, setlfid);
+                     if (MB_SUCCESS != error) return error;
+
+                     //Map opposite hf to current cell
+                     error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, setcid);
+                     if (MB_SUCCESS != error) return error;
+
+                     error = mb->tag_get_data(sibhfs_lfid, &cur_cid, 1, setlfid);
+                     if (MB_SUCCESS != error) return error;
 
-                     sibhfs_cid_ptr[nfpc*(cur_cid-start_cell)+cur_lfid] = *cid;
-                     sibhfs_lfid_ptr[nfpc*(cur_cid-start_cell)+cur_lfid] = i;
+                     setcid[cur_lfid] = *cid;
+                     setlfid[cur_lfid] = i;
 
+                     error = mb->tag_set_data(sibhfs_cid, &cur_cid, 1, setcid);
+                     if (MB_SUCCESS != error) return error;
+                     error = mb->tag_set_data(sibhfs_lfid, &cur_cid, 1, setlfid);
+                     if (MB_SUCCESS != error) return error;
                    }
                }
 
              delete [] next;
              delete [] prev;
              delete [] vs;
+             delete [] setcid;
+             delete [] setlfid;
            }
+         delete sibcid;
+         delete siblfid;
        }
 
 
@@ -2115,10 +2221,8 @@ namespace moab {
   bool HalfFacetRep::find_match_in_array(EntityHandle ent, EntityHandle *ent_list, int count, bool get_index, int *index)
   {
     bool found = false;
-   // std::cout<<"count = "<<count<<std::endl;
     for (int i = 0; i<= count; i++)
       {
-     //   std::cout<<"For i = "<<i<<": ent-ent_list[i] = "<<(int)(ent-ent_list[i])<<std::endl;
         if (!((int)(ent - ent_list[i])))
           {
             found = true;

diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index 941129a..20aafdc 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -328,6 +328,16 @@ public:
     #endif
 
 
+  /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+                                       const int num_entities,
+                                       const int to_dimension,
+                                       const bool create_if_missing,
+                                       std::vector<EntityHandle>& adj_entities,
+                                       const int operation_type = Interface::INTERSECT);*/
+
+
+
+
     virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
                                         const int num_entities,
                                          const int to_dimension,

diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index 3d1069a..344dbd1 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -533,7 +533,7 @@ namespace moab {
       int lookup_leids[MAX_VERTICES][MAX_VERTICES];
     };
 
-    static  LocalMaps3D lConnMap3D[4];
+    static const LocalMaps3D lConnMap3D[4];
 
     int get_index_from_type(EntityHandle cid);
 

diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index bfd5fb0..57252e9 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -630,6 +630,12 @@ public:
     #else
       ) = 0;
     #endif
+  /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+                                      const int num_entities,
+                                      const int to_dimension,
+                                      const bool create_if_missing,
+                                      std::vector<EntityHandle>& adj_entities,
+                                      const int operation_type = Interface::INTERSECT) = 0; */
 
     //! Get the adjacencies associated with a vector of entities to entities of a specfied dimension.
     /** Identical to vector-based get_adjacencies function, except results are returned in a

diff --git a/test/Makefile.am b/test/Makefile.am
index 34432d0..1354e3c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,9 +61,9 @@ if HDF5_FILE
         lloyd_smoother_test
 endif
 
-if ENABLE_ahf
-  TESTS += ahf_mbintf_test
-endif
+# if ENABLE_ahf
+#  TESTS += ahf_mbintf_test
+# endif
 
 #                 merge_test \         # input files no longer exist?
 #                 test_tag_server \    # fails
@@ -158,9 +158,9 @@ lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
 
 ahf_test_SOURCES = test_ahf_moab.cpp
 
-if ENABLE_ahf
-ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
-endif
+# if ENABLE_ahf
+# ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
+# endif
 
 
 if PARALLEL

diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index f946f94..32e2a57 100644
--- a/test/perf/Makefile.am
+++ b/test/perf/Makefile.am
@@ -7,13 +7,14 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
             
 LDADD = $(top_builddir)/src/libMOAB.la
 
-check_PROGRAMS = perf seqperf adj_time perftool
+check_PROGRAMS = perf seqperf adj_time perftool ahf_mem_time
 noinst_PROGRAMS = 
 
 perf_SOURCES = perf.cpp
 seqperf_SOURCES = seqperf.cpp
 adj_time_SOURCES = adj_time.cpp
 perftool_SOURCES = perftool.cpp
+ahf_mem_time_SOURCES = test_ahf_mem_time.cpp
 
 if ENABLE_imesh
   LDADD += $(top_builddir)/itaps/imesh/libiMesh.la

diff --git a/test/perf/test_ahf_mem_time.cpp b/test/perf/test_ahf_mem_time.cpp
new file mode 100755
index 0000000..9c72ae7
--- /dev/null
+++ b/test/perf/test_ahf_mem_time.cpp
@@ -0,0 +1,281 @@
+/*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_elapsed, time_avg;
+
+  // Create an ahf instance
+  HalfFacetRep ahf(&moab);
+
+  // Call the initialize function which creates the maps for each dimension
+  time_start = wtime();
+
+  ahf.initialize();
+
+  time_elapsed = wtime() - time_start;
+  std::cout << "Time taken to construct the MDS = "<<time_elapsed<<" secs"<<std::endl;
+
+  //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;
+  std::vector<int> lids;
+  Range 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 = ahf.get_up_adjacencies( *i, 1, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)verts.size();
+  std::cout<<"MOAB_AHF: Average time taken to compute incident edges to a vertex =  "<< time_avg<<" secs" <<std::endl;
+
+  error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
+  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<<"MOAB: Average time taken to compute incident edges to a vertex =  "<< 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 = ahf.get_neighbor_adjacencies( *i, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"MOAB_AHF: Average time taken to compute neighbor edges of an edge = "<<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<<"MOAB: Average time taken to compute neighbor edges of an edge = "<<time_avg<<" secs" << std::endl;
+  std::cout<<std::endl;
+
+
+  // 2D Queries
+  //IQ21: For every edge, obtain incident faces
+  std::cout<<"2D QUERIES"<<std::endl;
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {   
+    adjents.clear();
+    error = ahf.get_up_adjacencies( *i, 2, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"MOAB_AHF: Average time taken to compute incident faces on an edge =  "<<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<<"MOAB: Average time taken to compute incident faces on an edge =  "<<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 = ahf.get_neighbor_adjacencies( *i, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"MOAB_AHF: Average time taken to compute neighbor faces of a face = "<< 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<<"MOAB: Average time taken to compute neighbor faces of a face = "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+
+
+  // 3D Queries
+  // IQ 31: For every edge, obtain incident cells
+  std::cout<<"3D QUERIES"<<std::endl;
+  time_start = wtime();
+  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+    adjents.clear();
+    error = ahf.get_up_adjacencies( *i, 3, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)edges.size();
+  std::cout<<"MOAB_AHF: Average time taken to compute incident cells on an edge  =  "<<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<<"MOAB: Average time taken to compute incident cells on an edge  =  "<<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 = ahf.get_up_adjacencies( *i, 3, adjents);
+
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+  std::cout<<"MOAB_AHF: Average time taken to compute incident cells on a face  =  "<<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<<"MOAB: Average time taken to compute incident cells on a face  =  "<<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 = ahf.get_neighbor_adjacencies( *i, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+  std::cout<<"MOAB_AHF: Average time taken to compute neighbor cells of a cell =  "<< 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<<"MOAB: Average time taken to compute neighbor cells of a cell =  "<< time_avg <<" secs" << std::endl;
+  std::cout<<std::endl;
+
+  ahf.deinitialize();
+
+  //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_moab.cpp b/test/test_ahf_moab.cpp
index 93bd947..e415186 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -11,172 +11,203 @@
 using namespace moab;
 
 #ifdef MESHDIR
-static const char example[] = STRINGIFY(MESHDIR) "/hexes_mixed.vtk";
+std::string TestDir(STRINGIFY(MESHDIR));
 #else
-static const char example[] = "/hexes_mixed.vtk";
+std::string TestDir(".");
 #endif
 
-void ahf_test()
-{
-
-  Core moab;
-  Interface* mbImpl = &moab;
-  MeshTopoUtil mtu(mbImpl);
-
-  ErrorCode error = mbImpl->load_file(example);
-  CHECK_ERR(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);
-
-  // Create an ahf instance
-  HalfFacetRep ahf(&moab);
-
-  // Call the initialize function which creates the maps for each dimension
-  ahf.initialize();
-
-  //Perform queries
-  std::vector<EntityHandle> adjents;
-  Range mbents, ahfents;
-
-  //1D Queries //
-  //IQ1: For every vertex, obtain incident edges
-  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_up_adjacencies( *i, 1, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
-  }
-
-  //NQ1:  For every edge, obtain neighbor edges
-  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_neighbor_adjacencies( *i, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mtu.get_bridge_adjacencies( *i, 0, 1, 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());
-  }
-
-  // 2D Queries
-  //IQ2: For every edge, obtain incident faces
-  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_up_adjacencies( *i, 2, 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::string filename;
 
-    std::sort(adjents.begin(), adjents.end());
-    std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
-    mbents = subtract(mbents, ahfents);
-    CHECK(!mbents.size());
-  }
+int number_tests_successful = 0;
+int number_tests_failed = 0;
 
-  //NQ2: For every face, obtain neighbor faces
-  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_neighbor_adjacencies( *i, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mtu.get_bridge_adjacencies( *i, 1, 2, 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());
+void handle_error_code(ErrorCode rv, int &number_failed, int &number_successful)
+{
+  if (rv == MB_SUCCESS) {
+    std::cout << "Success";
+    number_successful++;
+  } else {
+    std::cout << "Failure";
+    number_failed++;
   }
+}
 
-  // 3D Queries
-  // IQ 31: For every edge, obtain incident cells
-  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_up_adjacencies( *i, 3, 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());
-  }
 
-  //IQ32: For every face, obtain incident cells
-  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_up_adjacencies( *i, 3, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
-    CHECK_ERR(error);
-
-    CHECK_EQUAL(adjents.size(), mbents.size());
+ErrorCode ahf_test(Core *moab)
+{
 
-    std::sort(adjents.begin(), adjents.end());
-    std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
-    mbents = subtract(mbents, ahfents);
-    CHECK(!mbents.size());
-  }
+    Interface* mbImpl = &*moab;
+    MeshTopoUtil mtu(mbImpl);
 
-  //NQ3: For every cell, obtain neighbor cells
-  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_neighbor_adjacencies( *i, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+    ErrorCode error = mbImpl->load_file(filename.c_str());
     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());
-  }
-
-  //ahf.deinitialize();
+    /*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);
+
+    // Create an ahf instance
+    HalfFacetRep ahf(&*moab);
+
+    // Call the initialize function which creates the maps for each dimension
+    ahf.initialize();
+
+    //ahf.print_tags();
+
+    //Perform queries
+    std::vector<EntityHandle> adjents;
+    Range mbents, ahfents;
+
+    //1D Queries //
+    //IQ1: For every vertex, obtain incident edges
+    for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 1, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
+    }
+
+    //NQ1:  For every edge, obtain neighbor edges
+    for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_neighbor_adjacencies( *i, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 0, 1, 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());
+    }
+
+    // 2D Queries
+    //IQ2: For every edge, obtain incident faces
+    for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 2, 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());
+    }
+
+    //NQ2: For every face, obtain neighbor faces
+    for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_neighbor_adjacencies( *i, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 1, 2, 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());
+    }
+
+    // 3D Queries
+    // IQ 31: For every edge, obtain incident cells
+    for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 3, 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());
+    }
+
+    //IQ32: For every face, obtain incident cells
+    for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 3, 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());
+    }
+
+    //NQ3: For every cell, obtain neighbor cells
+    for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_neighbor_adjacencies( *i, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 2, 3, 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());
+    }
+
+    return MB_SUCCESS;
 
 }
 
 int main(int argc, char *argv[])
 {
-  int result = 0;
-
-  argv[0] = argv[argc - argc]; // Followed read_mpas_nc.cpp test for removing warnings in serial mode about unused variables.
-
-  result += RUN_TEST(ahf_test);
-
-  return result;
+    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;
+    }
+
+    Core moab;
+    ErrorCode result;
+
+    std::cout<<" ahf_test: ";
+    result = ahf_test(&moab);
+    handle_error_code(result, number_tests_failed, number_tests_successful);
+    std::cout<<"\n";
+
+    return number_tests_failed;
 }
 


https://bitbucket.org/fathomteam/moab/commits/7c0456989c29/
Changeset:   7c0456989c29
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Removed 'use_ahf' flag from get_adjacencies interface in Core/Interface.
Passed make check.

Affected #:  9 files

diff --git a/src/Core.cpp b/src/Core.cpp
index 692495b..3340934 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -280,6 +280,7 @@ ErrorCode Core::initialize()
   ahfRep = new HalfFacetRep(this);
   if (!ahfRep)
     return MB_MEMORY_ALLOCATION_FAILED;
+  mesh_modified = false;
 #endif
 
   return MB_SUCCESS;
@@ -1353,14 +1354,11 @@ ErrorCode get_adjacencies_union( Core* gMB,
   return result;
 }
 
-
-///////////////////////////
-///
-#ifdef USE_AHF
 template <typename ITER> static inline
-ErrorCode get_adjacencies_intersection_ahf(Core *mb,
+ErrorCode get_adjacencies_intersection( Core* mb,
                              ITER begin, ITER end,
                              const int to_dimension,
+                             const bool create_if_missing,
                              std::vector<EntityHandle>& adj_entities )
 {
   const size_t SORT_THRESHOLD = 200;
@@ -1378,11 +1376,13 @@ ErrorCode get_adjacencies_intersection_ahf(Core *mb,
     // input list), we begin with the adjacencies for the first entity.
   if (adj_entities.empty()) {
     EntityType type = TYPE_FROM_HANDLE(*begin);
-
-    if(to_dimension == 0 && type != MBPOLYHEDRON)
+    if (to_dimension == CN::Dimension(type))
+      adj_entities.push_back(*begin);
+    else if(to_dimension == 0 && type != MBPOLYHEDRON)
       result = mb->get_connectivity(&(*begin), 1, adj_entities);
     else
-      result = mb->a_half_facet_rep()->get_adjacencies(*begin, to_dimension, adj_entities);
+      result = mb->a_entity_factory()->get_adjacencies(*begin, to_dimension,
+                                                   create_if_missing, adj_entities);
     if (MB_SUCCESS != result)
       return result;
     ++begin;
@@ -1395,10 +1395,13 @@ ErrorCode get_adjacencies_intersection_ahf(Core *mb,
 
       // get the next set of adjacencies
     EntityType type = TYPE_FROM_HANDLE(*from_it);
-    if(to_dimension == 0 && type != MBPOLYHEDRON)
+    if (to_dimension == CN::Dimension(type))
+      temp_vec.push_back(*from_it);
+    else if(to_dimension == 0 && type != MBPOLYHEDRON)
       result = mb->get_connectivity(&(*from_it), 1, temp_vec);
     else
-      result = mb->a_half_facet_rep()->get_adjacencies(*from_it, to_dimension, temp_vec);
+      result = mb->a_entity_factory()->get_adjacencies(*from_it, to_dimension,
+                                                   create_if_missing, temp_vec);
     if (MB_SUCCESS != result)
       return result;
 
@@ -1424,14 +1427,43 @@ ErrorCode get_adjacencies_intersection_ahf(Core *mb,
 
   return MB_SUCCESS;
 }
-#endif
-///////////////////////////////////////////
 
 template <typename ITER> static inline
 ErrorCode get_adjacencies_intersection( Core* mb,
                              ITER begin, ITER end,
                              const int to_dimension,
                              const bool create_if_missing,
+                             Range& adj_entities )
+{
+  std::vector<EntityHandle> results;
+  ErrorCode rval = moab::get_adjacencies_intersection( mb, begin, end, to_dimension,
+						       create_if_missing, results );
+  if (MB_SUCCESS != rval)
+    return rval;
+
+  if (adj_entities.empty()) {
+    std::copy( results.begin(), results.end(), range_inserter(adj_entities) );
+    return MB_SUCCESS;
+  }
+
+  Range::iterator it = adj_entities.begin();
+  while (it != adj_entities.end()) {
+    if (std::find( results.begin(), results.end(), *it) == results.end())
+      it = adj_entities.erase( it );
+    else
+      ++it;
+  }
+  return MB_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////
+//////////////////////////////////////////
+#ifdef USE_AHF
+
+template <typename ITER> static inline
+ErrorCode get_adjacencies_intersection_ahf(Core *mb,
+                             ITER begin, ITER end,
+                             const int to_dimension,
                              std::vector<EntityHandle>& adj_entities )
 {
   const size_t SORT_THRESHOLD = 200;
@@ -1449,13 +1481,11 @@ ErrorCode get_adjacencies_intersection( Core* mb,
     // input list), we begin with the adjacencies for the first entity.
   if (adj_entities.empty()) {
     EntityType type = TYPE_FROM_HANDLE(*begin);
-    if (to_dimension == CN::Dimension(type))
-      adj_entities.push_back(*begin);
-    else if(to_dimension == 0 && type != MBPOLYHEDRON)
+
+    if(to_dimension == 0 && type != MBPOLYHEDRON)
       result = mb->get_connectivity(&(*begin), 1, adj_entities);
     else
-      result = mb->a_entity_factory()->get_adjacencies(*begin, to_dimension,
-                                                   create_if_missing, adj_entities);
+      result = mb->a_half_facet_rep()->get_adjacencies(*begin, to_dimension, adj_entities);
     if (MB_SUCCESS != result)
       return result;
     ++begin;
@@ -1468,13 +1498,10 @@ ErrorCode get_adjacencies_intersection( Core* mb,
 
       // get the next set of adjacencies
     EntityType type = TYPE_FROM_HANDLE(*from_it);
-    if (to_dimension == CN::Dimension(type))
-      temp_vec.push_back(*from_it);
-    else if(to_dimension == 0 && type != MBPOLYHEDRON)
+    if(to_dimension == 0 && type != MBPOLYHEDRON)
       result = mb->get_connectivity(&(*from_it), 1, temp_vec);
     else
-      result = mb->a_entity_factory()->get_adjacencies(*from_it, to_dimension,
-                                                   create_if_missing, temp_vec);
+      result = mb->a_half_facet_rep()->get_adjacencies(*from_it, to_dimension, temp_vec);
     if (MB_SUCCESS != result)
       return result;
 
@@ -1500,52 +1527,16 @@ ErrorCode get_adjacencies_intersection( Core* mb,
 
   return MB_SUCCESS;
 }
+#endif
 
-template <typename ITER> static inline
-ErrorCode get_adjacencies_intersection( Core* mb,
-                             ITER begin, ITER end,
-                             const int to_dimension,
-                             const bool create_if_missing,
-                             Range& adj_entities )
-{
-  std::vector<EntityHandle> results;
-  ErrorCode rval = moab::get_adjacencies_intersection( mb, begin, end, to_dimension,
-						       create_if_missing, results );
-  if (MB_SUCCESS != rval)
-    return rval;
-
-  if (adj_entities.empty()) {
-    std::copy( results.begin(), results.end(), range_inserter(adj_entities) );
-    return MB_SUCCESS;
-  }
-
-  Range::iterator it = adj_entities.begin();
-  while (it != adj_entities.end()) {
-    if (std::find( results.begin(), results.end(), *it) == results.end())
-      it = adj_entities.erase( it );
-    else
-      ++it;
-  }
-  return MB_SUCCESS;
-}
+///////////////////////////////////////////
 
 ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
                                      const int num_entities,
                                      const int to_dimension,
                                      const bool create_if_missing,
                                      std::vector<EntityHandle> &adj_entities,
-                                     const int operation_type
-#ifdef USE_AHF
-                                 , const bool use_ahf)
-#else
-                                 )
-#endif
-/*ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
-                                     const int num_entities,
-                                     const int to_dimension,
-                                     const bool create_if_missing,
-                                     std::vector<EntityHandle> &adj_entities,
-                                     const int operation_type)*/
+                                     const int operation_type)
 {
 
 #ifdef USE_AHF
@@ -1553,41 +1544,22 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
     int source_dim = this->dimension_from_handle(from_entities[0]);
 
     if ((source_dim > to_dimension) && (to_dimension != 0))
-    {
-        std::cout<<"Currently Not Supported by MOAB_AHF: Down Adjacencies"<<std::endl;
-        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
-        can_handle = false;
-    }
-    else if (((source_dim == 0) && (to_dimension == 2))||((source_dim == 0) && (to_dimension == 3)))
-    {
-        std::cout<<"Currently Not Supported by MOAB_AHF: Vertex to face/cell"<<std::endl;
-        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
-        can_handle = false;
-    }
+        can_handle = false; //NOT SUPPORTED: Down adjacencies
     else if (to_dimension == 4)
-    {
-        std::cout<<"Currently Not Supported by MOAB_AHF: meshsets"<<std::endl;
-        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
-        can_handle = false;
-    }
-    else if (TYPE_FROM_HANDLE(from_entities[0]) == MBPOLYHEDRON)
-    {
-        std::cout<<"Currently Not Supported by MOAB_AHF: Polyhedron Meshes"<<std::endl;
-        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
-        can_handle = false;
-    }
+        can_handle = false; // NOT SUPPORTED: meshsets
     else if (create_if_missing)
-    {
-        std::cout<<"Currently Not Supporteded by MOAB_AHF: create_if_missing capability "<<std::endl;
-        std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+        can_handle = false;//NOT SUPPORTED: create_if_missing
+
+    bool mixed = ahfRep->check_mixed_entity_type(); //NOT SUPPORTED: mixed entity types or polygonal/hedrals types
+    if (mixed)
         can_handle = false;
-    }
 
+    if (mesh_modified)
+        can_handle = false;
 
-    if ((use_ahf) && (can_handle))
-    //if (can_handle)
+    if (can_handle)
     {
-
+        ErrorCode result;
         if (operation_type == Interface::INTERSECT)
             return get_adjacencies_intersection_ahf(this, from_entities, from_entities+num_entities,
                                                     to_dimension, adj_entities );
@@ -1595,7 +1567,7 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
             return MB_FAILURE;
 
         // do union
-        ErrorCode result;
+
         std::vector<EntityHandle> tmp_storage;
         const EntityHandle* conn;
         int len;
@@ -1668,14 +1640,14 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
                                      Range &adj_entities,
                                      const int operation_type )
 {
-  if (operation_type == Interface::INTERSECT)
-    return get_adjacencies_intersection( this, from_entities, from_entities + num_entities,
-                                         to_dimension, create_if_missing, adj_entities );
-  else if (operation_type == Interface::UNION)
-    return get_adjacencies_union( this, from_entities, from_entities + num_entities,
-                                  to_dimension, create_if_missing, adj_entities );
-  else
-    return MB_FAILURE;
+    if (operation_type == Interface::INTERSECT)
+        return get_adjacencies_intersection( this, from_entities, from_entities + num_entities,
+                                             to_dimension, create_if_missing, adj_entities );
+    else if (operation_type == Interface::UNION)
+        return get_adjacencies_union( this, from_entities, from_entities + num_entities,
+                                      to_dimension, create_if_missing, adj_entities );
+    else
+        return MB_FAILURE;
 }
 
 ErrorCode Core::get_connectivity( const Range& from_entities,
@@ -2754,6 +2726,11 @@ ErrorCode Core::create_element(const EntityType type,
   if (MB_SUCCESS == status)
     status = aEntityFactory->notify_create_entity( handle, connectivity, num_nodes);
 
+#ifdef USE_AHF
+  mesh_modified = true;
+#endif
+
+
   return status;
 }
 

diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 449a48a..18a8a0d 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -34,6 +34,8 @@ namespace moab {
     assert(NULL != impl);
     mb = impl;
     mInitAHFmaps = false;
+    chk_mixed = false;
+    is_mixed = false;
   }
 
   HalfFacetRep::~HalfFacetRep()
@@ -65,6 +67,89 @@ namespace moab {
     return mesh_type;
   }
 
+  const HalfFacetRep::adj_matrix HalfFacetRep::adjMatrix[7] =
+  {
+      // Stores the adjacency matrix for each mesh type.
+      //CURVE
+      {{{0,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}},
+
+      //SURFACE
+      {{{0,0,1,0},{0,0,0,0},{1,0,1,0},{0,0,0,0}}},
+
+      //SURFACE_MIXED
+      {{{0,1,1,0},{1,1,1,0},{1,0,1,0},{0,0,0,0}}},
+
+      //VOLUME
+      {{{0,0,0,1},{0,0,0,0},{0,0,0,0},{1,0,0,1}}},
+
+      //VOLUME_MIXED_1
+      {{{0,1,0,1},{1,1,0,1},{0,0,0,0},{1,0,0,1}}},
+
+      //VOLUME_MIXED_2
+      {{{0,0,1,1},{0,0,0,0},{1,0,1,1},{1,0,0,1}}},
+
+      //VOLUME_MIXED
+      {{{0,1,1,1},{1,1,1,1},{1,0,1,1},{1,0,0,1}}}
+  };
+
+  int HalfFacetRep::get_index_for_meshtype(MESHTYPE mesh_type)
+  {
+      int index;
+      if (mesh_type == CURVE) index = 0;
+      else if (mesh_type == SURFACE) index = 1;
+      else if (mesh_type == SURFACE_MIXED) index = 2;
+      else if (mesh_type == VOLUME)  index = 3;
+      else if (mesh_type == VOLUME_MIXED_1) index = 4;
+      else if (mesh_type == VOLUME_MIXED_2) index = 5;
+      else if (mesh_type == VOLUME_MIXED) index = 6;
+      return index;
+  }
+
+  bool HalfFacetRep::check_mixed_entity_type()
+  {
+      if (!chk_mixed)
+      {
+          chk_mixed = true;
+
+          ErrorCode error;
+          Range felems, celems;
+
+          error = mb->get_entities_by_dimension( 0, 2, felems );
+          if (MB_SUCCESS != error) return error;
+
+          if (felems.size()){
+              Range tris, quad, poly;
+              tris = felems.subset_by_type(MBTRI);
+              quad = felems.subset_by_type(MBQUAD);
+              poly = felems.subset_by_type(MBPOLYGON);
+              if ((tris.size()&&quad.size())||(tris.size()&&poly.size())||(quad.size()&&poly.size()))
+                  is_mixed = true;
+              if (poly.size())
+                  is_mixed = true;
+
+              return is_mixed;
+          }
+
+          error = mb->get_entities_by_dimension( 0, 3, celems);
+          if (MB_SUCCESS != error) return error;
+          if (celems.size()){
+              Range tet, pyr, prism, hex, polyhed;
+              tet = celems.subset_by_type(MBTET);
+              pyr = celems.subset_by_type(MBPYRAMID);
+              prism = celems.subset_by_type(MBPRISM);
+              hex = celems.subset_by_type(MBHEX);
+              polyhed = celems.subset_by_type(MBPOLYHEDRON);
+              if ((tet.size() && pyr.size())||(tet.size() && prism.size())||(tet.size() && hex.size())||(tet.size()&&polyhed.size())||(pyr.size() && prism.size())||(pyr.size() && hex.size()) ||(pyr.size()&&polyhed.size())|| (prism.size() && hex.size())||(prism.size()&&polyhed.size())||(hex.size()&&polyhed.size()))
+                  is_mixed = true;
+
+              if (polyhed.size())
+                  is_mixed = true;
+              return is_mixed;
+          }
+      }
+      return is_mixed;
+  }
+
   /*******************************************************
    * initialize                                          *
    ******************************************************/
@@ -93,8 +178,10 @@ namespace moab {
     int ncells = _cells.size();
 
     MESHTYPE mesh_type = get_mesh_type(nverts, nedges, nfaces, ncells);
-    std::cout<<"MeshType = "<<mesh_type<<std::endl;
- 
+    thismeshtype = mesh_type;
+    std::cout<<"MeshType = "<<thismeshtype<<std::endl;
+  
+    //Initialize mesh type specific maps
     if (mesh_type == CURVE){
         error = init_curve();
         if (MB_SUCCESS != error) return error;
@@ -460,50 +547,78 @@ namespace moab {
 
       if (mInitAHFmaps == false)
       {
-       error = initialize();
-       if (MB_SUCCESS != error) return error;
-      }
-
-      if ((source_dimension == 0) && (target_dimension == 1))
-      {
-          error = get_up_adjacencies_1d(source_entity, target_entities);
+          error = initialize();
           if (MB_SUCCESS != error) return error;
       }
 
-      else if ((source_dimension == 1) && (target_dimension == 2))
-      {
-          error = get_up_adjacencies_2d(source_entity, target_entities);
-          if (MB_SUCCESS != error) return error;
-      }
-      else if ((source_dimension == 1) && (target_dimension == 3))
-      {
-          error = get_up_adjacencies_edg_3d(source_entity, target_entities);
-          if (MB_SUCCESS != error) return error;
-      }
-      else if ((source_dimension == 2) && (target_dimension ==3))
-      {
-          error = get_up_adjacencies_face_3d(source_entity, target_entities);
-          if (MB_SUCCESS != error) return error;
-      }
-      else if (source_dimension == target_dimension)
+      int mindex = get_index_for_meshtype(thismeshtype);
+      int adj_possible = adjMatrix[mindex].val[source_dimension][target_dimension];
+
+      if (adj_possible)
       {
-          if (target_dimension == 1)
+
+          if (source_dimension == 0) // Vertex to up adjacencies
           {
-              error = get_neighbor_adjacencies_1d(source_entity, target_entities);
-              if (MB_SUCCESS != error) return error;
+              if (target_dimension == 1)
+              {
+                  error = get_up_adjacencies_1d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
+              else if (target_dimension == 2)
+              {
+                  error = get_up_adjacencies_vert_2d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
+              else if (target_dimension == 3)
+              {
+                  error = get_up_adjacencies_vert_3d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
           }
 
-          else if (target_dimension == 2)
+          else if (source_dimension == 1) // Edge to up adjacencies
           {
-              error = get_neighbor_adjacencies_2d(source_entity, target_entities);
-              if (MB_SUCCESS != error) return error;
+              if (target_dimension == 2)
+              {
+                  error = get_up_adjacencies_2d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
+              else if (target_dimension == 3)
+              {
+                  error = get_up_adjacencies_edg_3d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
           }
-          else if (target_dimension == 3)
+
+          else if ((source_dimension == 2) && (target_dimension ==3)) // Face to up adjacencies
           {
-              error = get_neighbor_adjacencies_3d(source_entity, target_entities);
+              error = get_up_adjacencies_face_3d(source_entity, target_entities);
               if (MB_SUCCESS != error) return error;
           }
+
+          else if (source_dimension == target_dimension) // Same dimensional adjacencies
+          {
+              if (target_dimension == 1)
+              {
+                  error = get_neighbor_adjacencies_1d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
+
+              else if (target_dimension == 2)
+              {
+                  error = get_neighbor_adjacencies_2d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
+              else if (target_dimension == 3)
+              {
+                  error = get_neighbor_adjacencies_3d(source_entity, target_entities);
+                  if (MB_SUCCESS != error) return error;
+              }
+          }
       }
+      else
+          return MB_SUCCESS;
+
       return MB_SUCCESS;
   }
 
@@ -517,10 +632,23 @@ namespace moab {
     ErrorCode error;
     int in_dim = mb->dimension_from_handle(ent);
 
-    if ((in_dim == 0) && (out_dim == 1))
+    if (in_dim == 0)
       {
-        error = get_up_adjacencies_1d(ent, adjents, local_id, lids);
-        if (MB_SUCCESS != error) return error;
+        if (out_dim == 1)
+        {
+            error = get_up_adjacencies_1d(ent, adjents, local_id, lids);
+            if (MB_SUCCESS != error) return error;
+        }
+        else if (out_dim == 2)
+        {
+            error = get_up_adjacencies_vert_2d(ent, adjents);
+            if (MB_SUCCESS != error) return error;
+        }
+        else if (out_dim == 3)
+        {
+            error = get_up_adjacencies_vert_3d(ent, adjents);
+            if (MB_SUCCESS != error) return error;
+        }
       }
 
     else if ((in_dim == 1) && (out_dim == 2))
@@ -1070,7 +1198,7 @@ namespace moab {
     return MB_SUCCESS;
   }
   ///////////////////////////////////////////////////////////////////
- /* ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle vid, std::vector<EntityHandle> &adjents)
+  ErrorCode HalfFacetRep::get_up_adjacencies_vert_2d(EntityHandle vid, std::vector<EntityHandle> &adjents)
   {
     ErrorCode error;
 
@@ -1092,12 +1220,12 @@ namespace moab {
             queue_lid[i] = 0;
             trackfaces[i] = 0;
           }
-        int qsize = 0, tcount = -1;
+        int qsize = 0, count = -1;
         int num_qvals = 0;
-        error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &tcount);
+        error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
         if (MB_SUCCESS != error) return error;
 
-        while (num_qvals < *qsize)
+        while (num_qvals < qsize)
           {
             EntityHandle curfid = queue_fid[num_qvals];
             int curlid = queue_lid[num_qvals];
@@ -1107,22 +1235,23 @@ namespace moab {
             error = another_halfedge(vid, curfid, curlid, &he2_fid, &he2_lid);
             if (MB_SUCCESS != error) return error;
 
-            bool found_ent = find_match_in_array(he2_fid, trackfaces, tcount[0]);
+            bool found_ent = find_match_in_array(he2_fid, trackfaces, count);
 
             if (found_ent)
               continue;
-            tcount[0] += 1;
-            trackfaces[tcount[0]] = he2_fid;
+            count += 1;
+            trackfaces[count] = he2_fid;
 
-            error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+            error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
             if (MB_SUCCESS != error) return error;
 
             adjents.push_back(he2_fid);
 
           }
       }
+    return MB_SUCCESS;
   }
-*/
+
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   ErrorCode  HalfFacetRep::get_up_adjacencies_2d( EntityHandle eid,
                                                   std::vector<EntityHandle> &adjents,
@@ -1803,6 +1932,85 @@ namespace moab {
 
     return MB_SUCCESS;
   }
+  ////////////////////////////////////////////////////////////////////////
+  ErrorCode HalfFacetRep::get_up_adjacencies_vert_3d(EntityHandle vid, std::vector<EntityHandle> &adjents)
+  {
+      ErrorCode error;
+
+      // Obtain a half-face incident on v
+      EntityHandle cur_cid = 0;
+      error = mb->tag_get_data(v2hf_cid, &vid, 1, &cur_cid);
+      if (MB_SUCCESS != error) return error;
+
+      int index = get_index_from_type(cur_cid);
+      int nvpc = lConnMap3D[index].num_verts_in_cell;
+      int nfpc = lConnMap3D[index].num_faces_in_cell;
+
+      // Collect all incident cells
+      if (cur_cid != 0){
+          EntityHandle Stkcells[MAXSIZE], trackcells[MAXSIZE];
+          for (int i = 0; i< MAXSIZE; i++)
+            {
+              Stkcells[i] = 0;
+              trackcells[i] = 0;
+            }
+          int Stksize = 0, count = -1;
+          Stkcells[0] = cur_cid;
+
+          while (Stksize >= 0 ){
+              cur_cid = Stkcells[Stksize];
+              Stksize -= 1 ;
+
+              bool found = find_match_in_array(cur_cid, trackcells, count);
+              if (!found){
+                  count += 1;
+                  trackcells[count] = cur_cid;
+
+                  // Add the current cell
+                  adjents.push_back(cur_cid);
+              }
+
+              // Connectivity of the cell
+              std::vector<EntityHandle> conn;
+              error = mb->get_connectivity(&cur_cid, 1, conn);
+              if (MB_SUCCESS != error) return error;
+
+              // Local id of vid in the cell and the half-faces incident on it
+              int lv;
+              for (int i = 0; i< nvpc; ++i){
+                  if (conn[i] == vid)
+                      lv = i;
+              };
+
+              int nhf_thisv = lConnMap3D[index].v2hf_num[lv];
+
+              // Add other cells that are incident on vid to the stack
+              std::vector<EntityHandle> sib_cids(nfpc);
+              error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, &sib_cids[0]);
+              if (MB_SUCCESS != error) return error;
+
+              // Add new cells into the stack
+              EntityHandle ngb;
+              for (int i = 0; i < nhf_thisv; ++i){
+                  int ind = lConnMap3D[index].v2hf[lv][i];
+                  ngb = sib_cids[ind];
+
+                  if (ngb) {
+                      bool found_ent = find_match_in_array(ngb, trackcells, count);
+
+                      if (!found_ent){
+                          Stksize += 1;
+                          Stkcells[Stksize] = ngb;
+                      }
+                  }
+              }
+              // Add the current cell
+              //adjents.push_back(cur_cid);
+          }
+      }
+
+      return MB_SUCCESS;
+  }
 
  //////////////////////////////////////////////////////////////////////////////////////////////
   ErrorCode HalfFacetRep::get_up_adjacencies_edg_3d( EntityHandle eid,
@@ -2126,23 +2334,23 @@ namespace moab {
             error = mb->get_connectivity(&cur_cid, 1, conn);
             if (MB_SUCCESS != error) return error;
 
-	    // Local id of fid_verts[0] in the cell
-	    int lv0;
-	    for (int i = 0; i< nvpc; ++i){
-		if (conn[i] == fid_verts[0])
-		  {
-		    lv0 = i;
-		  }
+            // Local id of fid_verts[0] in the cell
+            int lv0;
+            for (int i = 0; i< nvpc; ++i){
+                if (conn[i] == fid_verts[0])
+                {
+                    lv0 = i;
+                }
 	      };
 
-	    int nhf_thisv = lConnMap3D[index].v2hf_num[lv0];
+            int nhf_thisv = lConnMap3D[index].v2hf_num[lv0];
 
             // Search each half-face to match input face
             for(int i = 0; i < nhf_thisv; ++i){
                 int lfid = lConnMap3D[index].v2hf[lv0][i];
                 int nv_curF = lConnMap3D[index].hf2v_num[lfid];
                 if (nv_curF != nvF)
-                  continue;
+                    continue;
 
                 // Connectivity of the current half-face
 
@@ -2150,7 +2358,7 @@ namespace moab {
                 for(int l = 0; l < nvF; ++l){
                     int ind = lConnMap3D[index].hf2v[lfid][l];
                     vthisface[l] = conn[ind];
-                  };
+                };
 
 
                 // Match this half-face with input fid
@@ -2163,32 +2371,32 @@ namespace moab {
                     lid[0] = lfid;
 
                     break;
-                  }
-              }
+                }
+            }
 
-	    // Add other cells that are incident on fid_verts[0]
-	    std::vector<EntityHandle> sib_cids(nfpc);
-	    error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, &sib_cids[0]);
-	    if (MB_SUCCESS != error) return error;
+            // Add other cells that are incident on fid_verts[0]
+            std::vector<EntityHandle> sib_cids(nfpc);
+            error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, &sib_cids[0]);
+            if (MB_SUCCESS != error) return error;
 
-	    // Add new cells into the stack
-	    EntityHandle ngb;
-	    for (int i = 0; i < nhf_thisv; ++i){
-		int ind = lConnMap3D[index].v2hf[lv0][i];
-		ngb = sib_cids[ind];
+            // Add new cells into the stack
+            EntityHandle ngb;
+            for (int i = 0; i < nhf_thisv; ++i){
+                int ind = lConnMap3D[index].v2hf[lv0][i];
+                ngb = sib_cids[ind];
 
-		if (ngb) {
+                if (ngb) {
 
-		    bool found_ent = find_match_in_array(ngb, trackcells, count);
+                    bool found_ent = find_match_in_array(ngb, trackcells, count);
 
-		    if (!found_ent){
-			Stksize += 1;
-			Stkcells[Stksize] = ngb;
-		      }
-		  }
-	      }
-	  }
-      }
+                    if (!found_ent){
+                        Stksize += 1;
+                        Stkcells[Stksize] = ngb;
+                    }
+                }
+            }
+        }
+    }
     return found;
   }
 

diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index 20aafdc..d8b155e 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -315,30 +315,16 @@ public:
             get_adjacencies( from_entities, MB_1D_ENTITY, adjacencies ); 
             \endcode */
 
-  virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+   virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
                                        const int num_entities,
                                        const int to_dimension,
                                        const bool create_if_missing,
                                        std::vector<EntityHandle>& adj_entities,
-                                       const int operation_type = Interface::INTERSECT
-    #ifdef USE_AHF
-      , const bool use_ahf = false);
-    #else
-      );
-    #endif
-
-
-  /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
-                                       const int num_entities,
-                                       const int to_dimension,
-                                       const bool create_if_missing,
-                                       std::vector<EntityHandle>& adj_entities,
-                                       const int operation_type = Interface::INTERSECT);*/
-
+                                       const int operation_type = Interface::INTERSECT);
 
 
 
-    virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+   virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
                                         const int num_entities,
                                          const int to_dimension,
                                          const bool create_if_missing,
@@ -1375,6 +1361,7 @@ private:
 
 #ifdef USE_AHF
   HalfFacetRep *ahfRep;
+  bool mesh_modified;
 #endif
   
 };

diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index 344dbd1..a228520 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -62,6 +62,8 @@ namespace moab {
     
     ~HalfFacetRep();
 
+    bool check_mixed_entity_type();
+
     // User interface functions
 
     //! Creates all the necessary tags to store the maps. Constructs the sibling-half-facet and vertex-to-incident-half-facet maps for each dimension present in the input.
@@ -177,8 +179,7 @@ namespace moab {
 
     ErrorCode determine_incident_halfedges(Range &faces);
 
-   /* ErrorCode get_up_adjacencies_2d(EntityHandle vid,
-                                       std::vector<EntityHandle> &adjents);*/
+    ErrorCode get_up_adjacencies_vert_2d(EntityHandle vid, std::vector<EntityHandle> &adjents);
 
     //! Given an edge, finds the faces incident on it.
     /** Given an edge, it first finds a matching half-edge corresponding to eid, and then
@@ -260,6 +261,9 @@ namespace moab {
     ErrorCode determine_border_vertices( Range &cells,
                                          Tag isborder);
 
+
+    ErrorCode get_up_adjacencies_vert_3d(EntityHandle vid, std::vector<EntityHandle> &adjents);
+
     //! Given an edge, finds the cells incident on it.
     /** Given an edge, it first finds a matching local edge in a cell corresponding to eid, and then
      * collects all the incident cells via the sibhfs map.
@@ -353,9 +357,20 @@ namespace moab {
     Tag sibhes_fid, sibhes_leid, v2he_fid, v2he_leid;
     Tag sibhfs_cid, sibhfs_lfid, v2hf_cid, v2hf_lfid;
 
-
+    MESHTYPE thismeshtype;
     MESHTYPE get_mesh_type(int nverts, int nedges, int nfaces, int ncells);
 
+    struct adj_matrix{
+        int val[4][4];
+    };
+
+    static const adj_matrix adjMatrix[7];
+    int get_index_for_meshtype(MESHTYPE mesh_type);
+
+    // These two flags are for checking mixed entity type meshes
+    bool is_mixed;
+    bool chk_mixed;
+
     ErrorCode init_curve();
     ErrorCode init_surface();
     ErrorCode init_volume();
@@ -364,6 +379,7 @@ namespace moab {
     ErrorCode deinit_surface();
     ErrorCode deinit_volume();
 
+
     //! Contains the local information for 2D entities
     /** Given a face, find the face type specific information
      * Parameters:

diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index 57252e9..0b9e8e9 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -619,23 +619,13 @@ public:
             get_adjacencies( from_entities, 2, 1, false, adjacencies, Interface::INTERSECT); 
             \endcode 
     */
+
   virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
                                       const int num_entities,
                                       const int to_dimension,
                                       const bool create_if_missing,
                                       std::vector<EntityHandle>& adj_entities,
-                                      const int operation_type = Interface::INTERSECT
-    #ifdef USE_AHF
-      , const bool use_ahf = false) = 0;
-    #else
-      ) = 0;
-    #endif
-  /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
-                                      const int num_entities,
-                                      const int to_dimension,
-                                      const bool create_if_missing,
-                                      std::vector<EntityHandle>& adj_entities,
-                                      const int operation_type = Interface::INTERSECT) = 0; */
+                                      const int operation_type = Interface::INTERSECT) = 0;
 
     //! Get the adjacencies associated with a vector of entities to entities of a specfied dimension.
     /** Identical to vector-based get_adjacencies function, except results are returned in a

diff --git a/test/MBTest.cpp b/test/MBTest.cpp
index d70753f..a4f5d8a 100644
--- a/test/MBTest.cpp
+++ b/test/MBTest.cpp
@@ -6559,7 +6559,7 @@ ErrorCode mb_skin_verts_common( unsigned dim, bool skin_elems )
     std::cout << "Extra/non-returned elements created: " << extra << std::endl;
     return MB_FAILURE;
   }
-    
+
     // check that each skin vertex has the correct number of adjacent quads
   missing.clear(); extra.clear();
   for (Range::iterator i = expected.begin(); i != expected.end(); ++i) {

diff --git a/test/Makefile.am b/test/Makefile.am
index 1354e3c..33ca518 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,9 +61,9 @@ if HDF5_FILE
         lloyd_smoother_test
 endif
 
-# if ENABLE_ahf
-#  TESTS += ahf_mbintf_test
-# endif
+if ENABLE_ahf
+  TESTS += ahf_mbintf_test
+endif
 
 #                 merge_test \         # input files no longer exist?
 #                 test_tag_server \    # fails
@@ -158,9 +158,9 @@ lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
 
 ahf_test_SOURCES = test_ahf_moab.cpp
 
-# if ENABLE_ahf
-# ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
-# endif
+if ENABLE_ahf
+ ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
+endif
 
 
 if PARALLEL

diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
index 9bf76ef..3d8257f 100755
--- a/test/test_ahf_mb_interface.cpp
+++ b/test/test_ahf_mb_interface.cpp
@@ -41,7 +41,7 @@ void ahf_mbintf_test()
   //IQ1: For every vertex, obtain incident edges
   for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
     adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
@@ -58,7 +58,7 @@ void ahf_mbintf_test()
   //NQ1:  For every edge, obtain neighbor edges
   for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
     adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
@@ -76,7 +76,7 @@ void ahf_mbintf_test()
   //IQ2: 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, Interface::INTERSECT, true);
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
@@ -93,7 +93,7 @@ void ahf_mbintf_test()
   //NQ2: For every face, obtain neighbor faces
   for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
     adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents, Interface::INTERSECT, true);
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
@@ -111,7 +111,7 @@ void ahf_mbintf_test()
   // IQ 31: 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, Interface::INTERSECT, true);
+    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -128,7 +128,7 @@ void ahf_mbintf_test()
   //IQ32: For every face, obtain incident cells
   for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
     adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -145,7 +145,7 @@ void ahf_mbintf_test()
   //NQ3: For every cell, obtain neighbor cells
   for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
     adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
     CHECK_ERR(error);
     mbents.clear();
     error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);

diff --git a/test/test_ahf_moab.cpp b/test/test_ahf_moab.cpp
index e415186..a9185ae 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -97,7 +97,25 @@ ErrorCode ahf_test(Core *moab)
     }
 
     // 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 = ahf.get_up_adjacencies( *i, 2, 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 = ahf.get_up_adjacencies( *i, 2, adjents);
@@ -132,7 +150,24 @@ ErrorCode ahf_test(Core *moab)
     }
 
     // 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 = ahf.get_up_adjacencies( *i, 3, 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 = ahf.get_up_adjacencies( *i, 3, adjents);
@@ -149,7 +184,7 @@ ErrorCode ahf_test(Core *moab)
         CHECK(!mbents.size());
     }
 
-    //IQ32: For every face, obtain incident cells
+    //IQ33: For every face, obtain incident cells
     for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
         adjents.clear();
         error = ahf.get_up_adjacencies( *i, 3, adjents);


https://bitbucket.org/fathomteam/moab/commits/38d5e3b3418e/
Changeset:   38d5e3b3418e
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
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);


https://bitbucket.org/fathomteam/moab/commits/dfc0e561138a/
Changeset:   dfc0e561138a
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Corrected memory deallocation. Removed warnings when configured with
--enable-ahf.

Affected #:  3 files

diff --git a/src/Core.cpp b/src/Core.cpp
index 3340934..9bfb9ca 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -302,6 +302,11 @@ void Core::deinitialize()
     delete *vit;
 #endif
 
+#ifdef USE_AHF
+  delete ahfRep;
+  ahfRep = 0;
+#endif
+
   if (aEntityFactory)
     delete aEntityFactory;
 
@@ -334,10 +339,6 @@ void Core::deinitialize()
     MPI_Finalize();
 #endif
 
-#ifdef USE_AHF
-  delete ahfRep;
-  ahfRep = 0;
-#endif
 }
 
 ErrorCode Core::query_interface_type( const std::type_info& type, void*& ptr )

diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index af8c187..fbda680 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -38,16 +38,12 @@ namespace moab {
     is_mixed = false;
   }
 
-  HalfFacetRep::~HalfFacetRep()
-  {
-    ErrorCode result;
-    result = deinitialize();
-    //if (MB_SUCCESS != result) return result;
-  }
+  HalfFacetRep::~HalfFacetRep() {}
+
 
   MESHTYPE HalfFacetRep::get_mesh_type(int nverts, int nedges, int nfaces, int ncells)
   {
-    MESHTYPE mesh_type;
+    MESHTYPE mesh_type = CURVE;
 
     if (nverts && nedges && (!nfaces) && (!ncells))
       mesh_type = CURVE;
@@ -94,7 +90,7 @@ namespace moab {
 
   int HalfFacetRep::get_index_for_meshtype(MESHTYPE mesh_type)
   {
-      int index;
+      int index = 0;
       if (mesh_type == CURVE) index = 0;
       else if (mesh_type == SURFACE) index = 1;
       else if (mesh_type == SURFACE_MIXED) index = 2;
@@ -181,42 +177,42 @@ namespace moab {
     thismeshtype = mesh_type;
   
     //Initialize mesh type specific maps
-    if (mesh_type == CURVE){
+    if (thismeshtype == CURVE){
         error = init_curve();
         if (MB_SUCCESS != error) return error;
       }
     
-    else if (mesh_type == SURFACE){
+    else if (thismeshtype == SURFACE){
       error = init_surface();
       if (MB_SUCCESS != error) return error;
       }
 
-    else if (mesh_type == SURFACE_MIXED){
+    else if (thismeshtype == SURFACE_MIXED){
         error = init_curve();
         if (MB_SUCCESS != error) return error;
         error = init_surface();
         if (MB_SUCCESS != error) return error;
       }
-    else if (mesh_type == VOLUME){
+    else if (thismeshtype == VOLUME){
         error = init_volume();
         if (MB_SUCCESS != error) return error;
       }
 
-    else if (mesh_type == VOLUME_MIXED_1){
+    else if (thismeshtype == VOLUME_MIXED_1){
         error = init_curve();
         if (MB_SUCCESS != error) return error;
         error = init_volume();
         if (MB_SUCCESS != error) return error;
     }
 
-    else if (mesh_type == VOLUME_MIXED_2){
+    else if (thismeshtype == VOLUME_MIXED_2){
         error = init_surface();
         if (MB_SUCCESS != error) return error;
         error = init_volume();
         if (MB_SUCCESS != error) return error;
       }
 
-    else if (mesh_type == VOLUME_MIXED){
+    else if (thismeshtype == VOLUME_MIXED){
         error = init_curve();
         if (MB_SUCCESS != error) return error;
         error = init_surface();
@@ -329,39 +325,38 @@ namespace moab {
    ErrorCode HalfFacetRep::deinitialize()
    {
      ErrorCode error;
-     MESHTYPE mesh_type = get_mesh_type(_verts.size(), _edges.size(), _faces.size(), _cells.size());
 
-     if (mesh_type == CURVE){
+     if (thismeshtype == CURVE){
          error = deinit_curve();
          if (MB_SUCCESS != error) return error;
        }
-     else if (mesh_type == SURFACE){
+     else if (thismeshtype == SURFACE){
          error = deinit_surface();
          if (MB_SUCCESS != error) return error;
        }
-     else if (mesh_type == SURFACE_MIXED){
+     else if (thismeshtype == SURFACE_MIXED){
          error = deinit_curve();
          if (MB_SUCCESS != error) return error;
          error = deinit_surface();
          if (MB_SUCCESS != error) return error;
        }
-     else if (mesh_type == VOLUME){
+     else if (thismeshtype == VOLUME){
          error = deinit_volume();
          if (MB_SUCCESS != error) return error;
        }
-     else if (mesh_type == VOLUME_MIXED_1){
+     else if (thismeshtype == VOLUME_MIXED_1){
          error = deinit_curve();
          if (MB_SUCCESS != error) return error;
          error = deinit_volume();
          if (MB_SUCCESS != error) return error;
        }
-     else if (mesh_type == VOLUME_MIXED_2){
+     else if (thismeshtype == VOLUME_MIXED_2){
          error = deinit_surface();
          if (MB_SUCCESS != error) return error;
          error = deinit_volume();
-         if (MB_SUCCESS != error) return error;         
+         if (MB_SUCCESS != error) return error;
        }
-     else if (mesh_type == VOLUME_MIXED){
+     else if (thismeshtype == VOLUME_MIXED){
          error = deinit_curve();
          if (MB_SUCCESS != error) return error;
          error = deinit_surface();
@@ -946,7 +941,7 @@ namespace moab {
     // nepf: Number of edges per face
     EntityType type = mb->type_from_handle(face);
 
-    int nepf;
+    int nepf = 0;
     if (type == MBTRI)  nepf = 3;
     else if (type ==MBQUAD)   nepf = 4;
 
@@ -1603,7 +1598,7 @@ namespace moab {
 
   int HalfFacetRep::get_index_from_type(EntityHandle cid)
   {
-    int index;
+    int index = 0;
     EntityType type = mb->type_from_handle(cid);
     if (type == MBTET)
       index = 0;
@@ -1822,8 +1817,8 @@ namespace moab {
              delete [] setcid;
              delete [] setlfid;
            }
-         delete sibcid;
-         delete siblfid;
+         delete [] sibcid;
+         delete [] siblfid;
        }
 
 
@@ -1970,7 +1965,7 @@ namespace moab {
               if (MB_SUCCESS != error) return error;
 
               // Local id of vid in the cell and the half-faces incident on it
-              int lv;
+              int lv = -1;
               for (int i = 0; i< nvpc; ++i){
                   if (conn[i] == vid)
                       lv = i;
@@ -2241,7 +2236,7 @@ namespace moab {
         error =mb->get_connectivity(&cell_id, 1, conn);
         if (MB_SUCCESS != error) return error;
 
-        int lv0 = -1, lv1 = -1, lv;
+        int lv0 = -1, lv1 = -1, lv = -1;
 
         //locate v_origin in poped out tet, check if v_end is in
         for (int i = 0; i<nvpc; i++){
@@ -2329,7 +2324,7 @@ namespace moab {
             if (MB_SUCCESS != error) return error;
 
             // Local id of fid_verts[0] in the cell
-            int lv0;
+            int lv0 = -1;
             for (int i = 0; i< nvpc; ++i){
                 if (conn[i] == fid_verts[0])
                 {

diff --git a/test/test_ahf_moab.cpp b/test/test_ahf_moab.cpp
index a9185ae..759f7b0 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -218,6 +218,8 @@ ErrorCode ahf_test(Core *moab)
         CHECK(!mbents.size());
     }
 
+    ahf.deinitialize();
+
     return MB_SUCCESS;
 
 }


https://bitbucket.org/fathomteam/moab/commits/f70fc9fbb253/
Changeset:   f70fc9fbb253
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Changed ahf moab interface test to accept an input file.

Affected #:  1 file

diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
index f4f754f..321d043 100755
--- a/test/test_ahf_mb_interface.cpp
+++ b/test/test_ahf_mb_interface.cpp
@@ -11,198 +11,228 @@
 using namespace moab;
 
 #ifdef MESHDIR
-static const char example[] = STRINGIFY(MESHDIR) "/hexes_mixed.vtk";
+std::string TestDir(STRINGIFY(MESHDIR));
 #else
-static const char example[] = "/hexes_mixed.vtk";
+std::string TestDir(".");
 #endif
 
-void ahf_mbintf_test()
-{
-
-  Core moab;
-  Interface* mbImpl = &moab;
-  MeshTopoUtil mtu(mbImpl);
-
-  ErrorCode error = mbImpl->load_file(example);
-  CHECK_ERR(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);
-
-  //Perform queries
-  std::vector<EntityHandle> adjents;
-  Range mbents, ahfents;
-
-  //1D Queries //
-  //IQ1: For every vertex, obtain incident edges
-  for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
-    adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
-  }
-
-  //NQ1:  For every edge, obtain neighbor edges
-  for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
-    adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
-    CHECK_ERR(error);
-
-    CHECK_EQUAL(adjents.size(), mbents.size());
+std::string filename;
 
-    std::sort(adjents.begin(), adjents.end());
-    std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
-    mbents = subtract(mbents, ahfents);
-    CHECK(!mbents.size());
-  }
-
-  // 2D Queries
-  // 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);
-    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());
-  }
-
-  //NQ2: For every face, obtain neighbor faces
-  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
-    adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
-    CHECK_ERR(error);
-    mbents.clear();
-    error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
-    CHECK_ERR(error);
+int number_tests_successful = 0;
+int number_tests_failed = 0;
 
-    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());
-  }
-
-  // 3D Queries
-  //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);
-    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());
+void handle_error_code(ErrorCode rv, int &number_failed, int &number_successful)
+{
+  if (rv == MB_SUCCESS) {
+    std::cout << "Success";
+    number_successful++;
+  } else {
+    std::cout << "Failure";
+    number_failed++;
   }
+}
 
-  //IQ32: For every face, obtain incident cells
-  for (Range::iterator i = faces.begin(); i != faces.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());
-  }
+ErrorCode ahf_mbintfc_test(Core *moab)
+{
+    Interface* mbImpl = &*moab;
+    MeshTopoUtil mtu(mbImpl);
 
-  //NQ3: For every cell, obtain neighbor cells
-  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
-    adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+    ErrorCode error = mbImpl->load_file(filename.c_str());
     CHECK_ERR(error);
-    mbents.clear();
-    error = mtu.get_bridge_adjacencies( *i, 2, 3, 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());
-  }
+    /*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);
+
+    //Perform queries
+    std::vector<EntityHandle> adjents;
+    Range mbents, ahfents;
+
+    //1D Queries //
+    //IQ1: For every vertex, obtain incident edges
+    for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+        adjents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
+    }
+
+    //NQ1:  For every edge, obtain neighbor edges
+    for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+        adjents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 0, 1, 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());
+    }
+
+    // 2D Queries
+    // 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);
+        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());
+    }
+
+    //NQ2: For every face, obtain neighbor faces
+    for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+        adjents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 1, 2, 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());
+    }
+
+    // 3D Queries
+    //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);
+        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());
+    }
+
+    //IQ32: For every face, obtain incident cells
+    for (Range::iterator i = faces.begin(); i != faces.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());
+    }
+
+    //NQ3: For every cell, obtain neighbor cells
+    for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+        adjents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 2, 3, 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());
+    }
+
+    return MB_SUCCESS;
 
 }
 
 int main(int argc, char *argv[])
 {
-  int result = 0;
 
-  argv[0] = argv[argc - argc]; // Followed read_mpas_nc.cpp test for removing warnings in serial mode about unused variables.
+    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;
+    }
+
+    Core moab;
+    ErrorCode result;
 
-  result += RUN_TEST(ahf_mbintf_test);
+    std::cout<<" ahf_mbintfc_test: ";
+    result = ahf_mbintfc_test(&moab);
+    handle_error_code(result, number_tests_failed, number_tests_successful);
+    std::cout<<"\n";
 
-  return result;
+    return number_tests_failed;
 }
 


https://bitbucket.org/fathomteam/moab/commits/f7794c267f95/
Changeset:   f7794c267f95
Branch:      None
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Added down adjacencies. Merged separate performance tests for AHF and
MOAB adjacencies into one. Some optimization.

Affected #:  11 files

diff --git a/src/Core.cpp b/src/Core.cpp
index 9bfb9ca..e8cdf33 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -1542,11 +1542,8 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
 
 #ifdef USE_AHF
     bool can_handle = true;
-    int source_dim = this->dimension_from_handle(from_entities[0]);
 
-    if ((source_dim > to_dimension) && (to_dimension != 0))
-        can_handle = false; //NOT SUPPORTED: Down adjacencies
-    else if (to_dimension == 4)
+    if (to_dimension == 4)
         can_handle = false; // NOT SUPPORTED: meshsets
     else if (create_if_missing)
         can_handle = false;//NOT SUPPORTED: create_if_missing
@@ -1555,7 +1552,7 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
     if (mixed)
         can_handle = false;
 
-    if (mesh_modified)
+    if (mesh_modified) //NOT SUPPORTED: modified mesh
         can_handle = false;
 
     if (can_handle)

diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index fbda680..4e363e3 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -27,8 +27,6 @@
 
 namespace moab {
 
-  const int MAXSIZE = 150;
-
   HalfFacetRep::HalfFacetRep(Core *impl)
   {
     assert(NULL != impl);
@@ -73,19 +71,19 @@ namespace moab {
       {{{0,0,1,0},{0,0,0,0},{1,0,1,0},{0,0,0,0}}},
 
       //SURFACE_MIXED
-      {{{0,1,1,0},{1,1,1,0},{1,0,1,0},{0,0,0,0}}},
+      {{{0,1,1,0},{1,1,1,0},{1,1,1,0},{0,0,0,0}}},
 
       //VOLUME
       {{{0,0,0,1},{0,0,0,0},{0,0,0,0},{1,0,0,1}}},
 
       //VOLUME_MIXED_1
-      {{{0,1,0,1},{1,1,0,1},{0,0,0,0},{1,0,0,1}}},
+      {{{0,1,0,1},{1,1,0,1},{0,0,0,0},{1,1,0,1}}},
 
       //VOLUME_MIXED_2
-      {{{0,0,1,1},{0,0,0,0},{1,0,1,1},{1,0,0,1}}},
+      {{{0,0,1,1},{0,0,0,0},{1,0,1,1},{1,0,1,1}}},
 
       //VOLUME_MIXED
-      {{{0,1,1,1},{1,1,1,1},{1,0,1,1},{1,0,0,1}}}
+      {{{0,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}}
   };
 
   int HalfFacetRep::get_index_for_meshtype(MESHTYPE mesh_type)
@@ -278,6 +276,17 @@ namespace moab {
     error = determine_incident_halfedges(_faces);
     if (MB_SUCCESS != error) return error;
 
+    //Create face tags
+    error = mb->tag_get_handle("__VISITED_FACE", 1, MB_TYPE_INTEGER, visited_face, MB_TAG_DENSE | MB_TAG_CREAT, &ival);
+    if (MB_SUCCESS != error) return error;
+
+    //Initialize queues for storing face and local id's during local search
+    for (int i = 0; i< MAXSIZE; i++)
+      {
+        queue_fid[i] = 0;
+        queue_lid[i] = 0;
+      }
+
     delete [] sdefval;
     delete [] sval;
 
@@ -299,6 +308,7 @@ namespace moab {
         sval[i] = 0;
       }
 
+    //Create tags to store ahf maps for volume
     error = mb->tag_get_handle("__SIBHFS_CID", nfpc, MB_TYPE_HANDLE, sibhfs_cid, MB_TAG_DENSE | MB_TAG_CREAT, sdefval);
     if (MB_SUCCESS != error) return error;
     error = mb->tag_get_handle("__SIBHFS_LFID", nfpc, MB_TYPE_INTEGER, sibhfs_lfid, MB_TAG_DENSE | MB_TAG_CREAT, sval);
@@ -308,11 +318,17 @@ namespace moab {
     error = mb->tag_get_handle("__V2HF_LFID", 1, MB_TYPE_INTEGER, v2hf_lfid, MB_TAG_DENSE | MB_TAG_CREAT, &ival);
     if (MB_SUCCESS != error) return error;
 
+    //Construct the maps
     error = determine_sibling_halffaces(_cells);
     if (MB_SUCCESS != error) return error;
     error = determine_incident_halffaces(_cells);
     if (MB_SUCCESS != error) return error;
 
+
+    //Create cell tag
+    error = mb->tag_get_handle("__VISITED_CELL", 1, MB_TYPE_INTEGER, visited_cell, MB_TAG_DENSE | MB_TAG_CREAT, &ival);
+    if (MB_SUCCESS != error) return error;
+
     delete [] sdefval;
     delete [] sval;
 
@@ -393,6 +409,9 @@ namespace moab {
      error = mb->tag_delete(v2he_leid);
      if (MB_SUCCESS != error) return error;
 
+     error = mb->tag_delete(visited_face);
+     if (MB_SUCCESS != error) return error;
+
      return MB_SUCCESS;
    }
 
@@ -407,6 +426,10 @@ namespace moab {
      error = mb->tag_delete(v2hf_lfid);
      if (MB_SUCCESS != error) return error;
 
+     error = mb->tag_delete(visited_cell);
+     if (MB_SUCCESS != error) return error;
+
+
      return MB_SUCCESS;
    }
 
@@ -550,64 +573,20 @@ namespace moab {
 
       if (adj_possible)
       {
-
-          if (source_dimension == 0) // Vertex to up adjacencies
-          {
-              if (target_dimension == 1)
-              {
-                  error = get_up_adjacencies_1d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
-              else if (target_dimension == 2)
-              {
-                  error = get_up_adjacencies_vert_2d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
-              else if (target_dimension == 3)
-              {
-                  error = get_up_adjacencies_vert_3d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
-          }
-
-          else if (source_dimension == 1) // Edge to up adjacencies
+          if (source_dimension < target_dimension)
           {
-              if (target_dimension == 2)
-              {
-                  error = get_up_adjacencies_2d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
-              else if (target_dimension == 3)
-              {
-                  error = get_up_adjacencies_edg_3d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
+              error = get_up_adjacencies(source_entity, target_dimension, target_entities);
+              if (MB_SUCCESS != error) return error;
           }
-
-          else if ((source_dimension == 2) && (target_dimension ==3)) // Face to up adjacencies
+          else if (source_dimension == target_dimension)
           {
-              error = get_up_adjacencies_face_3d(source_entity, target_entities);
+              error = get_neighbor_adjacencies(source_entity, target_entities);
               if (MB_SUCCESS != error) return error;
           }
-
-          else if (source_dimension == target_dimension) // Same dimensional adjacencies
+          else
           {
-              if (target_dimension == 1)
-              {
-                  error = get_neighbor_adjacencies_1d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
-
-              else if (target_dimension == 2)
-              {
-                  error = get_neighbor_adjacencies_2d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
-              else if (target_dimension == 3)
-              {
-                  error = get_neighbor_adjacencies_3d(source_entity, target_entities);
-                  if (MB_SUCCESS != error) return error;
-              }
+              error = get_down_adjacencies(source_entity, target_dimension, target_entities);
+              if (MB_SUCCESS != error) return error;
           }
       }
       else
@@ -688,6 +667,28 @@ namespace moab {
      return MB_SUCCESS;
    }
 
+   ErrorCode HalfFacetRep::get_down_adjacencies(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents)
+   {
+       ErrorCode error;
+       int in_dim = mb->dimension_from_handle(ent);
+       if ((in_dim == 2)&&(out_dim == 1))
+       {
+           error = get_down_adjacencies_2d(ent, adjents);
+           if (MB_SUCCESS != error) return error;
+       }
+       else if ((in_dim == 3)&&(out_dim == 1))
+       {
+           error = get_down_adjacencies_edg_3d(ent, adjents);
+           if (MB_SUCCESS != error) return error;
+       }
+       else if ((in_dim == 3)&&(out_dim == 2))
+       {
+           error = get_down_adjacencies_face_3d(ent, adjents);
+           if (MB_SUCCESS != error) return error;
+       }
+       return MB_SUCCESS;
+   }
+
   /******************************************************** 
   * 1D: sibhvs, v2hv, incident and neighborhood queries   *
   *********************************************************/
@@ -1203,17 +1204,9 @@ namespace moab {
       {
         adjents.push_back(fid);
 
-        EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
-        int queue_lid[MAXSIZE];
-        for (int i = 0; i< MAXSIZE; i++)
-          {
-            queue_fid[i] = 0;
-            queue_lid[i] = 0;
-            trackfaces[i] = 0;
-          }
-        int qsize = 0, count = -1;
+        int qsize = 0;
         int num_qvals = 0;
-        error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
+        error = gather_halfedges(vid, fid, lid, &qsize);
         if (MB_SUCCESS != error) return error;
 
         while (num_qvals < qsize)
@@ -1226,20 +1219,35 @@ namespace moab {
             error = another_halfedge(vid, curfid, curlid, &he2_fid, &he2_lid);
             if (MB_SUCCESS != error) return error;
 
-            bool found_ent = find_match_in_array(he2_fid, trackfaces, count);
+            int val;
+            error = mb->tag_get_data(visited_face, &he2_fid, 1, &val);
+            if (MB_SUCCESS != error) return error;
 
-            if (found_ent)
+            if (val)
               continue;
-            count += 1;
-            trackfaces[count] = he2_fid;
 
-            error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
+            val = 1;
+            error = mb->tag_set_data(visited_face, &he2_fid, 1, &val);
             if (MB_SUCCESS != error) return error;
 
-            adjents.push_back(he2_fid);
+            error = get_up_adjacencies_2d(he2_fid, he2_lid, &qsize);
+            if (MB_SUCCESS != error) return error;
 
+            adjents.push_back(he2_fid);
           }
-      }
+
+        //Change the visited faces to false, also empty the queue
+        for (int i = 0; i<qsize; i++)
+        {
+            int val = 0;
+            error = mb->tag_set_data(visited_face, &queue_fid[i], 1, &val);
+            if (MB_SUCCESS != error) return error;
+
+            queue_fid[i] = 0;
+            queue_lid[i] = 0;
+        }
+
+    }
     return MB_SUCCESS;
   }
 
@@ -1251,7 +1259,6 @@ namespace moab {
 {
 
   // Given an explicit edge eid, find the incident faces.
-
     ErrorCode error;
     EntityHandle he_fid=0; int he_lid=0;
 
@@ -1322,11 +1329,8 @@ namespace moab {
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle fid,
                                                  int lid,
-                                                 EntityHandle *queue_fid,
-                                                 int *queue_lid,
-                                                 int *qsize,
-                                                 EntityHandle *trackfaces,
-                                                 int *tcount)
+                                                 int *qsize
+                                                )
   {
 
     ErrorCode error; 
@@ -1345,7 +1349,6 @@ namespace moab {
         int index = 0;
         bool found_ent = find_match_in_array(fid, queue_fid, qsize[0]-1, true, &index);
         if ((!found_ent)||((found_ent) && (queue_lid[index] != lid)))
-
           {
             queue_fid[qsize[0]] = fid;
             queue_lid[qsize[0]] = lid;
@@ -1354,14 +1357,14 @@ namespace moab {
       }
 
     while ((curfid != fid)&&(curfid != 0)) {
+        int val;
+        error = mb->tag_get_data(visited_face, &curfid, 1, &val);
+        if (MB_SUCCESS != error) return error;
 
-        bool found = find_match_in_array(curfid, trackfaces, tcount[0]);
-
-        if (!found){
+        if (!val){
             queue_fid[qsize[0]] = curfid;
             queue_lid[qsize[0]] = curlid;
             qsize[0] += 1;
-
           }
 
         sib_fids.clear();
@@ -1396,22 +1399,26 @@ namespace moab {
     bool found = false;
 
     if (fid!=0){
-        EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
-        int queue_lid[MAXSIZE];
-        for (int i = 0; i< MAXSIZE; i++)
-          {
-            queue_fid[i] = 0;
-            queue_lid[i] = 0;
-            trackfaces[i] = 0;
-          }
-        int qsize = 0, tcount = -1;
+
+        int qsize = 0;
 
         EntityHandle vid = conn[0];
 
-        error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &tcount);
+        error = gather_halfedges(vid, fid, lid, &qsize);
         if (MB_SUCCESS != error) return error;
 
-        found =  collect_and_compare(conn, queue_fid, queue_lid, &qsize, trackfaces, &tcount, hefid, helid);
+        found =  collect_and_compare(conn, &qsize, hefid, helid);
+
+        //Change the visited faces to false
+        for (int i = 0; i<qsize; i++)
+        {
+            int val = 0;
+            error = mb->tag_set_data(visited_face, &queue_fid[i], 1, &val);
+            if (MB_SUCCESS != error) return error;
+
+            queue_fid[i] = 0;
+            queue_lid[i] = 0;
+        }
       }
 
     return found;
@@ -1420,11 +1427,8 @@ namespace moab {
    ErrorCode HalfFacetRep::gather_halfedges( EntityHandle vid,
                                              EntityHandle he_fid,
                                              int he_lid,
-                                             EntityHandle *queue_fid,
-                                             int *queue_lid,
-                                             int *qsize,
-                                             EntityHandle *trackfaces,
-                                             int *tcount)
+                                             int *qsize
+                                            )
   {  
     ErrorCode error;
     EntityHandle he2_fid = 0; int he2_lid = 0;
@@ -1436,12 +1440,14 @@ namespace moab {
     *qsize += 1;
     queue_fid[*qsize] = he2_fid; queue_lid[*qsize] = he2_lid;
     *qsize += 1;
-    tcount[0] += 1;
-    trackfaces[tcount[0]] = he_fid;
+
+    int val = 1;
+    error = mb->tag_set_data(visited_face, &he_fid, 1, &val);
+    if (MB_SUCCESS != error) return error;
     
-    error = get_up_adjacencies_2d(he_fid, he_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+    error = get_up_adjacencies_2d(he_fid, he_lid, qsize);
     if (MB_SUCCESS != error) return error;
-    error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+    error = get_up_adjacencies_2d(he2_fid, he2_lid, qsize);
     if (MB_SUCCESS != error) return error;
 
     return MB_SUCCESS;
@@ -1479,11 +1485,7 @@ namespace moab {
   
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   bool HalfFacetRep::collect_and_compare(std::vector<EntityHandle> &edg_vert,
-                                         EntityHandle *queue_fid,
-                                         int *queue_lid,
-                                         int *qsize,
-                                         EntityHandle *trackfaces,
-                                         int *tcount,
+                                         int *qsize,                                      
                                          EntityHandle *he_fid,
                                          int *he_lid)
   {
@@ -1503,41 +1505,45 @@ namespace moab {
         int curlid = queue_lid[num_qvals];
         num_qvals += 1;       
 
-	std::vector<EntityHandle> conn(nepf);
-	error = mb->get_connectivity(&curfid, 1, conn);
-	if (MB_SUCCESS != error) return error;
+        std::vector<EntityHandle> conn(nepf);
+        error = mb->get_connectivity(&curfid, 1, conn);
+        if (MB_SUCCESS != error) return error;
 
-    int id = next[curlid];
-	if (((conn[curlid]==edg_vert[0])&&(conn[id]==edg_vert[1]))||((conn[curlid]==edg_vert[1])&&(conn[id]==edg_vert[0]))){
-	    *he_fid = curfid;
-	    *he_lid = curlid;
-	    found = true;
-	    break;
-	}
+        int id = next[curlid];
+        if (((conn[curlid]==edg_vert[0])&&(conn[id]==edg_vert[1]))||((conn[curlid]==edg_vert[1])&&(conn[id]==edg_vert[0]))){
+            *he_fid = curfid;
+            *he_lid = curlid;
+            found = true;
+            break;
+        }
 
-	bool found_ent = find_match_in_array(curfid, trackfaces, tcount[0]);
+        int val;
+        error = mb->tag_get_data(visited_face, &curfid, 1, &val);
+        if (MB_SUCCESS != error) return error;
 
-	if (found_ent)
-	  continue;
-	tcount[0] += 1;
-	trackfaces[tcount[0]] = curfid;
+        if (val)
+            continue;
 
-	EntityHandle he2_fid; int he2_lid;
-	error = another_halfedge(edg_vert[0], curfid, curlid, &he2_fid, &he2_lid);
+        val=1;
+        error = mb->tag_set_data(visited_face, &curfid, 1, &val);
+        if (MB_SUCCESS != error) return error;
 
-	if (MB_SUCCESS != error) return error;
-	error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
-	if (MB_SUCCESS != error) return error;      
+        EntityHandle he2_fid; int he2_lid;
+        error = another_halfedge(edg_vert[0], curfid, curlid, &he2_fid, &he2_lid);
+
+        if (MB_SUCCESS != error) return error;
+        error = get_up_adjacencies_2d(he2_fid, he2_lid, qsize);
+        if (MB_SUCCESS != error) return error;
+
+        counter += 1;
+    }
 
-	counter += 1;
-      }
-      
     delete [] next;
     delete [] prev;
     return found;
   }
   
-  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////////////////////////////////////
   ErrorCode  HalfFacetRep::get_neighbor_adjacencies_2d( EntityHandle fid,
                                                         std::vector<EntityHandle> &adjents)
   {
@@ -1554,6 +1560,50 @@ namespace moab {
     return MB_SUCCESS;
   }
 
+
+  /////////////////////////////////////////////////////////////////////////////////////////////////
+  ErrorCode HalfFacetRep::get_down_adjacencies_2d(EntityHandle fid, std::vector<EntityHandle> &adjents)
+  {
+      //Returns explicit edges, if any, of the face
+      ErrorCode error;
+      int nepf = local_maps_2d(fid);
+      std::vector<EntityHandle> conn(nepf);
+      error = mb->get_connectivity(&fid, 1, conn);
+      if (error != MB_SUCCESS) return error;
+
+      //Gather all the incident edges on each vertex of the face
+      std::vector< std::vector<EntityHandle> > temp(nepf);
+      for (int i=0; i<nepf; i++)
+      {
+          error = get_up_adjacencies_1d(conn[i], temp[i]);
+          if (error != MB_SUCCESS) return error;
+          std::sort(temp[i].begin(), temp[i].end());
+      }
+
+      //Loop over all the local edges and find the intersection.
+      for (int i = 0; i < nepf; ++i)
+      {
+          std::vector<EntityHandle> common(10);
+          std::vector<EntityHandle>::iterator it;
+          if (i == nepf-1){
+              it = std::set_intersection(temp[i].begin(), temp[i].end(), temp[0].begin(), temp[0].end(), common.begin());
+              if (*common.begin() == 0)
+                  continue;
+
+              adjents.push_back(*common.begin());
+          }
+          else
+          {
+              it = std::set_intersection(temp[i].begin(), temp[i].end(), temp[i+1].begin(), temp[i+1].end(), common.begin());
+              if (*common.begin() == 0)
+                  continue;
+
+              adjents.push_back(*common.begin());
+          }
+      }
+      return MB_SUCCESS;
+  }
+
   ////////////////////////////////////////////////////////////////////////////////////////////////
   int HalfFacetRep::find_total_edges_2d(Range &faces)
   {
@@ -2087,15 +2137,15 @@ namespace moab {
 	    {
 	      idx = lConnMap3D[index].hf2v[lfid][j];
 	      if (vert0 == sib_conn[idx])
-		lv0 = idx;
-	      if (vert1 == sib_conn[idx])
-		lv1 = idx;
-	    }
+              lv0 = idx;
+          if (vert1 == sib_conn[idx])
+              lv1 = idx;
+      }
 
-	  assert((lv0 >= 0) && (lv1 >= 0));
-	  cur_leid = lConnMap3D[index].lookup_leids[lv0][lv1];
+      assert((lv0 >= 0) && (lv1 >= 0));
+      cur_leid = lConnMap3D[index].lookup_leids[lv0][lv1];
 
-	  int chk_lfid = lConnMap3D[index].e2hf[cur_leid][0];
+      int chk_lfid = lConnMap3D[index].e2hf[cur_leid][0];
 
 	  if (lfid == chk_lfid)
 	    lface = 1;
@@ -2414,6 +2464,96 @@ namespace moab {
     return MB_SUCCESS; 
   }
 
+  /////////////////////////////////////////////////////////////////////////////////////////////////
+  ErrorCode HalfFacetRep::get_down_adjacencies_edg_3d(EntityHandle cid, std::vector<EntityHandle> &adjents)
+  {
+      //Returns explicit edges, if any, of the face
+      ErrorCode error;
+      int index = get_index_from_type(cid);
+      int nvpc = lConnMap3D[index].num_verts_in_cell;
+      int nepc = lConnMap3D[index].num_edges_in_cell;
+
+      std::vector<EntityHandle> conn(nvpc);
+      error = mb->get_connectivity(&cid, 1, conn);
+      if (error != MB_SUCCESS) return error;
+
+      //Gather all the incident edges on each vertex of the face
+      std::vector< std::vector<EntityHandle> > temp(nvpc);
+      for (int i=0; i<nvpc; i++)
+      {
+          error = get_up_adjacencies_1d(conn[i], temp[i]);
+          if (error != MB_SUCCESS) return error;
+          std::sort(temp[i].begin(), temp[i].end());
+      }
+
+      //Loop over all the local edges and find the intersection.
+      for (int i = 0; i < nepc; ++i)
+      {
+          std::vector<EntityHandle> common(10);
+          std::vector<EntityHandle>::iterator it;
+
+          int lv0 = lConnMap3D[index].e2v[i][0];
+          int lv1 = lConnMap3D[index].e2v[i][1];
+
+          it = std::set_intersection(temp[lv0].begin(), temp[lv0].end(), temp[lv1].begin(), temp[lv1].end(), common.begin());
+          if (*common.begin() == 0)
+              continue;
+
+          adjents.push_back(*common.begin());
+      }
+      return MB_SUCCESS;
+  }
+
+  /////////////////////////////////////////////////////////////////////////////////////////////////
+  ErrorCode HalfFacetRep::get_down_adjacencies_face_3d(EntityHandle cid, std::vector<EntityHandle> &adjents)
+  {
+      //Returns explicit edges, if any, of the face
+      ErrorCode error;
+      int index = get_index_from_type(cid);
+      int nvpc = lConnMap3D[index].num_verts_in_cell;
+      int nfpc = lConnMap3D[index].num_faces_in_cell;
+
+      std::vector<EntityHandle> conn(nvpc);
+      error = mb->get_connectivity(&cid, 1, conn);
+      if (error != MB_SUCCESS) return error;
+
+      //Gather all the incident edges on each vertex of the face
+      std::vector< std::vector<EntityHandle> > temp(nvpc);
+      for (int i=0; i<nvpc; i++)
+      {
+          error = get_up_adjacencies_vert_2d(conn[i], temp[i]);
+          if (error != MB_SUCCESS) return error;
+          std::sort(temp[i].begin(), temp[i].end());
+      }
+
+      //Loop over all the local faces and find the intersection.
+      for (int i = 0; i < nfpc; ++i)
+      {
+          std::vector<EntityHandle> results(100);
+          std::vector<EntityHandle>::iterator it;
+
+          int nvF = lConnMap3D[index].hf2v_num[i];
+
+          int lv0 = lConnMap3D[index].hf2v[i][0];
+          int lv1 = lConnMap3D[index].hf2v[i][1];
+          std::set_intersection(temp[lv0].begin(), temp[lv0].end(), temp[lv1].begin(), temp[lv1].end(), std::back_inserter(results));
+
+          std::vector<EntityHandle> common(100);
+          for (int k = 2; k < nvF; k++){
+              common.clear();
+              int lv = lConnMap3D[index].hf2v[i][k];
+              std::set_intersection(temp[lv].begin(), temp[lv].end(), results.begin(), results.end(), std::back_inserter(common));
+          }
+
+          if (*common.begin() == 0)
+              continue;
+
+          adjents.push_back(*common.begin());
+      }
+      return MB_SUCCESS;
+  }
+
+
   ///////////////////////////////////////////////////////////////////////////////////////////
   bool HalfFacetRep::find_match_in_array(EntityHandle ent, EntityHandle *ent_list, int count, bool get_index, int *index)
   {

diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index a228520..c960330 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -41,22 +41,24 @@ namespace moab {
  *  \
  */ 
 
-  //! ENUM for the type of input mesh.
-  enum MESHTYPE{
-   CURVE = 0, //Homogeneous curve mesh
-   SURFACE, // Homogeneous surface mesh
-   SURFACE_MIXED, // Mixed surface with embedded curves
-   VOLUME, // Homogeneous volume mesh
-   VOLUME_MIXED_1, // Volume mesh with embedded curves
-   VOLUME_MIXED_2, // Volume mesh with embedded surface
-   VOLUME_MIXED //Volume mesh with embedded curves and surfaces
-  };
+const int MAXSIZE = 150;
 
-  class Core;
+//! ENUM for the type of input mesh.
+enum MESHTYPE{
+    CURVE = 0, //Homogeneous curve mesh
+    SURFACE, // Homogeneous surface mesh
+    SURFACE_MIXED, // Mixed surface with embedded curves
+    VOLUME, // Homogeneous volume mesh
+    VOLUME_MIXED_1, // Volume mesh with embedded curves
+    VOLUME_MIXED_2, // Volume mesh with embedded surface
+    VOLUME_MIXED //Volume mesh with embedded curves and surfaces
+};
 
-  class HalfFacetRep{
-       
-  public:
+class Core;
+
+class HalfFacetRep{
+
+public:
     
     HalfFacetRep(Core *impl);
     
@@ -78,6 +80,7 @@ namespace moab {
     ErrorCode print_tags();
     
 
+
     ErrorCode get_adjacencies(const EntityHandle source_entity,
                               const unsigned int target_dimension,
                               std::vector<EntityHandle> &target_entities);
@@ -110,6 +113,9 @@ namespace moab {
     ErrorCode get_neighbor_adjacencies(EntityHandle ent,
                                        std::vector<EntityHandle> &adjents);
 
+    ErrorCode get_down_adjacencies(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents);
+
+
     // 1D Maps and queries
 
     //! Given a range of edges, determines the map for sibling half-verts and stores them into SIBHVS_EID, SIBHVS_LVID tags.
@@ -224,6 +230,9 @@ namespace moab {
     ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid,
                                           std::vector<EntityHandle> &adjents);
 
+    ErrorCode get_down_adjacencies_2d(EntityHandle fid,
+                                      std::vector<EntityHandle> &adjents);
+
     //! Given a range of faces, finds the total number of edges.
     
     int find_total_edges_2d(Range &faces);
@@ -334,6 +343,11 @@ namespace moab {
 
     ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid,
                                           std::vector<EntityHandle> &adjents);
+
+
+    ErrorCode get_down_adjacencies_edg_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
+
+    ErrorCode get_down_adjacencies_face_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
     
 
   protected:
@@ -356,6 +370,13 @@ namespace moab {
     Tag sibhvs_eid, sibhvs_lvid, v2hv_eid, v2hv_lvid;
     Tag sibhes_fid, sibhes_leid, v2he_fid, v2he_leid;
     Tag sibhfs_cid, sibhfs_lfid, v2hf_cid, v2hf_lfid;
+    Tag visited_face, visited_cell;
+
+    EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
+    int queue_lid[MAXSIZE];
+
+
+
 
     MESHTYPE thismeshtype;
     MESHTYPE get_mesh_type(int nverts, int nedges, int nfaces, int ncells);
@@ -426,11 +447,7 @@ namespace moab {
 
     ErrorCode get_up_adjacencies_2d(EntityHandle he_fid,
                                     int he_lid,
-                                    EntityHandle *queue_fid,
-                                    int *queue_lid,
-                                    int *qsize,
-                                    EntityHandle *trackfaces,
-                                    int *tcount);
+                                    int *qsize);
 
     //! Given an edge, finds a matching half-edge in the surface.
     /** Given an edge eid, it first collects few half-edges belonging to one-ring neighborhood of
@@ -455,14 +472,10 @@ namespace moab {
      * \param trackfaces, tcount
     */
 
-    ErrorCode gather_halfedges( EntityHandle vid,
+    ErrorCode gather_halfedges(EntityHandle vid,
                                 EntityHandle he_fid,
                                 int he_lid,
-                                EntityHandle *queue_fid,
-                                int *queue_lid,
-                                int *qsize,
-                                EntityHandle *trackfaces,
-                                int *tcount);
+                                int *qsize);
 
     //! Obtains another half-edge belonging to the same face as the input half-edge
     /** It uses the local maps to find another half-edge that is either incident or outgoing depending
@@ -490,11 +503,7 @@ namespace moab {
     */
 
     bool collect_and_compare(std::vector<EntityHandle> &edg_vert,
-                             EntityHandle *queue_fid,
-                             int *queue_lid,
                              int *qsize,
-                             EntityHandle *trackfaces,
-                             int *tcount,
                              EntityHandle *he_fid,
                              int *he_lid);
 

diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index 556554c..1e1da98 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 adj_without_ahf
+check_PROGRAMS = perf seqperf adj_time perftool adj_mem_time ahf_mem_time
 noinst_PROGRAMS = 
 
 perf_SOURCES = perf.cpp
@@ -15,7 +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
+adj_mem_time_SOURCES = adj_mem_time.cpp
 
 if ENABLE_imesh
   LDADD += $(top_builddir)/itaps/imesh/libiMesh.la
@@ -25,9 +25,3 @@ 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_mem_time.cpp b/test/perf/adj_mem_time.cpp
new file mode 100755
index 0000000..56b8fb7
--- /dev/null
+++ b/test/perf/adj_mem_time.cpp
@@ -0,0 +1,337 @@
+/*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;
+  Range ngbents;
+
+  // This call should create all the necessary ahf maps or adjacency lists
+  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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time =  "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time =  "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //NQ1:  For every edge, obtain neighbor edges  
+#ifdef USE_AHF
+  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;
+  std::cout<<std::endl;
+#else
+  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;
+#endif
+
+  // 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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //NQ2: For every face, obtain neighbor faces 
+#ifdef USE_AHF
+  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;
+  std::cout<<std::endl;
+#else
+  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;
+#endif
+
+  //DQ2: For every face, obtain its edges
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Face -> Edges :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Face -> Edges :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+
+  // 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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  // 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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#endif
+
+
+  //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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Face -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //NQ3: For every cell, obtain neighbor cells
+#ifdef USE_AHF
+  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;
+  std::cout<<std::endl;
+#else
+  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;
+#endif
+
+  //DQ31: For every cell, obtain its edges
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Cell -> Edges :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Cell -> Edges :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //DQ32: For every cell, obtain its faces
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Cell -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Cell -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+
+  //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<<std::endl;
+  std::cout<<"Entity storage = "<<eES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+  std::cout<<std::endl;
+#ifdef USE_AHF
+  std::cout<<"AHF adjacency tag storage  = "<<eTS-sTS<<std::endl;
+  std::cout<<"Amortized AHF adjacency tag storage = "<<eATS-sATS<<std::endl;
+  std::cout<<std::endl;
+  std::cout<<"Tag storage = "<<sTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+#else
+  std::cout<<"Adjacency lists storage = "<<eAS<<std::endl;
+  std::cout<<"Amortized adjacency lists storage = "<<eAAS<<std::endl;
+  std::cout<<std::endl;
+  std::cout<<"Tag storage = "<<eTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+#endif
+  std::cout<<std::endl;
+
+  return 0;
+}
+

diff --git a/test/perf/adj_with_ahf_mem_time.cpp b/test/perf/adj_with_ahf_mem_time.cpp
deleted file mode 100755
index dbf4558..0000000
--- a/test/perf/adj_with_ahf_mem_time.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/*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
deleted file mode 100755
index cd4d58c..0000000
--- a/test/perf/adj_without_ahf_mem_time.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/*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
deleted file mode 100755
index 6d8ef14..0000000
--- a/test/perf/ahf_intfc_mem_time.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/*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;
-}
-

This diff is so big that we needed to truncate the remainder.

https://bitbucket.org/fathomteam/moab/commits/77765758fc68/
Changeset:   77765758fc68
Branch:      nray/feature_ahf
User:        nray
Date:        2014-07-13 04:18:47
Summary:     Removed redundant test codes. Added assertion checks to interface
functions.

Affected #:  10 files

diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 4e363e3..209cc9e 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -561,6 +561,7 @@ namespace moab {
       ErrorCode error;
 
       unsigned int source_dimension = mb->dimension_from_handle(source_entity);
+      assert((source_dimension <= target_dimension) || (source_dimension > target_dimension));
 
       if (mInitAHFmaps == false)
       {
@@ -584,7 +585,7 @@ namespace moab {
               if (MB_SUCCESS != error) return error;
           }
           else
-          {
+          {           
               error = get_down_adjacencies(source_entity, target_dimension, target_entities);
               if (MB_SUCCESS != error) return error;
           }
@@ -604,6 +605,7 @@ namespace moab {
    {
     ErrorCode error;
     int in_dim = mb->dimension_from_handle(ent);
+    assert((in_dim >=0 && in_dim <= 2) && (out_dim > in_dim));
 
     if (in_dim == 0)
       {
@@ -647,6 +649,7 @@ namespace moab {
    {
      ErrorCode error;
      int in_dim = mb->dimension_from_handle(ent);
+     assert(in_dim >=1 && in_dim <= 3);
 
      if (in_dim == 1)
        {
@@ -671,6 +674,8 @@ namespace moab {
    {
        ErrorCode error;
        int in_dim = mb->dimension_from_handle(ent);
+       assert((in_dim >=2 && in_dim <= 3) && (out_dim < in_dim));
+
        if ((in_dim == 2)&&(out_dim == 1))
        {
            error = get_down_adjacencies_2d(ent, adjents);

diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index c960330..8a8d80a 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -31,13 +31,18 @@ namespace moab {
  *  \        2. V2HF: Maps each vertex to an incident half-facet
  *  \        Using these two maps, a range of adjacency queries is performed. The maps are stored in dense tags over entities and vertices.
  *  \
- *  \        Current support for adjacency functions:
+ *  \        Adjacency functions:
  *  \        1. upward-incidence queries: vertex -> edge, edge -> faces, edge -> cells, face ->cells
  *  \        2. neighborhood (same-dimensional) adjacency queries: edge -> edges, face -> faces, cell -> cells, etc.
- *  \ 
+ *  \        3. downward adjacency queries: face -> edges, cell -> edges, etc.
+ *  \
  *  \        Mesh types supported: 
  *  \        1D(edges), 2D(triangles, quads), 3D(tet, pyramid, prism, hex), Mixed dimensional meshes
- *  \        NOT SUPPORTED: Meshes with mixed entity types of same dimension. Ex. a volume mesh with both tets and prisms.
+ *  \
+ *  \        CURRENTLY NOT SUPPORTED:
+ *  \        1. Meshes with mixed entity types of same dimension. Ex. a volume mesh with both tets and prisms.
+ *  \        2. create_if_missing = true
+ *  \        3. Modified meshes
  *  \
  */ 
 
@@ -79,7 +84,13 @@ public:
     //! Prints the tag values.
     ErrorCode print_tags();
     
-
+    //! Get the adjacencies associated with an entity.
+    /** Given an entity of dimension <em>d</em>, gather all the adjacent <em>D</em> dimensional entities where <em>D >, = , < d </em>.
+     *
+     * \param source_entity EntityHandle to which adjacent entities have to be found.
+     * \param target_dimension Int Dimension of the desired adjacent entities.
+     * \param target_entities Vector in which the adjacent EntityHandle are returned.
+     */
 
     ErrorCode get_adjacencies(const EntityHandle source_entity,
                               const unsigned int target_dimension,
@@ -88,7 +99,7 @@ public:
 
     //! Get the upward incidences associated with an entity.
     /** Given an entity of dimension <em>d</em>, gather all the incident <em>D(>d)</em> dimensional entities.
-     * Parameters:
+     * :
      * \param ent EntityHandle to which incident entities have to be found.
      * \param out_dim Dimension of the desired incidence information.
      * \param adjents Vector in which the incident entities are returned.
@@ -105,7 +116,7 @@ public:
     //! Get the same-dimensional entities connected with an entity.
     /** Given an entity of dimension <em>d</em>, gather all the entities connected via <em>d-1</em> dimensional entities.
      *  Same as bridge_adjacencies in MOAB.
-     * Parameters:
+     *
      * \param ent EntityHandle to which neighbor entities have to be found.
      * \param adjents Vector in which the neighbor entities are returned.
      */
@@ -113,6 +124,14 @@ public:
     ErrorCode get_neighbor_adjacencies(EntityHandle ent,
                                        std::vector<EntityHandle> &adjents);
 
+    //! Get the downward adjacent entities connected with an entity.
+    /** Given an entity of dimension <em>d</em>, gather all the <em>d-1</em> dimensional entities.
+     *
+     * \param ent EntityHandle to which neighbor entities have to be found.
+     * \param out_dim Dimension of the desired downward adjacency.
+     * \param adjents Vector in which the neighbor entities are returned.
+     */
+
     ErrorCode get_down_adjacencies(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents);
 
 
@@ -122,7 +141,7 @@ public:
     /** Compute all sibling half-vertices for all half-vertices in the given curve. The sibling half-verts is
      *  defined in terms of the containing edge and the local id of the vertex w.r.t that edge.
      *  That is, the map consists of two pieces of information: <EntityHandle eid, int lvid>
-     *  Parameters:
+     *
      * \param edges Range of edges.
     */
     
@@ -131,7 +150,7 @@ public:
     //! Given a range of edges, determines the map for incident half-verts and stores them into V2HV_EID, V2HV_LVID tags.
     /** Compute a map between a vertex and an incident half-vertex. This map is not always required, but is
      * essential for local neighborhood searching as it acts like an anchor to start the search.
-     * Parameters:
+     *
      * \param edges Range of edges
     */
 
@@ -140,7 +159,7 @@ public:
     //! Given a vertex, finds the edges incident on it.
     /** Given a vertex handle, it starts by first finding an incident half-vert by using the incident
      * half-vert map, and then obtaining all the sibling half-verts of the corresponding half-vertex.
-     * Parameters:
+     *
      * \param vid EntityHandle of the query vertex
      * \param adjents Vector returning the incident edges
      * \param local_id False by default. If true, returns the local vertex id's corresponding to vid
@@ -154,7 +173,7 @@ public:
 
     //! Given an edge, finds vertex-connected neighbor edges
     /** Given an edge, it gathers all the incident edges of each vertex of the edge.
-     * Parameters:
+     *
      * \param eid EntityHandle of the query edge
      * \param adjents Vector returning neighbor edges
     */
@@ -169,7 +188,7 @@ public:
     /** Compute all sibling half-edges for all half-edges in the given surface.
      * The sibling half-edges is defined in terms of the containing face and the local id of the edge w.r.t that entity.
      * That is, the map consists of two pieces of information: <EntityHandle fid, int leid>
-     * Parameters:
+     *
      * \param faces Range of faces
     */
     
@@ -179,18 +198,26 @@ public:
     /** Compute a map between a vertex and an incident half-edge.
      * This map is not always required, but is essential for local neighborhood searching as it acts
      * like an anchor to start the search.
-     * 	Parameters:
+     *
      * \param faces Range of faces
     */
 
     ErrorCode determine_incident_halfedges(Range &faces);
 
+    //! Given a vertex, finds the faces incident on it.
+    /** Given a vertex, it first finds an incident half-edge via v2he map, and then
+     * collects all the incident half-edges/faces via the sibhes map.
+     *
+     * \param vid EntityHandle of the query vertex
+     * \param adjents Vector returning the incident faces
+    */
+
     ErrorCode get_up_adjacencies_vert_2d(EntityHandle vid, std::vector<EntityHandle> &adjents);
 
     //! Given an edge, finds the faces incident on it.
     /** Given an edge, it first finds a matching half-edge corresponding to eid, and then
      * collects all the incident half-edges/faces via the sibhes map.
-     * Parameters:
+     *
      * \param eid EntityHandle of the query edge
      * \param adjents Vector returning the incident faces
      * \param local_id By default false. If true, returns the local edge id's corresponding to the input edge
@@ -204,7 +231,7 @@ public:
 
     //! Given a half-edge <fid, leid>, finds the faces incident on it.
     /**
-     * Parameters:
+     *
      * \param fid EntityHandle of the containing face
      * \param leid local id of the edge w.r.t to the face
      * \param add_inent If true, adds the input fid into the returning vector of adjents.
@@ -222,7 +249,7 @@ public:
 
     //! Given an edge, finds edge-connected neighbor face
     /** Given an face, it gathers all the neighbor faces of each local edge of the face.
-     * Parameters:
+     *
      * \param fid EntityHandle of the query face
      * \param adjents Vector returning neighbor faces
     */
@@ -230,6 +257,14 @@ public:
     ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid,
                                           std::vector<EntityHandle> &adjents);
 
+    //! Given a face, finds its edges.
+    /** Given a face, it first finds incident edges on each vertex of the face, and then
+     *  it performs a set intersection to gather all the edges of the given face.
+     *
+     * \param fid EntityHandle of the query face
+     * \param adjents Vector returning its edges
+    */
+
     ErrorCode get_down_adjacencies_2d(EntityHandle fid,
                                       std::vector<EntityHandle> &adjents);
 
@@ -243,7 +278,7 @@ public:
     /** Compute all sibling half-faces for all half-faces in the given volume.
      * The sibling half-faces is defined in terms of the containing cell and the local id of the face w.r.t that cell.
      * That is, the map consists of two pieces of information: <EntityHandle cid, int lfid>
-     * Parameters:
+     *
      * \param faces Range of cells
     */
 
@@ -253,7 +288,7 @@ public:
     /** Compute a map between a vertex and an incident half-face.
      * This map is not always required, but is essential for local neighborhood searching as it acts
      * like an anchor to start the search.
-     * 	Parameters:
+     *
      * \param faces Range of cells
     */
     
@@ -262,7 +297,7 @@ public:
     //! Given a range of cells, tags all border vertices with a true value.
     /** Tag border vertices by using the sibhf_cid map. All vertices on half-faces with no sibling
      * half-faces are considered as border vertices.
-     * Parameters:
+     *
      * \param cells Range of cells
      * \param isborder: A dense tag over all vertices of size 1. Value is true for a border vertex, otherwise is false.
     */
@@ -270,13 +305,20 @@ public:
     ErrorCode determine_border_vertices( Range &cells,
                                          Tag isborder);
 
+    //! Given a vertex, finds the cells incident on it.
+    /** Given a vertex, it first finds an incident half-face via v2hf map, and then
+     * collects all the incident half-faces via the sibhfs map.
+     *
+     * \param vid EntityHandle of the query vertex
+     * \param adjents Vector returning the incident cells
+    */
 
     ErrorCode get_up_adjacencies_vert_3d(EntityHandle vid, std::vector<EntityHandle> &adjents);
 
     //! Given an edge, finds the cells incident on it.
     /** Given an edge, it first finds a matching local edge in a cell corresponding to eid, and then
      * collects all the incident cells via the sibhfs map.
-     * Parameters:
+     *
      * \param eid EntityHandle of the query edge
      * \param adjents Vector returning the incident cells
      * \param local_id By default false. If true, returns the local edge id's corresponding to the input edge
@@ -290,7 +332,7 @@ public:
 
     //! Given a local edge <cid, leid>, finds the cells incident on it.
     /** Given a local edge, it gathers all the incident cells via the sibhfs map.
-     * Parameters:
+     *
      * \param cid EntityHandle of the cell containing the local edge
      * \param leid local edge id w.r.t the cell
      * \param adjents Vector returning the incident cells
@@ -306,7 +348,7 @@ public:
     //! Given an face, finds the cells incident on it.
     /** Given an face, it first finds a matching half-face in a cell corresponding to face, and then
      * collects all the incident cells via the sibhfs map.
-     * Parameters:
+     *
      * \param fid EntityHandle of the query face
      * \param adjents Vector returning the incident cells
      * \param local_id By default false. If true, returns the local face id's corresponding to the input face
@@ -320,7 +362,7 @@ public:
 
     //! Given a local face <cid, lfid>, finds the cells incident on it.
     /** Given a local face, it gathers all the incident cells via the sibhfs map.
-     * Parameters:
+     *
      * \param cid EntityHandle of the cell containing the local edge
      * \param lfid local face id w.r.t the cell
      * \param adjents Vector returning the incident cells
@@ -336,7 +378,7 @@ public:
     
     //! Given a cell, finds face-connected neighbor cells
     /** Given a cell, it gathers all the neighbor cells of each local face of the cell.
-     * Parameters:
+     *
      * \param cid EntityHandle of the query cell
      * \param adjents Vector returning neighbor cells
     */
@@ -344,9 +386,24 @@ public:
     ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid,
                                           std::vector<EntityHandle> &adjents);
 
+    //! Given a cell, finds its edges.
+    /** Given a cell, it first finds incident edges on each vertex of the cell, and then
+     *  it performs a set intersection to gather all the edges of the given cell.
+     *
+     * \param cid EntityHandle of the query cell
+     * \param adjents Vector returning its edges
+    */
 
     ErrorCode get_down_adjacencies_edg_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
 
+    //! Given a cell, finds its faces.
+    /** Given a cell, it first finds incident faces on each vertex of the cell, and then
+     *  performs a set intersection to gather all the faces of the given cell.
+     *
+     * \param cid EntityHandle of the query cell
+     * \param adjents Vector returning its faces
+    */
+
     ErrorCode get_down_adjacencies_face_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
     
 
@@ -375,9 +432,6 @@ public:
     EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
     int queue_lid[MAXSIZE];
 
-
-
-
     MESHTYPE thismeshtype;
     MESHTYPE get_mesh_type(int nverts, int nedges, int nfaces, int ncells);
 
@@ -403,7 +457,7 @@ public:
 
     //! Contains the local information for 2D entities
     /** Given a face, find the face type specific information
-     * Parameters:
+     *
      * \param face EntityHandle. Used to gather info about the type of face for which local info is required
      * \param nepf: Returns the number of vertices/edges for given face type.
     */
@@ -412,7 +466,7 @@ public:
 
     //! Contains the local information for 2D entities
     /** Given number of edges, returns local indices of next and previous local edges.
-     * Parameters:
+     *
      * \param nepf: The number of vertices/edges for given face type.
      * \param next, prev: Local ids of next and previous edges w.r.t to the face
      *
@@ -434,15 +488,9 @@ public:
     /** Given an half-edge, obtain all the incident half-edges via the sibhes map and add them to a given
      * queue of half-edges, if they do not already exist in the queue. This function is used to increment the
      * search space for finding a matching half-edge.
-     * Parameters:
+     *
      * \param he_fid EntityHandle of query half-edge
      * \param he_lid Local id of query half-edge
-     * \param queue_fid
-     * \param queue_lid
-     * \param qsize Array of faces and local edge ids. qsize is the current size of the queue_fid.
-     * \param trackfaces Array containing faces. If fid of an incident half-edge doesn't belong to trackfaces,
-     *  the half-edge is added to the queue.
-     * \param tcount Current size of trackfaces
      */
 
     ErrorCode get_up_adjacencies_2d(EntityHandle he_fid,
@@ -453,7 +501,7 @@ public:
     /** Given an edge eid, it first collects few half-edges belonging to one-ring neighborhood of
      * the starting vertex of the given edge, and then simultaneously searches and adds to the local list
      * of half-edges for searching, till it finds a matching half-edge.
-     * Parameters:
+     *
      * \param eid EntityHandle of the query edge
      * \param hefid, helid: Returns the matching half-edge corresponding to the query edge.
     */
@@ -464,12 +512,6 @@ public:
 
     //! Gather half-edges to a queue of half-edges.
     /** Given a vertex vid, and a half-edge <he_fid,he_lid>, add another half-edge in the same face sharing the vertex
-     * and add all incident half-edges to the queue via sibhes map.
-     * Parameters:
-     * \param vid EntityHandle of a vertex in a half-edge
-     * \param <EntityHandle he_fid, int he_lid>:  Half-edge
-     * \param queue_fid, queue_lid, count
-     * \param trackfaces, tcount
     */
 
     ErrorCode gather_halfedges(EntityHandle vid,
@@ -480,11 +522,7 @@ public:
     //! Obtains another half-edge belonging to the same face as the input half-edge
     /** It uses the local maps to find another half-edge that is either incident or outgoing depending
      * on vid and input half-edge
-     * Parameters:
-     * \param vid EntityHandle of a vertex in a half-edge
-     * \param <EntityHandle he_fid, int he_lid>:  Half-edge
-     * \param <EntityHandle he2_fid, int he2_lid>: Returns another half-edge in the same he_fid sharing vid.
-    */
+     */
 
     ErrorCode another_halfedge( EntityHandle vid,
                                 EntityHandle he_fid,
@@ -495,11 +533,6 @@ public:
     //! Collect and compare to find a matching half-edge with the given edge connectivity.
     /** Given edge connectivity, compare to an input list of half-edges to find a matching half-edge
      * and add a list of half-edges belonging to the one-ring neighborhood to a queue till it finds a match.
-     * Parameters:
-     * \param edg_vert End vertices of an edge
-     * \param queue_fid, queue_lid, count
-     * \param trackfaces, tcount
-     * \param <EntityHandle he_fid, int he_lid>: Returns matching half-edge
     */
 
     bool collect_and_compare(std::vector<EntityHandle> &edg_vert,
@@ -564,7 +597,7 @@ public:
 
     //! Given an edge, finds a matching local edge in an incident cell.
     /** Find a local edge with the same connectivity as the input edge, belonging to an incident cell.
-     * Parameters:
+     *
      * \param eid EntityHandle of the edge
      * \param cid Returns EntityHandle of the incident cell
      * \param leid Returns the local id of the edge corresponding to the input edge w.r.t the incident cell.
@@ -576,7 +609,7 @@ public:
 
     //! Given a face, finds a matching local face in an incident cell.
     /** Find a local face with the same connectivity as the input face, belonging to an incident cell.
-     * Parameters:
+     *
      * \param fid EntityHandle of the face
      * \param cid Returns EntityHandle of the incident cell
      * \param lfid Returns the local id of the face corresponding to the input face w.r.t the incident cell.

diff --git a/test/Makefile.am b/test/Makefile.am
index 33ca518..d615905 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -49,7 +49,7 @@ TESTS = range_test \
 	elem_eval_test \
 	spatial_locator_test \
 	test_boundbox \ 
-	ahf_test 
+	adj_moab_test 
 
 
 if HDF5_FILE
@@ -61,9 +61,6 @@ if HDF5_FILE
         lloyd_smoother_test
 endif
 
-if ENABLE_ahf
-  TESTS += ahf_mbintf_test
-endif
 
 #                 merge_test \         # input files no longer exist?
 #                 test_tag_server \    # fails
@@ -156,11 +153,7 @@ coords_connect_iterate_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS)
 test_boundbox_SOURCES = test_boundbox.cpp
 lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
 
-ahf_test_SOURCES = test_ahf_moab.cpp
-
-if ENABLE_ahf
- ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
-endif
+adj_moab_test_SOURCES = adj_moab_test.cpp
 
 
 if PARALLEL

diff --git a/test/adj_moab_test.cpp b/test/adj_moab_test.cpp
new file mode 100755
index 0000000..1a6fe5c
--- /dev/null
+++ b/test/adj_moab_test.cpp
@@ -0,0 +1,304 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include "TestUtil.hpp"
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+int number_tests_successful = 0;
+int number_tests_failed = 0;
+
+void handle_error_code(ErrorCode rv, int &number_failed, int &number_successful)
+{
+  if (rv == MB_SUCCESS) {
+    std::cout << "Success";
+    number_successful++;
+  } else {
+    std::cout << "Failure";
+    number_failed++;
+  }
+}
+
+
+ErrorCode ahf_test(Core *moab)
+{
+
+    Interface* mbImpl = &*moab;
+    MeshTopoUtil mtu(mbImpl);
+
+    ErrorCode error = mbImpl->load_file(filename.c_str());
+    CHECK_ERR(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);
+
+    // Create an ahf instance
+    HalfFacetRep ahf(&*moab);
+
+    // Call the initialize function which creates the maps for each dimension
+    ahf.initialize();
+
+    //ahf.print_tags();
+
+    //Perform queries
+    std::vector<EntityHandle> adjents;
+    Range mbents, ahfents;
+
+    //1D Queries //
+    //IQ1: For every vertex, obtain incident edges
+    for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 1, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
+    }
+
+    //NQ1:  For every edge, obtain neighbor edges
+    for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_neighbor_adjacencies( *i, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 0, 1, 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());
+    }
+
+    // 2D Queries
+
+    // IQ21: For every vertex, obtain incident faces
+    for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 2, 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 = ahf.get_up_adjacencies( *i, 2, 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());
+    }
+
+    //NQ2: For every face, obtain neighbor faces
+    for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_neighbor_adjacencies( *i, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 1, 2, 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());
+    }
+
+    //DQ 21: For every face, obtain its edges
+    for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_down_adjacencies( *i, 1, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
+    }
+
+    // 3D Queries
+    //IQ 31: For every vertex, obtain incident cells
+    for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 3, 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 = ahf.get_up_adjacencies( *i, 3, 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());
+    }
+
+    //IQ33: For every face, obtain incident cells
+    for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_up_adjacencies( *i, 3, 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());
+    }
+
+    //NQ3: For every cell, obtain neighbor cells
+    for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_neighbor_adjacencies( *i, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mtu.get_bridge_adjacencies( *i, 2, 3, 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());
+    }
+
+
+    //DQ 31: For every cell, obtain its edges
+    for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_down_adjacencies( *i, 1, adjents);
+        CHECK_ERR(error);
+        mbents.clear();
+        error = mbImpl->get_adjacencies( &*i, 1, 1, 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());
+    }
+
+    //DQ 32: For every cell, obtain its faces
+    for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+        adjents.clear();
+        error = ahf.get_down_adjacencies( *i, 2, 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());
+    }
+
+
+
+    ahf.deinitialize();
+
+    return MB_SUCCESS;
+
+}
+
+int main(int argc, char *argv[])
+{
+    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;
+    }
+
+    Core moab;
+    ErrorCode result;
+
+    std::cout<<" ahf_test: ";
+    result = ahf_test(&moab);
+    handle_error_code(result, number_tests_failed, number_tests_successful);
+    std::cout<<"\n";
+
+    return number_tests_failed;
+}
+

diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index 1e1da98..b8c5d19 100644
--- a/test/perf/Makefile.am
+++ b/test/perf/Makefile.am
@@ -7,15 +7,14 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
             
 LDADD = $(top_builddir)/src/libMOAB.la
 
-check_PROGRAMS = perf seqperf adj_time perftool adj_mem_time ahf_mem_time
+check_PROGRAMS = perf seqperf adj_time perftool adj_mem_time 
 noinst_PROGRAMS = 
 
 perf_SOURCES = perf.cpp
 seqperf_SOURCES = seqperf.cpp
 adj_time_SOURCES = adj_time.cpp
 perftool_SOURCES = perftool.cpp
-ahf_mem_time_SOURCES = test_ahf_mem_time.cpp
-adj_mem_time_SOURCES = adj_mem_time.cpp
+adj_mem_time_SOURCES = adj_mem_time_test.cpp
 
 if ENABLE_imesh
   LDADD += $(top_builddir)/itaps/imesh/libiMesh.la

diff --git a/test/perf/adj_mem_time.cpp b/test/perf/adj_mem_time.cpp
deleted file mode 100755
index 56b8fb7..0000000
--- a/test/perf/adj_mem_time.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*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;
-  Range ngbents;
-
-  // This call should create all the necessary ahf maps or adjacency lists
-  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();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time =  "<< time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time =  "<< time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#endif
-
-  //NQ1:  For every edge, obtain neighbor edges  
-#ifdef USE_AHF
-  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;
-  std::cout<<std::endl;
-#else
-  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;
-#endif
-
-  // 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();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#endif
-
-  //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();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#endif
-
-  //NQ2: For every face, obtain neighbor faces 
-#ifdef USE_AHF
-  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;
-  std::cout<<std::endl;
-#else
-  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;
-#endif
-
-  //DQ2: For every face, obtain its edges
-  time_start = wtime();
-  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
-    adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)faces.size();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Face -> Edges :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Face -> Edges :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#endif
-
-
-  // 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();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
-  std::cout<<std::endl;
-#endif
-
-  // 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();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
-  std::cout<<std::endl;
-#endif
-
-
-  //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();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Face -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
-  std::cout<<std::endl;
-#endif
-
-  //NQ3: For every cell, obtain neighbor cells
-#ifdef USE_AHF
-  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;
-  std::cout<<std::endl;
-#else
-  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;
-#endif
-
-  //DQ31: For every cell, obtain its edges
-  time_start = wtime();
-  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
-    adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)cells.size();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Cell -> Edges :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Cell -> Edges :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#endif
-
-  //DQ32: For every cell, obtain its faces
-  time_start = wtime();
-  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
-    adjents.clear();
-    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)cells.size();
-#ifdef USE_AHF
-  std::cout<<"QUERY: Cell -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#else
-  std::cout<<"QUERY: Cell -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
-  std::cout<<std::endl;
-#endif
-
-
-  //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<<std::endl;
-  std::cout<<"Entity storage = "<<eES<<std::endl;
-  std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
-  std::cout<<std::endl;
-#ifdef USE_AHF
-  std::cout<<"AHF adjacency tag storage  = "<<eTS-sTS<<std::endl;
-  std::cout<<"Amortized AHF adjacency tag storage = "<<eATS-sATS<<std::endl;
-  std::cout<<std::endl;
-  std::cout<<"Tag storage = "<<sTS<<std::endl;
-  std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
-#else
-  std::cout<<"Adjacency lists storage = "<<eAS<<std::endl;
-  std::cout<<"Amortized adjacency lists storage = "<<eAAS<<std::endl;
-  std::cout<<std::endl;
-  std::cout<<"Tag storage = "<<eTS<<std::endl;
-  std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
-#endif
-  std::cout<<std::endl;
-
-  return 0;
-}
-

diff --git a/test/perf/adj_mem_time_test.cpp b/test/perf/adj_mem_time_test.cpp
new file mode 100755
index 0000000..56b8fb7
--- /dev/null
+++ b/test/perf/adj_mem_time_test.cpp
@@ -0,0 +1,337 @@
+/*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;
+  Range ngbents;
+
+  // This call should create all the necessary ahf maps or adjacency lists
+  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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time =  "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time =  "<< time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //NQ1:  For every edge, obtain neighbor edges  
+#ifdef USE_AHF
+  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;
+  std::cout<<std::endl;
+#else
+  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;
+#endif
+
+  // 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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //NQ2: For every face, obtain neighbor faces 
+#ifdef USE_AHF
+  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;
+  std::cout<<std::endl;
+#else
+  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;
+#endif
+
+  //DQ2: For every face, obtain its edges
+  time_start = wtime();
+  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)faces.size();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Face -> Edges :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Face -> Edges :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+
+  // 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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  // 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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#endif
+
+
+  //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();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Face -> Cells :: MOAB: Average time =  "<<time_avg <<" secs"<<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //NQ3: For every cell, obtain neighbor cells
+#ifdef USE_AHF
+  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;
+  std::cout<<std::endl;
+#else
+  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;
+#endif
+
+  //DQ31: For every cell, obtain its edges
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Cell -> Edges :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Cell -> Edges :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+  //DQ32: For every cell, obtain its faces
+  time_start = wtime();
+  for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+    adjents.clear();
+    error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+  }
+  time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+  std::cout<<"QUERY: Cell -> Faces :: MOAB_AHF: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#else
+  std::cout<<"QUERY: Cell -> Faces :: MOAB: Average time =  "<<time_avg<<" secs" <<std::endl;
+  std::cout<<std::endl;
+#endif
+
+
+  //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<<std::endl;
+  std::cout<<"Entity storage = "<<eES<<std::endl;
+  std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+  std::cout<<std::endl;
+#ifdef USE_AHF
+  std::cout<<"AHF adjacency tag storage  = "<<eTS-sTS<<std::endl;
+  std::cout<<"Amortized AHF adjacency tag storage = "<<eATS-sATS<<std::endl;
+  std::cout<<std::endl;
+  std::cout<<"Tag storage = "<<sTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+#else
+  std::cout<<"Adjacency lists storage = "<<eAS<<std::endl;
+  std::cout<<"Amortized adjacency lists storage = "<<eAAS<<std::endl;
+  std::cout<<std::endl;
+  std::cout<<"Tag storage = "<<eTS<<std::endl;
+  std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+#endif
+  std::cout<<std::endl;
+
+  return 0;
+}
+

diff --git a/test/perf/test_ahf_mem_time.cpp b/test/perf/test_ahf_mem_time.cpp
deleted file mode 100755
index 0882f4f..0000000
--- a/test/perf/test_ahf_mem_time.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*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;
-
-  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_elapsed, time_avg;
-
-  // Create an ahf instance
-  HalfFacetRep ahf(&moab);
-
-  // Call the initialize function which creates the maps for each dimension
-  time_start = wtime();
-
-  ahf.initialize();
-
-  time_elapsed = wtime() - time_start;
-  std::cout << "Time taken to construct the MDS = "<<time_elapsed<<" secs"<<std::endl;
-
-  //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;
-
-  //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 = ahf.get_up_adjacencies( *i, 1, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)verts.size();
-  std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: 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 = ahf.get_neighbor_adjacencies( *i, adjents);
-  }
-  std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: 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 = ahf.get_up_adjacencies( *i, 2, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)edges.size();
-  std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: 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 = ahf.get_up_adjacencies( *i, 2, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)edges.size();
-  std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: 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 = ahf.get_neighbor_adjacencies( *i, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)faces.size();
-  std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: 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 = ahf.get_up_adjacencies(*i, 3, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)edges.size();
-  std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: 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 = ahf.get_up_adjacencies( *i, 3, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)edges.size();
-  std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time =  "<<time_avg <<" secs"<<std::endl;
-  std::cout<<std::endl;
-
-
-  //IQ33: For every face, obtain incident cells
-  time_start = wtime();
-  for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
-    adjents.clear();
-    error = ahf.get_up_adjacencies( *i, 3, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)faces.size();
-  std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: 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 = ahf.get_neighbor_adjacencies( *i, adjents);
-  }
-  time_avg = (wtime()-time_start)/(double)cells.size();
-  std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time =  "<< time_avg <<" secs" << std::endl;
-  std::cout<<std::endl;
-
-  ahf.deinitialize();
-
-  //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;
-}
-

This diff is so big that we needed to truncate the remainder.

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