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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Jun 26 14:03:59 CDT 2014


2 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/2e66bac265f8/
Changeset:   2e66bac265f8
Branch:      None
User:        nray
Date:        2014-06-26 20:50:20
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/0859b4762a4b/
Changeset:   0859b4762a4b
Branch:      nray/feature_ahf
User:        nray
Date:        2014-06-26 20:50:20
Summary:     Added interface to AHF functionalities through the get_adjacencies
functions.

Affected #:  10 files

diff --git a/configure.ac b/configure.ac
index 83d8ea5..1eb2f63 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
@@ -1318,3 +1325,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();
 
 }

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