[MOAB-dev] r1837 - in MOAB/trunk: . parallel

tautges at mcs.anl.gov tautges at mcs.anl.gov
Thu May 22 12:37:49 CDT 2008


Author: tautges
Date: 2008-05-22 12:37:49 -0500 (Thu, 22 May 2008)
New Revision: 1837

Modified:
   MOAB/trunk/mbparallelcomm_test.cpp
   MOAB/trunk/parallel/MBParallelComm.cpp
   MOAB/trunk/parallel/MBParallelComm.hpp
Log:
Implemented functions to return interface entities and ents with prescribed pstatus flags.


Modified: MOAB/trunk/mbparallelcomm_test.cpp
===================================================================
--- MOAB/trunk/mbparallelcomm_test.cpp	2008-05-22 16:57:29 UTC (rev 1836)
+++ MOAB/trunk/mbparallelcomm_test.cpp	2008-05-22 17:37:49 UTC (rev 1837)
@@ -175,24 +175,24 @@
         // now figure out which vertices are shared
       MBParallelComm *pcomm = new MBParallelComm(mbImpl);
 
-      MBRange shared_ents[6];
+      MBRange iface_ents[6];
       for (int i = 0; i < 4; i++) {
-        tmp_result = pcomm->get_shared_entities(i, shared_ents[i]);
+        tmp_result = pcomm->get_iface_entities(-1, i, iface_ents[i]);
       
         if (MB_SUCCESS != tmp_result) {
-          std::cerr << "get_shared_entities returned error on proc " 
+          std::cerr << "get_iface_entities returned error on proc " 
                     << rank << "; message: " << std::endl;
           PRINT_LAST_ERROR
               result = tmp_result;
         }
-        if (0 != i) shared_ents[4].merge(shared_ents[i]);
+        if (0 != i) iface_ents[4].merge(iface_ents[i]);
       }
       
       if (0 == rank) setime = MPI_Wtime();
 
