[MOAB-dev] r1323 - in MOAB/trunk: . parallel test/h5file

tautges at mcs.anl.gov tautges at mcs.anl.gov
Tue Oct 23 13:54:21 CDT 2007


Author: tautges
Date: 2007-10-23 13:54:21 -0500 (Tue, 23 Oct 2007)
New Revision: 1323

Added:
   MOAB/trunk/parallel/MBParallelData.cpp
   MOAB/trunk/parallel/MBParallelData.hpp
Modified:
   MOAB/trunk/MBParallelConventions.h
   MOAB/trunk/parallel/Makefile.am
   MOAB/trunk/parallel/ReadParallel.cpp
   MOAB/trunk/parallel/WriteHDF5Parallel.cpp
   MOAB/trunk/test/h5file/parallel.cpp
Log:
Small parallel modifications.

- Changed some parallel tag convention names:
PARALLEL_INTERFACE_TAG_NAME -> PARALLEL_SHARED_PROC_TAG_NAME
PARALLEL_GLOBAL_ID_TAG_NAME -> PARALLEL_GID_TAG_NAME
PARALLEL_GEOM_TOPO_TAG_NAME -> GEOM_DIMENSION_TAG_NAME

- Implemented MBParallelData class, which currently has the
convenience functions get_partition_sets and get_interface_sets.
These functions just grab the sets out of MOAB with the proper
conventional tag names.  The MBParallelData class can take an
MBParallelComm object in its constructor, which restricts some
functionality to the communicator in that object (and thus affects the
proc rank used in those functions).

Passes make check.



Modified: MOAB/trunk/MBParallelConventions.h
===================================================================
--- MOAB/trunk/MBParallelConventions.h	2007-10-23 16:56:56 UTC (rev 1322)
+++ MOAB/trunk/MBParallelConventions.h	2007-10-23 18:54:21 UTC (rev 1323)
@@ -7,34 +7,13 @@
  * parallel applications.
  */
 
-/** \brief Meshset tag name for interfaces between processors
- *
- * Meshset containing the interface between two processors.
- * The contents of the mesh set is a group of mesh sets
- * (typically corresponding to geometric topology) containing
- * mesh entities.
- *
- * The data of the tag is struct { int; int; }; and contains 
- * the processor numbers (MPI rank) for the pair of processors
- * sharing the interface.
- */
-#define PARALLEL_INTERFACE_TAG_NAME "Interface"
-
 /** \brief Global identifier for interface mesh
  *
  * An integer identifier common to the corresponding mesh entity
  * instances on each processor for a mesh entity on the interface.
  */
-#define PARALLEL_GLOBAL_ID_TAG_NAME "GlobalHandle"
+#define PARALLEL_GID_TAG_NAME "PARALLEL_GID"
 
