[MOAB-dev] [patch] Remove entity sets from counts for iMesh_getNumOfType/Topo

Jed Brown jed at 59A2.org
Mon Oct 6 11:37:57 CDT 2008


The last of the attached patches resolves this issue.  The other patches
are floating locally.  They are all very minor except the one which
fixes types in many places in the iMesh interface.

Jed
-------------- next part --------------
From 0c0631bf6a2e0f74be7b2374877a0f0a7148f621 Mon Sep 17 00:00:00 2001
From: Jed Brown <jed at 59A2.org>
Date: Mon, 22 Sep 2008 19:18:40 +0200
Subject: [PATCH] Closed a memory leak in ReadParallel due to unresolved ownership of the
 communicator.

Signed-off-by: Jed Brown <jed at 59A2.org>
---
 parallel/ReadParallel.cpp |   12 +++++++++---
 parallel/ReadParallel.hpp |    5 ++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/parallel/ReadParallel.cpp b/parallel/ReadParallel.cpp
index 52d87e5..4c2c8b7 100644
--- a/parallel/ReadParallel.cpp
+++ b/parallel/ReadParallel.cpp
@@ -40,14 +40,20 @@ const char* ReadParallel::parallelOptsNames[] = { "NONE", "BCAST", "BCAST_DELETE
       
 ReadParallel::ReadParallel(MBInterface* impl, 
                            MBParallelComm *pc) 
-        : mbImpl(impl), myPcomm(pc) 
+        : mbImpl(impl), myPcomm(pc), myPcommAllocated(false)
 {
+  if (!myPcomm) myPcomm = MBParallelComm::get_pcomm(mbImpl, 0);
   if (!myPcomm) {
-    myPcomm = MBParallelComm::get_pcomm(mbImpl, 0);
-    if (NULL == myPcomm) myPcomm = new MBParallelComm(mbImpl);
+    myPcomm = new MBParallelComm(mbImpl);
+    myPcommAllocated = true;
   }
 }
 
+ReadParallel::~ReadParallel()
+{
+  if (myPcommAllocated) delete myPcomm;
+}
+
 MBErrorCode ReadParallel::load_file(const char **file_names,
                                     const int num_files,
                                     MBEntityHandle& file_set,
diff --git a/parallel/ReadParallel.hpp b/parallel/ReadParallel.hpp
index 7436df1..692392c 100644
--- a/parallel/ReadParallel.hpp
+++ b/parallel/ReadParallel.hpp
@@ -35,7 +35,7 @@ public:
   ReadParallel(MBInterface* impl = NULL, MBParallelComm *pc = NULL);
 
    //! Destructor
-  virtual ~ReadParallel() {}
+  virtual ~ReadParallel();
 
   static const char *parallelOptsNames[];
   
@@ -76,6 +76,9 @@ private:
 
     // each reader can keep track of its own pcomm
   MBParallelComm *myPcomm;
+
+    // should myPcomm be freed in dtor
+  bool myPcommAllocated;
 };
 
 inline MBErrorCode ReadParallel::load_file(const char *file_name,
-- 
1.6.0.2

-------------- next part --------------
From bb0d8dabcd2364900b1eed540d3c3ffa7315a10c Mon Sep 17 00:00:00 2001
From: Jed Brown <jed at 59A2.org>
Date: Mon, 22 Sep 2008 19:38:44 +0200
Subject: [PATCH] Make the ITAPS opaque handles use incomplete types instead of void*.

* iBase.h: incomplete types

* iMesh.h: incomplete types, fix function prototypes

* iMeshP_MOAB.cpp: Fix error array.

* iMesh_MOAB.cpp: Fix types in several places, an off-by-one error in
  iMesh_getDescription, storage order.

* iMesh_extensions.h: fix incorrect type

* testc_cbind.c: fix incorrect types

Signed-off-by: Jed Brown <jed at 59A2.org>
---
 tools/iMesh/iBase.h            |    8 ++++----
 tools/iMesh/iMesh.h            |   12 ++++++------
 tools/iMesh/iMeshP_MOAB.cpp    |   21 ++++++++++++++++++++-
 tools/iMesh/iMesh_MOAB.cpp     |   40 ++++++++++++++++++++--------------------
 tools/iMesh/iMesh_extensions.h |    2 +-
 tools/iMesh/testc_cbind.c      |    8 ++++----
 6 files changed, 55 insertions(+), 36 deletions(-)

diff --git a/tools/iMesh/iBase.h b/tools/iMesh/iBase.h
index 585c991..549fbef 100644
--- a/tools/iMesh/iBase.h
+++ b/tools/iMesh/iBase.h
@@ -15,10 +15,10 @@ extern "C"
      * TYPEDEF'S
      *==========================================================
      */
-  typedef void* iBase_Instance;
-  typedef void* iBase_EntityHandle;
-  typedef void* iBase_EntitySetHandle;
-  typedef void* iBase_TagHandle;
+  typedef struct iBase_Instance_private        *iBase_Instance;
+  typedef struct iBase_EntityHandle_private    *iBase_EntityHandle;
+  typedef struct iBase_EntitySetHandle_private *iBase_EntitySetHandle;
+  typedef struct iBase_TagHandle_private       *iBase_TagHandle;
 
     /*==========================================================
      * ENTITYTYPE ENUMERATION
diff --git a/tools/iMesh/iMesh.h b/tools/iMesh/iMesh.h
index 65eb51b..fdb0dc5 100644
--- a/tools/iMesh/iMesh.h
+++ b/tools/iMesh/iMesh.h
@@ -76,19 +76,19 @@ extern "C" {
      *
      * Type used to store iMesh interface handle
      */
-  typedef void* iMesh_Instance;
+  typedef struct iMesh_Instance_private *iMesh_Instance;
 
     /**\brief  Type used to store an iterator returned by iMesh
      *
      * Type used to store an iterator returned by iMesh
      */
-  typedef void* iMesh_EntityIterator;
+  typedef struct iMesh_EntityIterator_private *iMesh_EntityIterator;
 
     /**\brief  Type used to store an array iterator returned by iMesh
      *
      * Type used to store an array iterator returned by iMesh
      */
-  typedef void* iMesh_EntityArrIterator;
+  typedef struct iMesh_EntityArrIterator_private *iMesh_EntityArrIterator;
 
     /**\brief  Enumerator specifying entity topology
      *
@@ -514,7 +514,7 @@ extern "C" {
      * \param *err Pointer to error type returned from function
      */
   void iMesh_getAdjEntities(iMesh_Instance instance,
-                            /*in*/ const iBase_EntityHandle entity_set_handle,
+                            /*in*/ const iBase_EntitySetHandle entity_set_handle,
                             /*in*/ const int entity_type_requestor,
                             /*in*/ const int entity_topology_requestor,
                             /*in*/ const int entity_type_requested,
@@ -870,7 +870,7 @@ extern "C" {
      * \param *err Pointer to error type returned from function
      */
   void iMesh_addEntSet(iMesh_Instance instance,
-                       /*in*/ const iBase_EntityHandle entity_set_to_add,
+                       /*in*/ const iBase_EntitySetHandle entity_set_to_add,
                        /*inout*/ iBase_EntitySetHandle* entity_set_handle,
                        /*out*/ int *err);
 
@@ -901,7 +901,7 @@ extern "C" {
      */
   void iMesh_isEntContained(iMesh_Instance instance,
                             /*in*/ const iBase_EntitySetHandle containing_entity_set,
-                            /*in*/ const iBase_EntitySetHandle contained_entity,
+                            /*in*/ const iBase_EntityHandle contained_entity,
                             /*out*/ int *is_contained,
                             /*out*/ int *err);
 
diff --git a/tools/iMesh/iMeshP_MOAB.cpp b/tools/iMesh/iMeshP_MOAB.cpp
index bd26269..47ae939 100644
--- a/tools/iMesh/iMeshP_MOAB.cpp
+++ b/tools/iMesh/iMeshP_MOAB.cpp
@@ -14,7 +14,9 @@
 #define MBI reinterpret_cast<MBInterface*>(instance)
 
 #define RETURN(a) {iMesh_LAST_ERROR.error_type = a; *err = a;return;}
-#define iMesh_processError(a, b) {sprintf(iMesh_LAST_ERROR.description, "%s", b); iMesh_LAST_ERROR.error_type = a; *err = a;}
+#define iMesh_processError(a, b)                                        \
+  {snprintf(iMesh_LAST_ERROR.description, sizeof(iMesh_LAST_ERROR.description), "%s", b); \
+    iMesh_LAST_ERROR.error_type = a; *err = a;}
 
 // TAG_CHECK_SIZE is like CHECK_SIZE except it checks for and makes the allocated memory
 // size a multiple of sizeof(void*), and the pointer is assumed to be type char*
@@ -31,6 +33,8 @@
     if (NULL == array) {iMesh_processError(iBase_MEMORY_ALLOCATION_FAILED, \
           "Couldn't allocate array.");RETURN(iBase_MEMORY_ALLOCATION_FAILED); }\
   }
+#define NOT_IMPLEMENTED_IF(cond) \
+  if (cond) { iMesh_processError(iBase_ERROR_MAP[MB_NOT_IMPLEMENTED], "Not implemented."); RETURN(iBase_ERROR_MAP[MB_NOT_IMPLEMENTED]); }
 #define HANDLE_ARRAY_PTR(array) reinterpret_cast<MBEntityHandle*>(array)
 #define CONST_HANDLE_ARRAY_PTR(array) reinterpret_cast<const MBEntityHandle*>(array)
 #define TAG_HANDLE(handle) reinterpret_cast<MBTag>(handle)
@@ -52,6 +56,8 @@ const iBase_ErrorType iBase_ERROR_MAP[] =
   iBase_FILE_WRITE_ERROR, // MB_FILE_WRITE_ERROR,
   iBase_NOT_SUPPORTED, // MB_NOT_IMPLEMENTED,
   iBase_TAG_ALREADY_EXISTS, // MB_ALREADY_ALLOCATED,
+  iBase_FAILURE, // MB_VARIABLE_DATA_LENGTH,
+  iBase_FAILURE, // MB_INVALID_SIZE,
   iBase_FAILURE // MB_FAILURE};
 };
 
@@ -164,6 +170,7 @@ void iMeshP_createPartitionAll( iMesh_Instance /*instance*/,
   {
     MBParallelComm *pc = MBParallelComm::get_pcomm(MBI, 0);
     if (!pc) RETURN(iBase_ERROR_MAP[MB_FAILURE]);
+    NOT_IMPLEMENTED_IF(rank != pc->proc_config().proc_rank());
 
     MBRange part_sets;
   
@@ -364,6 +371,18 @@ void iMeshP_createPartitionAll( iMesh_Instance /*instance*/,
     RETURN(*err);
   }
   
+  void iMeshP_getPartIdsFromPartHandlesArr(iMesh_Instance instance,
+                       const iMeshP_PartitionHandle partition_handle,
+             /*in*/    const iMeshP_PartHandle *part_handles,
+             /*in*/    const int part_handles_size,
+             /*inout*/ iMeshP_Part **part_ids,
+             /*inout*/ int *part_ids_allocated,
+             /*out*/   int *part_ids_size,
+                       int *err)
+  {
+    RETURN(iBase_NOT_SUPPORTED);
+  }
+
 
 #ifdef __cplusplus
 } // extern "C"
diff --git a/tools/iMesh/iMesh_MOAB.cpp b/tools/iMesh/iMesh_MOAB.cpp
index 58a9a53..5b627fe 100644
--- a/tools/iMesh/iMesh_MOAB.cpp
+++ b/tools/iMesh/iMesh_MOAB.cpp
@@ -231,7 +231,7 @@ extern "C" {
   void iMesh_getDescription(iMesh_Instance instance, 
                             char *descr, int *err, int descr_len)
   {
-    unsigned int len = MIN(strlen(iMesh_LAST_ERROR.description), ((unsigned int) descr_len));
+    unsigned int len = MIN(strlen(iMesh_LAST_ERROR.description), ((unsigned int) descr_len-1));
     strncpy(descr, iMesh_LAST_ERROR.description, len);
     descr[len] = '\0';
     RETURN(iBase_SUCCESS);
@@ -304,7 +304,7 @@ extern "C" {
   }
    
   void iMesh_load(iMesh_Instance instance,
-                  const iBase_EntityHandle handle,
+                  const iBase_EntitySetHandle handle,
                   const char *name, const char *options, 
                   int *err, int name_len, int options_len) 
   {
@@ -347,7 +347,7 @@ extern "C" {
   }
 
   void iMesh_save(iMesh_Instance instance,
-                  const iBase_EntityHandle handle,
+                  const iBase_EntitySetHandle handle,
                   const char *name, const char *options, 
                   int *err, const int name_len, int options_len) 
   {
@@ -388,7 +388,7 @@ extern "C" {
   void iMesh_getDfltStorage(iMesh_Instance instance,
                             int *order, int *err)
   {
-    *order = iBase_BLOCKED;
+    *order = iBase_INTERLEAVED;
     RETURN(iBase_SUCCESS);
   }
   
@@ -845,13 +845,13 @@ extern "C" {
                              /*in*/ const int requested_entity_type,
                              /*in*/ const int requested_entity_topology,
                              /*in*/ const int requested_array_size,
-                             /*out*/ iMesh_EntityIterator* entArr_iterator,
+                             /*out*/ iMesh_EntityArrIterator* entArr_iterator,
                              int *err) 
   {
     MBEntityType req_type = mb_topology_table[requested_entity_topology];
     int req_dimension = (req_type == MBMAXTYPE ? (int) requested_entity_type : -1);
     RangeIterator *new_it = new RangeIterator;
-    *entArr_iterator = reinterpret_cast<iMesh_EntityIterator>(new_it);
+    *entArr_iterator = reinterpret_cast<iMesh_EntityArrIterator>(new_it);
     new_it->requestedSize = requested_array_size;
   
     MBErrorCode result;
@@ -889,7 +889,7 @@ extern "C" {
  * Method:  getEntArrNextIter[]
  */
   void iMesh_getNextEntArrIter (iMesh_Instance instance,
-                                /*in*/ iMesh_EntityIterator entArr_iterator,
+                                /*in*/ iMesh_EntityArrIterator entArr_iterator,
                                 /*inout*/ iBase_EntityHandle** entity_handles,
                                 /*inout*/ int* entity_handles_allocated,
                                 /*out*/ int* entity_handles_size,
@@ -925,7 +925,7 @@ extern "C" {
  * Method:  resetEntArrIter[]
  */
   void iMesh_resetEntArrIter (iMesh_Instance instance,
-                              /*in*/ iMesh_EntityIterator entArr_iterator, int *err) 
+                              /*in*/ iMesh_EntityArrIterator entArr_iterator, int *err)
   {
     RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
 
@@ -935,7 +935,7 @@ extern "C" {
   }
 
   void iMesh_endEntArrIter (iMesh_Instance instance,
-                            /*in*/ iMesh_EntityIterator entArr_iterator, int *err) 
+                            /*in*/ iMesh_EntityArrIterator entArr_iterator, int *err)
   {
     RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
 
@@ -1119,7 +1119,7 @@ extern "C" {
     }
   
       // return EntitySet_Handle
-    *entity_set_created = (iBase_EntityHandle)meshset;
+    *entity_set_created = (iBase_EntitySetHandle)meshset;
     RETURN(iBase_ERROR_MAP[result]);
   }
 
@@ -1202,7 +1202,7 @@ extern "C" {
     int k = 0;
 
     for (; iter != end_iter; iter++)
-      (*contained_entset_handles)[k++] = (iBase_EntityHandle)*iter;
+      (*contained_entset_handles)[k++] = (iBase_EntitySetHandle)*iter;
 
     *contained_entset_handles_size = sets.size();
     RETURN(iBase_SUCCESS);
@@ -1297,7 +1297,7 @@ extern "C" {
 
   void iMesh_isEntContained (iMesh_Instance instance,
                              /*in*/ const iBase_EntitySetHandle containing_entity_set,
-                             /*in*/ const iBase_EntitySetHandle contained_entity,
+                             /*in*/ const iBase_EntityHandle contained_entity,
                              int *is_contained, int *err) 
   {
     MBRange all_ents;
@@ -1324,7 +1324,7 @@ extern "C" {
                                 /*in*/ const iBase_EntitySetHandle contained_entity_set,
                                 int *is_contained, int *err) 
   {
-    iMesh_isEntContained(instance, containing_entity_set, contained_entity_set,
+    iMesh_isEntContained(instance, containing_entity_set, (iBase_EntityHandle)contained_entity_set,
                          is_contained, err);
   }
 
@@ -2073,7 +2073,7 @@ extern "C" {
       *status = iBase_CREATION_FAILED;
     else
       *status = iBase_SUCCESS;
-    *new_entity_handle = CAST_TO_VOID(tmp_ent);
+    *new_entity_handle = (iBase_EntityHandle)tmp_ent;
 
     *err = *status;
   }
@@ -2449,7 +2449,7 @@ extern "C" {
                           int *err) 
   {
     iMesh_initEntArrIter(instance, entity_set_handle, requested_entity_type,
-                         requested_entity_topology, 1, entity_iterator,
+                         requested_entity_topology, 1, (iMesh_EntityArrIterator*)entity_iterator,
                          err);
   }
 
@@ -2460,20 +2460,20 @@ extern "C" {
   {
     int eh_size = 1;
     iMesh_getNextEntArrIter(instance,
-                            entity_iterator, &entity_handle, &eh_size, &eh_size, is_end, err);
+                            (iMesh_EntityArrIterator)entity_iterator, &entity_handle, &eh_size, &eh_size, is_end, err);
   
   }
 
   void iMesh_resetEntIter (iMesh_Instance instance,
                            /*in*/ iMesh_EntityIterator entity_iterator, int *err) 
   {
-    iMesh_resetEntArrIter(instance, entity_iterator, err);  
+    iMesh_resetEntArrIter(instance, (iMesh_EntityArrIterator)entity_iterator, err);
   }
 
   void iMesh_endEntIter (iMesh_Instance instance,
                          /*in*/ iMesh_EntityIterator entity_iterator, int *err) 
   {
-    iMesh_endEntArrIter(instance, entity_iterator, err);
+    iMesh_endEntArrIter(instance, (iMesh_EntityArrIterator)entity_iterator, err);
   }
 
   void iMesh_getEntTopo (iMesh_Instance instance,
@@ -2907,7 +2907,7 @@ extern "C" {
                                  /*in*/ const char * const *tag_vals,
                                  /*in*/ const int num_tags_vals,
                                  /*in*/ const int recursive,
-                                 /*out*/ iBase_EntityHandle** set_handles,
+                                 /*out*/ iBase_EntitySetHandle** set_handles,
                                  /*out*/ int* set_handles_allocated,
                                  /*out*/ int* set_handles_size,
                                  /*out*/ int *err)
@@ -2929,7 +2929,7 @@ extern "C" {
     }
 
     CHECK_SIZE(*set_handles, *set_handles_allocated, 
-               (int)out_entities.size(), iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+               (int)out_entities.size(), iBase_EntitySetHandle, iBase_MEMORY_ALLOCATION_FAILED);
 
     std::copy(out_entities.begin(), out_entities.end(), ((MBEntityHandle*) *set_handles));
   
diff --git a/tools/iMesh/iMesh_extensions.h b/tools/iMesh/iMesh_extensions.h
index ed4c5db..ed8cd04 100644
--- a/tools/iMesh/iMesh_extensions.h
+++ b/tools/iMesh/iMesh_extensions.h
@@ -140,7 +140,7 @@ extern "C" {
                                  /*in*/ const char * const *tag_vals,
                                  /*in*/ const int num_tags_vals,
                                  /*in*/ const int recursive,
-                                 /*out*/ iBase_EntityHandle** set_handles,
+                                 /*out*/ iBase_EntitySetHandle** set_handles,
                                  /*out*/ int* set_handles_allocated,
                                  /*out*/ int* set_handles_size,
                                  /*out*/ int *err);
diff --git a/tools/iMesh/testc_cbind.c b/tools/iMesh/testc_cbind.c
index 8be9e57..e9dd89c 100755
--- a/tools/iMesh/testc_cbind.c
+++ b/tools/iMesh/testc_cbind.c
@@ -796,7 +796,7 @@ int entity_sets_subtest(iMesh_Instance mesh, int is_list,
   }
 
     // check if parent is really added
-  iBase_EntityHandle *parents = NULL;
+  iBase_EntitySetHandle *parents = NULL;
   int parents_alloc = 0, parents_size;
   iMesh_getPrnts(mesh, parent_child, 0, 
                  &parents, &parents_alloc, &parents_size, &result);
@@ -1636,7 +1636,7 @@ int entityset_double_tag_test(iMesh_Instance mesh,
 }
 
 int entityset_struct_tag_test(iMesh_Instance mesh, 
-                               iBase_EntityHandle *sets, int sets_size,
+                               iBase_EntitySetHandle *sets, int sets_size,
                                iBase_TagHandle *struct_tag) 
 {
   int result;
@@ -1692,7 +1692,7 @@ int entityset_struct_tag_test(iMesh_Instance mesh,
 }
 
 int entityset_tag_delete_test(iMesh_Instance mesh, 
-                               iBase_EntityHandle *sets, int sets_size) 
+                               iBase_EntitySetHandle *sets, int sets_size)
 {
     // test forced, unforced deletion of tags from entities
   int result;
@@ -1700,7 +1700,7 @@ int entityset_tag_delete_test(iMesh_Instance mesh,
 
     // test getAlliBase_TagHandles for first entity
   iBase_TagHandle *all_tags = NULL;
-  iBase_EntityHandle dum_entity = sets[0];
+  iBase_EntitySetHandle dum_entity = sets[0];
   int all_tags_alloc = 0, all_tags_size;
   iMesh_getAllEntSetTags(mesh, sets[0], &all_tags, &all_tags_alloc,
 			 &all_tags_size, &result);
-- 
1.6.0.2

-------------- next part --------------
From 7ac1e437c4e774cd105c56ea4987d789b4edc669 Mon Sep 17 00:00:00 2001
From: Jed Brown <jed at 59A2.org>
Date: Tue, 23 Sep 2008 14:49:24 +0200
Subject: [PATCH] Required for automake 1.10

Signed-off-by: Jed Brown <jed at 59A2.org>
---
 configure.in |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.in b/configure.in
index 95d07fe..22b5112 100644
--- a/configure.in
+++ b/configure.in
@@ -58,8 +58,8 @@ AC_DEFINE_UNQUOTED(MB_VERSION_STRING,"${VERSION_STRING}",[MOAB Version String])
 ################################################################################
 ITAPS_LIBTOOL_VAR( [CXX], [compiler_lib_search_path], [MOAB_CXX_LINKFLAGS])
 ITAPS_LIBTOOL_VAR( [CXX], [postdeps], [MOAB_CXX_LIBS])
-AC_SUBST( MOAB_CXX_LINKFLAGS )
-AC_SUBST( MOAB_CXX_LIBS )
+AC_SUBST(MOAB_CXX_LINKFLAGS)
+AC_SUBST(MOAB_CXX_LIBS)
 
 ################################################################################
 #                              HANDLE SIZE
-- 
1.6.0.2

-------------- next part --------------
From 193b8010b04d72047a7a0cf9bfcce01b92623843 Mon Sep 17 00:00:00 2001
From: Jed Brown <jed at 59A2.org>
Date: Sat, 4 Oct 2008 12:49:43 +0200
Subject: [PATCH] Resolve ownership of MBParallelComm in MBZoltan, fixes missing comm in serial.

Signed-off-by: Jed Brown <jed at 59A2.org>
---
 tools/mbzoltan/MBZoltan.cpp |    8 +++++++-
 tools/mbzoltan/MBZoltan.hpp |    2 ++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/tools/mbzoltan/MBZoltan.cpp b/tools/mbzoltan/MBZoltan.cpp
index 7743e5c..a477946 100644
--- a/tools/mbzoltan/MBZoltan.cpp
+++ b/tools/mbzoltan/MBZoltan.cpp
@@ -52,6 +52,7 @@ MBZoltan::MBZoltan( MBInterface *impl ,
                     int argc, 
                     char **argv ) 
                    : mbImpl(impl), 
+                     mbpcAllocated(false),
                      myZZ(NULL), 
                      newMoab(false), 
                      useCoords(use_coords),
@@ -59,11 +60,16 @@ MBZoltan::MBZoltan( MBInterface *impl ,
                      argvArg(argv)
 {
   mbpc = MBParallelComm::get_pcomm(mbImpl, 0);
+  if (NULL == mbpc) {
+    mbpc = new MBParallelComm(mbImpl);
+    mbpcAllocated = true;
+  }
 }
 
 MBZoltan::~MBZoltan() 
 {
-  if (NULL == myZZ) delete myZZ;
+  if (mbpcAllocated) delete mbpc;
+  delete myZZ;
 }
 
 MBErrorCode MBZoltan::balance_mesh(const char *zmethod,
diff --git a/tools/mbzoltan/MBZoltan.hpp b/tools/mbzoltan/MBZoltan.hpp
index 2c385bd..947bd69 100644
--- a/tools/mbzoltan/MBZoltan.hpp
+++ b/tools/mbzoltan/MBZoltan.hpp
@@ -115,6 +115,8 @@ extern "C"
 
     MBParallelComm *mbpc;
 
+    bool mbpcAllocated;
+
     Zoltan *myZZ;
   
     bool newMoab;
-- 
1.6.0.2

-------------- next part --------------
From 7dbd86572b8c439c19bb09be0bd69d7735acd82a Mon Sep 17 00:00:00 2001
From: Jed Brown <jed at 59A2.org>
Date: Mon, 6 Oct 2008 18:22:05 +0200
Subject: [PATCH] iMesh_MOAB.cpp: Remove entity sets from counts for iMesh_getNumOfType/Topo.

Signed-off-by: Jed Brown <jed at 59A2.org>
---
 tools/iMesh/iMesh_MOAB.cpp |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/tools/iMesh/iMesh_MOAB.cpp b/tools/iMesh/iMesh_MOAB.cpp
index 5b627fe..e381d1e 100644
--- a/tools/iMesh/iMesh_MOAB.cpp
+++ b/tools/iMesh/iMesh_MOAB.cpp
@@ -2720,15 +2720,20 @@ extern "C" {
                              /*out*/ int *err) 
   {
     *num_type = 0;
-    MBErrorCode result;
-    if (entity_type == iBase_ALL_TYPES)
+    MBErrorCode result, result_sets = MB_SUCCESS;
+    if (entity_type == iBase_ALL_TYPES) {
+      int num_sets;
       result = MBI->get_number_entities_by_handle
         (ENTITY_HANDLE(entity_set_handle), *num_type, recursive);
-    else
+      result_sets = MBI->get_number_entities_by_type
+        (ENTITY_HANDLE(entity_set_handle), MBENTITYSET, num_sets, recursive);
+      *num_type -= num_sets;
+    } else {
       result = MBI->get_number_entities_by_dimension
         (ENTITY_HANDLE(entity_set_handle), entity_type, *num_type, recursive);
+    }
 
-    if (result != MB_SUCCESS) {
+    if (MB_SUCCESS != result || MB_SUCCESS != result_sets) {
       std::string msg("iMesh_entitysetGetNumberEntityOfType: ERROR getting number of entities"
                       " by type, with error type: ");
       msg += MBI->get_error_string(result);
@@ -2769,11 +2774,18 @@ extern "C" {
     }
 
     *num_topo = 0;
-    MBErrorCode result = 
-      MBI->get_number_entities_by_type(ENTITY_HANDLE(entity_set_handle), 
+    MBErrorCode result, result_sets = MB_SUCCESS;
+    result = MBI->get_number_entities_by_type(ENTITY_HANDLE(entity_set_handle),
                                        mb_topology_table[entity_topology], 
                                        *num_topo, recursive);
-    if (MB_SUCCESS != result) {
+    if (iMesh_ALL_TOPOLOGIES == entity_topology) { // remove entity sets from count
+      int num_sets;
+      result_sets = MBI->get_number_entities_by_type
+        (ENTITY_HANDLE(entity_set_handle), MBENTITYSET, num_sets, recursive);
+      *num_topo -= num_sets;
+    }
+
+    if (MB_SUCCESS != result || MB_SUCCESS != result_sets) {
       std::string msg("iMesh_entitysetGetNumberEntityOfTopology: ERROR getting "
                       "number of entities by topology., with error type: ");
       msg += MBI->get_error_string(result);
-- 
1.6.0.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <https://lists.mcs.anl.gov/mailman/private/moab-dev/attachments/20081006/4b10e04b/attachment.pgp>


More information about the moab-dev mailing list