-        // check # shared entities
-      if (0 <= nshared && nshared != (int) shared_ents[0].size()) {
-        std::cerr << "Didn't get correct number of shared vertices on "
+        // check # iface entities
+      if (0 <= nshared && nshared != (int) iface_ents[0].size()) {
+        std::cerr << "Didn't get correct number of iface vertices on "
                   << "processor " << rank << std::endl;
         result = MB_FAILURE;
       }
@@ -202,24 +202,24 @@
                 << " succeeded." << std::endl;
 
       if (-1 == nshared) {
-        result = mbImpl->get_adjacencies(shared_ents[4], 0, false, shared_ents[5], 
+        result = mbImpl->get_adjacencies(iface_ents[4], 0, false, iface_ents[5], 
                                          MBInterface::UNION);
         
-        std::cerr << "Proc " << rank << " shared entities: " << std::endl;
+        std::cerr << "Proc " << rank << " iface entities: " << std::endl;
         for (int i = 0; i < 4; i++)
-          std::cerr << "    " << shared_ents[i].size() << " "
-                    << i << "d shared entities." << std::endl;
-        std::cerr << "    (" << shared_ents[5].size() 
-                  << " verts adj to other shared ents)" << std::endl;
+          std::cerr << "    " << iface_ents[i].size() << " "
+                    << i << "d iface entities." << std::endl;
+        std::cerr << "    (" << iface_ents[5].size() 
+                  << " verts adj to other iface ents)" << std::endl;
       }
       
       if (debug && 2 == nprocs) {
           // if I'm root, get and print handles on other procs
-        std::vector<MBEntityHandle> sharedh_tags(shared_ents[0].size());
+        std::vector<MBEntityHandle> sharedh_tags(iface_ents[0].size());
         std::fill(sharedh_tags.begin(), sharedh_tags.end(), 0);
         MBTag dumt, sharedh_tag;
         result = pcomm->get_shared_proc_tags(dumt, dumt, sharedh_tag, dumt, dumt);
-        result = mbImpl->tag_get_data(sharedh_tag, shared_ents[0], &sharedh_tags[0]);
+        result = mbImpl->tag_get_data(sharedh_tag, iface_ents[0], &sharedh_tags[0]);
         if (MB_SUCCESS != result) {
           std::cerr << "Couldn't get shared handle tag." << std::endl;
         }

Modified: MOAB/trunk/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.cpp	2008-05-22 16:57:29 UTC (rev 1836)
+++ MOAB/trunk/parallel/MBParallelComm.cpp	2008-05-22 17:37:49 UTC (rev 1837)
@@ -2742,58 +2742,50 @@
   return MB_SUCCESS;
 }
   
-MBErrorCode MBParallelComm::get_shared_entities(int dim,
-                                                MBRange &shared_ents) 
+MBErrorCode MBParallelComm::get_iface_entities(int other_proc,
+                                               int dim,
+                                               MBRange &iface_ents) 
 {
-    // check shared entities
-  MBTag sharedproc_tag = 0, sharedprocs_tag = 0;
-  MBErrorCode result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROC_TAG_NAME, 
-                                              sharedproc_tag);
-
-  result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROCS_TAG_NAME, 
-                                  sharedprocs_tag);
-
-  if (0 == sharedproc_tag && 0 == sharedprocs_tag) 
-    return MB_SUCCESS;
-
-    // get the tag values
-  MBEntityType start_type = MBCN::TypeDimensionMap[dim].first,
-    end_type = MBCN::TypeDimensionMap[dim].second;
-  std::vector<int> proc_tags;
-  for (MBEntityType this_type = start_type; this_type <= end_type;
-       this_type++) {
-    MBRange tmp_ents;
-
-      // PARALLEL_SHARED_PROC is a dense tag, so all ents will have a
-      // value (the default value)
-    if (0 != sharedproc_tag) {
-      result = mbImpl->get_entities_by_type(0, this_type, tmp_ents);
-      RR("Trouble getting entities for shared entities.");
-      proc_tags.resize(tmp_ents.size());
-      if (!tmp_ents.empty()) {
-        result = mbImpl->tag_get_data(sharedproc_tag, 
-                                      tmp_ents, &proc_tags[0]);
-        RR("Trouble getting tag data for shared entities.");
-      }
-      int i;
-      MBRange::iterator rit;
-      for (i = 0, rit = tmp_ents.begin(); rit != tmp_ents.end(); i++, rit++) 
-        if (proc_tags[i] > -1) shared_ents.insert(*rit);
-    }
-    if (0 != sharedprocs_tag) {
-      // PARALLEL_SHARED_PROCS is a sparse tag, so only entities with this
-      // tag set will have one
-      result = mbImpl->get_entities_by_type_and_tag(0, this_type, 
-                                                    &sharedprocs_tag,
-                                                    NULL, 1, shared_ents,
-                                                    MBInterface::UNION);
-      RR("Trouble getting sharedprocs_tag for shared entities.");
-    }
+  MBRange iface_sets;
+  std::vector<int> iface_procs;
+  MBErrorCode result = get_iface_sets_procs(iface_sets, iface_procs);
+  RRA("Failed to get iface sets/procs.");
+  
+  for (MBRange::iterator rit = iface_sets.begin(); rit != iface_sets.end(); rit++) {
+    if (-1 != other_proc && !is_iface_proc(*rit, other_proc)) continue;
+    
+    if (-1 == dim) result = mbImpl->get_entities_by_handle(*rit, iface_ents);
+    else result = mbImpl->get_entities_by_dimension(*rit, dim, iface_ents);
+    RRA(" Failed to get entities in iface set.");
   }
-
+  
   return MB_SUCCESS;
 }
+
+MBErrorCode MBParallelComm::get_pstatus_entities(int dim,
+                                                 unsigned char pstatus_val,
+                                                 MBRange &pstatus_ents)
+{
+  MBRange ents;
+  MBErrorCode result;
   
+  if (-1 == dim) result = mbImpl->get_entities_by_handle(0, ents);
+  else result = mbImpl->get_entities_by_dimension(0, dim, ents);
+  RRA(" ");
+  
+  std::vector<unsigned char> pstatus(ents.size());
+  result = mbImpl->tag_get_data(pstatus_tag(), ents, &pstatus[0]);
+  RRA("Couldn't get pastatus tag.");
+  MBRange::iterator rit = ents.begin();
+  int i = 0;
+  for (; rit != ents.end(); i++, rit++)
+    if (pstatus[i]&pstatus_val &&
+        (-1 == dim || mbImpl->dimension_from_handle(*rit) == dim)) 
+      pstatus_ents.insert(*rit);
+
+  return MB_SUCCESS;
+}
+
 MBErrorCode MBParallelComm::check_global_ids(MBEntityHandle this_set,
                                              const int dimension, 
                                              const int start_id,

Modified: MOAB/trunk/parallel/MBParallelComm.hpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.hpp	2008-05-22 16:57:29 UTC (rev 1836)
+++ MOAB/trunk/parallel/MBParallelComm.hpp	2008-05-22 17:37:49 UTC (rev 1837)
@@ -180,16 +180,28 @@
   MBErrorCode resolve_shared_ents(int resolve_dim = 3, 
                                   int shared_dim = -1);
   
-    /** \brief Get entities shared with other processors, based on 
+    /** \brief Get entities with the given pstatus bit(s) set
+     * Returns any entities whose pstatus tag value v satisfies (v & pstatus_val)
      *
-     * PARALLEL_SHARED_PROC_TAG_NAME and PARALLEL_SHARED_PROCS_TAG_NAME.
-     *
-     * \param dim Dimension of entities shared with other processors
-     * \param shared_ents Shared entities returned in this range
+     * \param dim Dimension of entities to be returned, or -1 if any
+     * \param pstatus_val pstatus value of desired entities
+     * \param pstatus_ents Entities returned from function
      */
-  MBErrorCode get_shared_entities(int dim,
-                                  MBRange &shared_ents);
-
+  MBErrorCode get_pstatus_entities(int dim,
+                                   unsigned char pstatus_val,
+                                   MBRange &pstatus_ents);
+  
+    /** \brief Get entities on an inter-processor interface and of specified dimension
+     * If other_proc is -1, any interface entities are returned.  If dim is -1,
+     * entities of all dimensions on interface are returned.
+     * \param other_proc Rank of processor for which interface entities are requested
+     * \param dim Dimension of interface entities requested
+     * \param iface_ents Entities returned from function
+     */
+  MBErrorCode get_iface_entities(int other_proc,
+                                 int dim,
+                                 MBRange &iface_ents);
+  
     //! pack the buffer with ALL data for orig_ents; return entities actually
     //! packed (including reference sub-entities) in final_ents
   MBErrorCode pack_buffer(MBRange &orig_ents,




More information about the moab-dev mailing list