-/** \brief Dimension of a meshset corresponding to geometric topology.
- *
- * A tag to identify a meshset that corresponds to some geometric
- * topology.  The value is an integer containing the dimension of
- * the corresponding geomteric entity (0=vertex, 1=curve, etc.)
- */
-#define PARALLEL_GEOM_TOPO_TAG_NAME "GeometryTopology"
-
 /** \brief Tag on a meshset representing a parallel partition.
  *
  * When the mesh is partitioned for use in a parallel environment,

Added: MOAB/trunk/parallel/MBParallelData.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelData.cpp	                        (rev 0)
+++ MOAB/trunk/parallel/MBParallelData.cpp	2007-10-23 18:54:21 UTC (rev 1323)
@@ -0,0 +1,94 @@
+#include "MBParallelData.hpp"
+#include "MBParallelComm.hpp"
+#include "MBParallelConventions.h"
+#include "MBInterface.hpp"
+
+#include <map>
+
+    //! return partition sets; if tag_name is input, gets sets with
+    //! that tag name, otherwise uses PARALLEL_PARTITION tag
+MBErrorCode MBParallelData::get_partition_sets(MBRange &part_sets,
+                                               const char *tag_name) 
+{
+  MBTag part_tag = 0;
+  MBErrorCode result;
+  
+  if (NULL != tag_name) 
+    result = mbImpl->tag_get_handle(tag_name, part_tag);
+  else
+    result = mbImpl->tag_get_handle(PARALLEL_PARTITION_TAG_NAME, part_tag);
+    
+  if (MB_SUCCESS != result) return result;
+  else if (0 == part_tag) return MB_TAG_NOT_FOUND;
+  
+  result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, &part_tag, 
+                                                NULL, 1, part_sets,
+                                                MBInterface::UNION);
+  return result;
+}
+  
+
+    //! get communication interface sets and the processors with which
+    //! this processor communicates; sets are sorted by processor
+MBErrorCode MBParallelData::get_interface_sets(std::vector<MBEntityHandle> &iface_sets,
+                                               std::vector<int> &iface_procs) 
+{
+#define CONTINUE {result = tmp_result; continue;}
+  iface_sets.clear();
+  iface_procs.clear();
+  
+  MBTag proc_tag = 0, procs_tag = 0;
+  MBErrorCode result = MB_SUCCESS;
+  int my_rank;
+  if (parallelComm) my_rank = parallelComm->proc_config().proc_rank();
+  else my_rank = mbImpl->proc_rank();
+
+  std::multimap<int, MBEntityHandle> iface_data;
+
+  for (int i = 0; i < 2; i++) {
+    MBErrorCode tmp_result;
+    
+    if (0 == i)
+      tmp_result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROC_TAG_NAME, 
+                                      proc_tag);
+    else
+      tmp_result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROCS_TAG_NAME, 
+                                      proc_tag);
+    if (0 == proc_tag) CONTINUE;
+
+    int tsize;
+    tmp_result = mbImpl->tag_get_size(proc_tag, tsize);
+    if (0 == tsize || MB_SUCCESS != tmp_result) CONTINUE;
+    
+    MBRange proc_sets;
+    tmp_result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, 
+                                                  &proc_tag, NULL, 1,
+                                                  proc_sets, MBInterface::UNION);
+    if (MB_SUCCESS != tmp_result) CONTINUE;
+    
+    if (proc_sets.empty()) CONTINUE;
+      
+    std::vector<int> proc_tags(proc_sets.size()*tsize/sizeof(int));
+    tmp_result = mbImpl->tag_get_data(procs_tag, proc_sets, &proc_tags[0]);
+    if (MB_SUCCESS != tmp_result) CONTINUE;
+    int i;
+    MBRange::iterator rit;
+    
+    for (i = 0, rit = proc_sets.begin(); rit != proc_sets.end(); rit++, i++) {
+      for (int j = 0; j < tsize; j++) {
+        if (my_rank != proc_tags[2*i+j] && proc_tags[2*i+j] >= 0)
+          iface_data.insert(std::pair<int,MBEntityHandle>(proc_tags[2*i+j], *rit));
+      }
+    }
+  }
+
+    // now get the results in sorted order
+  std::multimap<int,MBEntityHandle>::iterator mit;
+  for (mit = iface_data.begin(); mit != iface_data.end(); mit++)
+    iface_procs.push_back((*mit).first),
+      iface_sets.push_back((*mit).second);
+    
+  return result;
+}
+
+

Added: MOAB/trunk/parallel/MBParallelData.hpp
===================================================================
--- MOAB/trunk/parallel/MBParallelData.hpp	                        (rev 0)
+++ MOAB/trunk/parallel/MBParallelData.hpp	2007-10-23 18:54:21 UTC (rev 1323)
@@ -0,0 +1,55 @@
+/**
+ * \class MBParallelData
+ * \brief Parallel data in MOAB
+ * \author Tim Tautges
+ *
+ *  This class implements methods to retrieve information about 
+ * the parallel mesh from MOAB.  Most of this data can be retrieved
+ * directly from MOAB as sets and tags; this class provides convenience
+ * methods implemented on top of other MOAB functions.
+ *
+ */
+
+#ifndef MB_PARALLEL_DATA_HPP
+#define MB_PARALLEL_DATA_HPP
+
+#include "MBForward.hpp"
+#include "MBRange.hpp"
+
+class MBParallelComm;
+
+class MBParallelData
+{
+public:
+
+    //! constructor; if non-null parallelcomm, that is used to
+    //! determine rank, otherwise rank is taken from impl
+  MBParallelData(MBInterface *impl, MBParallelComm *pcomm = NULL);
+
+    //! return partition sets; if tag_name is input, gets sets with
+    //! that tag name, otherwise uses PARALLEL_PARTITION tag
+  MBErrorCode get_partition_sets(MBRange &part_sets,
+                                 const char *tag_name = NULL);
+
+    //! get communication interface sets and the processors with which
+    //! this processor communicates; sets are sorted by processor
+  MBErrorCode get_interface_sets(std::vector<MBEntityHandle> &iface_sets,
+                                 std::vector<int> &iface_procs);
+  
+
+private:
+
+    //! interface instance to which this instance corresponds
+  MBInterface *mbImpl;
+
+    //! MBParallelComm object to which this is bound
+  MBParallelComm *parallelComm;
+  
+};
+
+inline MBParallelData::MBParallelData(MBInterface *impl, 
+                                      MBParallelComm *pcomm) 
+    : mbImpl(impl), parallelComm(pcomm) 
+{}
+
+#endif

Modified: MOAB/trunk/parallel/Makefile.am
===================================================================
--- MOAB/trunk/parallel/Makefile.am	2007-10-23 16:56:56 UTC (rev 1322)
+++ MOAB/trunk/parallel/Makefile.am	2007-10-23 18:54:21 UTC (rev 1323)
@@ -23,6 +23,7 @@
      MBParallelComm.cpp \
      MBParallelConventions.h \
      MBProcConfig.cpp \
+     MBParallelData.cpp \
      ReadParallel.cpp \
      crystal.c crystal.h errmem.h errmem.c \
      transfer.c gs.c gs.h tuple_list.c \
@@ -32,6 +33,7 @@
   MOAB_PARALLEL_HDRS += \
      MBParallelComm.hpp \
      MBProcConfig.hpp \
+     MBParallelData.hpp \
      ReadParallel.hpp 
 
 if PARALLEL_HDF5

Modified: MOAB/trunk/parallel/ReadParallel.cpp
===================================================================
--- MOAB/trunk/parallel/ReadParallel.cpp	2007-10-23 16:56:56 UTC (rev 1322)
+++ MOAB/trunk/parallel/ReadParallel.cpp	2007-10-23 18:54:21 UTC (rev 1323)
@@ -108,6 +108,8 @@
 
     case POPT_READ_DELETE:
       pa_vec.push_back(PA_READ);
+      pa_vec.push_back(PA_CHECK_GIDS_SERIAL);
+      pa_vec.push_back(PA_GET_FILESET_ENTS);
       pa_vec.push_back(PA_DELETE_NONLOCAL);
       break;
 

Modified: MOAB/trunk/parallel/WriteHDF5Parallel.cpp
===================================================================
--- MOAB/trunk/parallel/WriteHDF5Parallel.cpp	2007-10-23 16:56:56 UTC (rev 1322)
+++ MOAB/trunk/parallel/WriteHDF5Parallel.cpp	2007-10-23 18:54:21 UTC (rev 1323)
@@ -274,9 +274,9 @@
   remoteMesh.resize( numProc );
   
     // Get tag handles
-  result = iFace->tag_get_handle( PARALLEL_INTERFACE_TAG_NAME, iface_tag );
+  result = iFace->tag_get_handle( PARALLEL_SHARED_PROC_TAG_NAME, iface_tag );
   if (MB_SUCCESS != result) return result;
-  result = iFace->tag_get_handle( PARALLEL_GEOM_TOPO_TAG_NAME, geom_tag );
+  result = iFace->tag_get_handle( GEOM_DIMENSION_TAG_NAME, geom_tag );
   if (MB_SUCCESS != result) return result;
   
   
@@ -2068,7 +2068,7 @@
   assert(MPI_SUCCESS == result);
   
   MBTag global_id_tag;
-  rval = iFace->tag_get_handle( PARALLEL_GLOBAL_ID_TAG_NAME, global_id_tag );
+  rval = iFace->tag_get_handle( PARALLEL_GID_TAG_NAME, global_id_tag );
   assert(MB_SUCCESS == rval);
   
     // Set file IDs for each communicated entity

Modified: MOAB/trunk/test/h5file/parallel.cpp
===================================================================
--- MOAB/trunk/test/h5file/parallel.cpp	2007-10-23 16:56:56 UTC (rev 1322)
+++ MOAB/trunk/test/h5file/parallel.cpp	2007-10-23 18:54:21 UTC (rev 1323)
@@ -38,7 +38,7 @@
      MPI_Barrier( MPI_COMM_WORLD )
 
 MBCore *iFace = NULL;
-MBTag blockTag, geomTag, pGeomTag, ifaceTag, idTag, gidTag;
+MBTag blockTag, geomTag, ifaceTag, idTag, gidTag;
 
 static void printerror( const char* format, ... )
 {
@@ -124,11 +124,9 @@
   rval = iFace->tag_get_handle( MATERIAL_SET_TAG_NAME, blockTag ); assert(!rval);
   rval = iFace->tag_get_handle( GEOM_DIMENSION_TAG_NAME, geomTag ); assert(!rval);
   rval = iFace->tag_get_handle( GLOBAL_ID_TAG_NAME, idTag ); assert(!rval);
-  rval = iFace->tag_create( PARALLEL_GEOM_TOPO_TAG_NAME, sizeof(int), 
-                           MB_TAG_SPARSE, pGeomTag, 0 ); assert(!rval);
-  rval = iFace->tag_create( PARALLEL_INTERFACE_TAG_NAME, 2*sizeof(int),
+  rval = iFace->tag_create( PARALLEL_SHARED_PROC_TAG_NAME, 2*sizeof(int),
                            MB_TAG_SPARSE, ifaceTag, 0 ); assert(!rval);
-  rval = iFace->tag_create( PARALLEL_GLOBAL_ID_TAG_NAME, sizeof(MBEntityHandle),
+  rval = iFace->tag_create( PARALLEL_GID_TAG_NAME, sizeof(MBEntityHandle),
                            MB_TAG_SPARSE, gidTag, 0 ); assert(!rval);
   
     // Get the list of geometry volumes this processor is to export
@@ -340,17 +338,6 @@
     rval = iFace->tag_set_data( gidTag, &*all_iter, 1,  &*all_iter );  assert(!rval); 
   }
      
-    // Copy dimension from non-parallel geometry tag to parallel geometry tag
-  everything.clear();
-  iFace->get_entities_by_type_and_tag(  0, MBENTITYSET, &geomTag, 0, 1, everything );
-  for (riter = everything.begin(); riter != everything.end(); ++riter)
-  { 
-    int dim;
-    rval = iFace->tag_get_data( geomTag, &*riter, 1, &dim ); assert(!rval);
-    rval = iFace->tag_set_data( pGeomTag, &*riter, 1, &dim ); assert(!rval);
-  }
-
-
     // Write all the mesh in a single, serial file to compare with
     // the parallel output.
   if (0 == rank) {




More information about the moab-dev mailing list