[MOAB-dev] commit/MOAB: danwu: Updated MPAS reader and some unit tests. If NO_MIXED_ELEMENTS read option is set, on the processor that creates the gather set, all cells (including the gather cells) will be in one contiguous chunk.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Oct 7 17:19:18 CDT 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/5910abb7155a/
Changeset:   5910abb7155a
Branch:      master
User:        danwu
Date:        2013-10-08 00:19:06
Summary:     Updated MPAS reader and some unit tests. If NO_MIXED_ELEMENTS read option is set, on the processor that creates the gather set, all cells (including the gather cells) will be in one contiguous chunk.

Affected #:  5 files

diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index 0bf9274..42eeca0 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -351,8 +351,8 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
   std::vector<double*> arrays;
   Range tmp_range;
   ErrorCode rval = _readNC->readMeshIface->get_node_coords(3, nLocalVertices, 0, start_vertex, arrays,
-                                            // Might have to create gather mesh later
-                                            (create_gathers ? nLocalVertices + nVertices : nLocalVertices));
+                                                          // Might have to create gather mesh later
+                                                          (create_gathers ? nLocalVertices + nVertices : nLocalVertices));
   ERRORR(rval, "Couldn't create local vertices in MPAS mesh.");
   tmp_range.insert(start_vertex, start_vertex + nLocalVertices - 1);
 
@@ -397,8 +397,8 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
   EntityHandle start_edge;
   EntityHandle* conn_arr_edges;
   rval = _readNC->readMeshIface->get_element_connect(nLocalEdges, 2, MBEDGE, 0, start_edge, conn_arr_edges,
-                                            // Might have to create gather mesh later
-                                            (create_gathers ? nLocalEdges + nEdges : nLocalEdges));
+                                                    // Might have to create gather mesh later
+                                                    (create_gathers ? nLocalEdges + nEdges : nLocalEdges));
   ERRORR(rval, "Couldn't create local edges in MPAS mesh.");
   Range local_edges_range(start_edge, start_edge + nLocalEdges - 1);
   tmp_range.insert(start_edge, start_edge + nLocalEdges - 1);
@@ -427,8 +427,9 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
 
     // Create cells and set connectivity array with proper local vertices handles
     EntityHandle* conn_arr_local_cells = NULL;
-    rval = _readNC->readMeshIface->get_element_connect(nLocalCells, maxEdgesPerCell, MBPOLYGON, 0, start_element,
-                                                       conn_arr_local_cells, nLocalCells);
+    rval = _readNC->readMeshIface->get_element_connect(nLocalCells, maxEdgesPerCell, MBPOLYGON, 0, start_element, conn_arr_local_cells,
+                                                      // Might have to create gather mesh later
+                                                      (create_gathers ? nLocalCells + nCells : nLocalCells));
     ERRORR(rval, "Couldn't create local cells in MPAS mesh.");
     Range local_cell_range(start_element, start_element + nLocalCells - 1);
     tmp_range.insert(start_element, start_element + nLocalCells - 1);
@@ -521,7 +522,7 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
 
     // Create gather vertices
     arrays.clear();
-    // Don't need to specify allocation number here, because we know enough verts were created before
+    // Don't need to specify allocation number here, because we know enough vertices were created before
     rval = _readNC->readMeshIface->get_node_coords(3, nVertices, 0, start_vertex, arrays);
     ERRORR(rval, "Couldn't create vertices in MPAS mesh for gather set.");
     Range gather_verts_range(start_vertex, start_vertex + nVertices - 1);
@@ -574,7 +575,6 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
 
     // Create gather edges
     EntityHandle* conn_arr_gather_edges;
-
     // Don't need to specify allocation number here, because we know enough edges were created before
     rval = _readNC->readMeshIface->get_element_connect(nEdges, 2, MBEDGE, 0, start_edge, conn_arr_gather_edges);
     ERRORR(rval, "Couldn't create edges in MPAS mesh for gather set.");
@@ -609,12 +609,13 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
 
     Range gather_cells_range;
     if (noMixedElements) {
-      // Create cells with maxEdgesPerCell vertices per element and set connectivity array
-      EntityHandle* conn_arr_gather_cells = NULL;
-      rval = _readNC->readMeshIface->get_element_connect(nCells, maxEdgesPerCell, MBPOLYGON, 0, start_element,
-                                                         conn_arr_gather_cells, nCells);
+      // Create gather cells
+      EntityHandle* conn_arr_gather_cells;
+      // Don't need to specify allocation number here, because we know enough cells were created before
+      rval = _readNC->readMeshIface->get_element_connect(nCells, maxEdgesPerCell, MBPOLYGON, 0, start_element, conn_arr_gather_cells);
       ERRORR(rval, "Couldn't create cells in MPAS mesh for gather set.");
       gather_cells_range.insert(start_element, start_element + nCells - 1);
+
       for (int cell_idx = 0; cell_idx < nCells; cell_idx++) {
         int num_edges = num_edges_on_gather_cells[cell_idx];
         for (int i = 0; i < num_edges; i++)
@@ -635,7 +636,7 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
         gather_cells_with_n_edges[num_edges].push_back(i + 1); // 0 based -> 1 based
       }
 
-      // For each non-empty cell group, create cells and set connectivity array
+      // Create gather cells
       EntityHandle* conn_arr_gather_cells_with_n_edges[MAX_EDGES_PER_CELL + 1];
       for (int num_edges_per_cell = 3; num_edges_per_cell <= maxEdgesPerCell; num_edges_per_cell++) {
         int num_cells = gather_cells_with_n_edges[num_edges_per_cell].size();

diff --git a/test/io/read_mpas_nc.cpp b/test/io/read_mpas_nc.cpp
index 0bc2d5a..cdef72d 100644
--- a/test/io/read_mpas_nc.cpp
+++ b/test/io/read_mpas_nc.cpp
@@ -1,5 +1,6 @@
 #include "TestUtil.hpp"
 #include "moab/Core.hpp"
+#include "moab/ReadUtilIface.hpp"
 
 using namespace moab;
 
@@ -54,8 +55,6 @@ int main(int argc, char* argv[])
 
 void test_read_all()
 {
-  const double eps = 1e-20;
-  double val[2];
   Core moab;
   Interface& mb = moab;
 
@@ -66,14 +65,6 @@ void test_read_all()
   rval = mb.load_file(example, NULL, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check tags for vertex variable vorticity
-  Tag vorticity_tag0, vorticity_tag1;
-  rval = mb.tag_get_handle("vorticity0", 1, MB_TYPE_DOUBLE, vorticity_tag0);
-  CHECK_ERR(rval);
-  rval = mb.tag_get_handle("vorticity1", 1, MB_TYPE_DOUBLE, vorticity_tag1);
-  CHECK_ERR(rval);
-
-  // Check values of tag T0 at some strategically chosen places below
   int procs = 1;
 #ifdef USE_MPI
   ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
@@ -82,6 +73,13 @@ void test_read_all()
 
   // Make check runs this test in one processor
   if (1 == procs) {
+    // Check tags for vertex variable vorticity
+    Tag vorticity_tag0, vorticity_tag1;
+    rval = mb.tag_get_handle("vorticity0", 1, MB_TYPE_DOUBLE, vorticity_tag0);
+    CHECK_ERR(rval);
+    rval = mb.tag_get_handle("vorticity1", 1, MB_TYPE_DOUBLE, vorticity_tag1);
+    CHECK_ERR(rval);
+
     // Get vertices (1280 edges)
     Range verts;
     rval = mb.get_entities_by_type(0, MBVERTEX, verts);
@@ -89,6 +87,9 @@ void test_read_all()
     CHECK_EQUAL((size_t)1280, verts.size());
     CHECK_EQUAL((size_t)1, verts.psize());
 
+    const double eps = 1e-20;
+    double val[2];
+
     // Check vorticity tag values on first two vertices
     EntityHandle vert_ents[] = {verts[0], verts[1]};
     rval = mb.tag_get_data(vorticity_tag0, &vert_ents[0], 2, val);
@@ -139,7 +140,7 @@ void test_read_all()
     // between the two face sequences.
     CHECK_EQUAL((size_t)2, cells.psize());
 #else
-  CHECK_EQUAL((size_t)1, cells.psize());
+    CHECK_EQUAL((size_t)1, cells.psize());
 #endif
 
     // Check ke tag values on first pentagon and first hexagon
@@ -162,15 +163,75 @@ void test_read_onevar()
   CHECK_ERR(rval);
 
   opts += std::string(";VARIABLE=ke");
+  // Create gather set
+  opts += std::string(";GATHER_SET=");
   rval = mb.load_file(example, NULL, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check for proper tags
-  Tag ke_tag0, ke_tag1;
-  rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
-  CHECK_ERR(rval);
-  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
-  CHECK_ERR(rval);
+  int procs = 1;
+#ifdef USE_MPI
+  ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  procs = pcomm->proc_config().proc_size();
+#endif
+
+  // Make check runs this test in one processor
+  if (1 == procs) {
+    // Check for proper tags
+    Tag ke_tag0, ke_tag1;
+    rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+    CHECK_ERR(rval);
+    rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+    CHECK_ERR(rval);
+
+    // Get cells (12 pentagons and 630 hexagons)
+    Range cells;
+    rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
+    assert(rval == MB_SUCCESS);
+    CHECK_EQUAL((size_t)1284, cells.size()); // Gather set cells included
+#ifdef USE_MPI
+    // If MOAB is compiled parallel, sequence size requested are increased
+    // by a factor of 1.5, to allow for ghosts. This will introduce a gap
+    // between the two face sequences.
+    CHECK_EQUAL((size_t)4, cells.psize()); // Gather set cells included
+#else
+    CHECK_EQUAL((size_t)2, cells.psize()); // Gather set cells included
+#endif
+
+    // Get gather set
+    EntityHandle gather_set;
+    ReadUtilIface* readUtilIface;
+    mb.query_interface(readUtilIface);
+    rval = readUtilIface->get_gather_set(gather_set);
+    CHECK_ERR(rval);
+
+    // Get gather set entities
+    Range gather_ents;
+    rval = mb.get_entities_by_handle(gather_set, gather_ents);
+    CHECK_ERR(rval);
+
+    // Remove gather set cells
+    cells = subtract(cells, gather_ents);
+    CHECK_EQUAL((size_t)642, cells.size()); // Gather set cells excluded
+#ifdef USE_MPI
+    // If MOAB is compiled parallel, sequence size requested are increased
+    // by a factor of 1.5, to allow for ghosts. This will introduce a gap
+    // between the two face sequences.
+    CHECK_EQUAL((size_t)2, cells.psize()); // Gather set cells excluded
+#else
+    CHECK_EQUAL((size_t)1, cells.psize()); // Gather set cells excluded
+#endif
+
+    // Check ke tag values on first pentagon and first hexagon
+    const double eps = 1e-20;
+    double val[2];
+    EntityHandle cell_ents[] = {cells[0], cells[12]};
+    rval = mb.tag_get_data(ke_tag0, &cell_ents[0], 2, val);
+    CHECK_REAL_EQUAL(1.5, val[0], eps);
+    CHECK_REAL_EQUAL(1.6, val[1], eps);
+    rval = mb.tag_get_data(ke_tag1, &cell_ents[0], 2, val);
+    CHECK_REAL_EQUAL(2.5, val[0], eps);
+    CHECK_REAL_EQUAL(2.6, val[1], eps);
+  }
 }
 
 void test_read_onetimestep()
@@ -210,7 +271,7 @@ void test_read_nomesh()
   opts = orig + std::string(";TIMESTEP=0");
   rval = mb.load_file(example, &set, opts.c_str());
   CHECK_ERR(rval);
-  
+
   // Check for proper tags
   Tag ke_tag0, ke_tag1;
   rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
@@ -287,13 +348,6 @@ void test_read_no_mixed_elements()
   rval = mb.load_file(example, NULL, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check for proper tags
-  Tag ke_tag0, ke_tag1;
-  rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
-  CHECK_ERR(rval);
-  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
-  CHECK_ERR(rval);
-
   int procs = 1;
 #ifdef USE_MPI
   ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
@@ -302,6 +356,13 @@ void test_read_no_mixed_elements()
 
   // Make check runs this test in one processor
   if (1 == procs) {
+    // Check for proper tags
+    Tag ke_tag0, ke_tag1;
+    rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+    CHECK_ERR(rval);
+    rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+    CHECK_ERR(rval);
+
     // Get cells (12 pentagons and 630 hexagons)
     Range cells;
     rval = mb.get_entities_by_type(0, MBPOLYGON, cells);

diff --git a/test/io/read_ucd_nc.cpp b/test/io/read_ucd_nc.cpp
index bd16ec4..12ca977 100644
--- a/test/io/read_ucd_nc.cpp
+++ b/test/io/read_ucd_nc.cpp
@@ -85,14 +85,6 @@ void test_read_onevar()
   rval = mb.load_file(example, NULL, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check for proper tags
-  Tag Ttag0, Ttag1;
-  rval = mb.tag_get_handle("T0", 26, MB_TYPE_DOUBLE, Ttag0);
-  CHECK_ERR(rval);
-
-  rval = mb.tag_get_handle("T1", 26, MB_TYPE_DOUBLE, Ttag1);
-  CHECK_ERR(rval);
-
   // Check values of tag T0 at some strategically chosen places below
   int procs = 1;
 #ifdef USE_MPI
@@ -102,6 +94,13 @@ void test_read_onevar()
 
   // Make check runs this test in one processor
   if (1 == procs) {
+    // Check for proper tags
+    Tag Ttag0, Ttag1;
+    rval = mb.tag_get_handle("T0", 26, MB_TYPE_DOUBLE, Ttag0);
+    CHECK_ERR(rval);
+    rval = mb.tag_get_handle("T1", 26, MB_TYPE_DOUBLE, Ttag1);
+    CHECK_ERR(rval);
+
     // Get vertices
     Range verts;
     rval = mb.get_entities_by_type(0, MBVERTEX, verts);
@@ -131,9 +130,10 @@ void test_read_onevar()
     CHECK_ERR(rval);
     CHECK_EQUAL((size_t)count, verts.size());
 
-    // Check first level values at some vertices
     const double eps = 0.0001;
     double* data = (double*) Tbuf;
+
+    // Check first level values at some vertices
     CHECK_REAL_EQUAL(233.1136, data[0 * 26], eps); // First vert
     CHECK_REAL_EQUAL(236.1505, data[1728 * 26], eps); // Median vert
     CHECK_REAL_EQUAL(235.7722, data[1729 * 26], eps); // Median vert

diff --git a/test/parallel/mpastrvpart.cpp b/test/parallel/mpastrvpart.cpp
index 5cacd2c..2b86f61 100644
--- a/test/parallel/mpastrvpart.cpp
+++ b/test/parallel/mpastrvpart.cpp
@@ -12,9 +12,11 @@ static const char example[] = STRINGIFY(MESHDIR) "/io/mpasx1.642.t.2.nc";
 #endif
 
 void test_read_parallel_mpas_trivial();
-void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool test_nb_edges);
-
+void test_read_parallel_mpas_trivial_no_mixed_elements();
+void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool test_nb_edges,
+                        int num_cells, bool test_nb_cells, bool mixed_elements);
 void test_multiple_loads_of_same_file();
+void test_multiple_loads_of_same_file_no_mixed_elements();
 
 std::string partition_method;
 
@@ -24,7 +26,9 @@ int main(int argc, char* argv[])
   int result = 0;
 
   result += RUN_TEST(test_read_parallel_mpas_trivial);
+  result += RUN_TEST(test_read_parallel_mpas_trivial_no_mixed_elements);
   result += RUN_TEST(test_multiple_loads_of_same_file);
+  result += RUN_TEST(test_multiple_loads_of_same_file_no_mixed_elements);
 
   MPI_Finalize();
   return result;
@@ -33,10 +37,17 @@ int main(int argc, char* argv[])
 void test_read_parallel_mpas_trivial()
 {
   partition_method = std::string(";PARTITION_METHOD=TRIVIAL;PARALLEL_RESOLVE_SHARED_ENTS");
-  test_read_parallel(1280, true, 1920, true);
+  test_read_parallel(1280, true, 1920, true, 642, true, true);
 }
-  
-void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool test_nb_edges)
+
+void test_read_parallel_mpas_trivial_no_mixed_elements()
+{
+  partition_method = std::string(";PARTITION_METHOD=TRIVIAL;PARALLEL_RESOLVE_SHARED_ENTS;NO_MIXED_ELEMENTS");
+  test_read_parallel(1280, true, 1920, true, 642, true, false);
+}
+
+void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool test_nb_edges,
+                        int num_cells, bool test_nb_cells, bool mixed_elements)
 {
   Core moab;
   Interface& mb = moab;
@@ -82,43 +93,6 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
       CHECK_EQUAL(160, my_verts_num); // Not owned vertices excluded
   }
 
-  if (0 == rank) {
-    // Get gather set
-    EntityHandle gather_set;
-    ReadUtilIface* readUtilIface;
-    rval = mb.query_interface(readUtilIface);
-    CHECK_ERR(rval);
-    rval = readUtilIface->get_gather_set(gather_set);
-    CHECK_ERR(rval);
-
-    // Get gather set entities
-    Range gather_ents;
-    rval = mb.get_entities_by_handle(gather_set, gather_ents);
-    CHECK_ERR(rval);
-
-    // Remove gather set vertices in processor 0
-    verts = subtract(verts, gather_ents);
-  }
-
-  my_verts_num = verts.size();
-  if (test_nb_nodes && 2 == procs) {
-    if (0 == rank)
-      CHECK_EQUAL(1120, my_verts_num); // Gather set vertices excluded
-    else if (1 == rank)
-      CHECK_EQUAL(160, my_verts_num); // Not owned vertices excluded
-  }
-
-  std::cout << "proc: " << rank << " verts:" << my_verts_num << "\n";
-
-  int total_verts;
-  MPI_Reduce(&my_verts_num, &total_verts, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
-  if (0 == rank)
-  {
-    std::cout << "total vertices: " << total_verts << "\n";
-    if (test_nb_nodes)
-      CHECK_EQUAL(total_verts, num_verts);
-  }
-
   // Get the total # owned edges
   Range edges;
   rval = mb.get_entities_by_type(0, MBEDGE, edges);
@@ -143,6 +117,44 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
       CHECK_EQUAL(482, my_edges_num); // Not owned edges excluded
   }
 
+  // Get the total # owned cells
+  Range cells;
+  rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
+  CHECK_ERR(rval);
+
+  int my_cells_num = cells.size();
+  if (test_nb_cells && 2 == procs) {
+    if (0 == rank) {
+      CHECK_EQUAL(963, my_cells_num); // Gather set cells included
+      if (mixed_elements)
+        CHECK_EQUAL((size_t)4, cells.psize()); // Gather set cells included
+      else
+        CHECK_EQUAL((size_t)1, cells.psize()); // Gather set cells included
+    }
+    else if (1 == rank) {
+      CHECK_EQUAL(321, my_cells_num); // Not owned cells included
+      CHECK_EQUAL((size_t)1, cells.psize()); // Not owned cells included
+    }
+  }
+
+   rval = pcomm->filter_pstatus(cells, PSTATUS_NOT_OWNED, PSTATUS_NOT);
+   CHECK_ERR(rval);
+
+   my_cells_num = cells.size();
+   if (test_nb_cells && 2 == procs) {
+     if (0 == rank) {
+       CHECK_EQUAL(963, my_cells_num); // Gather set cells included
+       if (mixed_elements)
+         CHECK_EQUAL((size_t)4, cells.psize()); // Gather set cells included
+       else
+         CHECK_EQUAL((size_t)1, cells.psize()); // Gather set cells included
+     }
+     else if (1 == rank) {
+       CHECK_EQUAL(321, my_cells_num); // Not owned cells excluded
+       CHECK_EQUAL((size_t)1, cells.psize()); // Not owned cells excluded
+     }
+   }
+
   if (0 == rank) {
     // Get gather set
     EntityHandle gather_set;
@@ -157,8 +169,32 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
     rval = mb.get_entities_by_handle(gather_set, gather_ents);
     CHECK_ERR(rval);
 
+    // Remove gather set vertices in processor 0
+    verts = subtract(verts, gather_ents);
+
     // Remove gather set edges in processor 0
     edges = subtract(edges, gather_ents);
+
+    // Remove gather set cells in processor 0
+    cells = subtract(cells, gather_ents);
+  }
+
+  my_verts_num = verts.size();
+  if (test_nb_nodes && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(1120, my_verts_num); // Gather set vertices excluded
+    else if (1 == rank)
+      CHECK_EQUAL(160, my_verts_num); // Not owned vertices excluded
+  }
+
+  std::cout << "proc: " << rank << " verts:" << my_verts_num << "\n";
+
+  int total_verts;
+  MPI_Reduce(&my_verts_num, &total_verts, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  if (0 == rank) {
+    std::cout << "total vertices: " << total_verts << "\n";
+    if (test_nb_nodes)
+      CHECK_EQUAL(total_verts, num_verts);
   }
 
   my_edges_num = edges.size();
@@ -173,13 +209,37 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
 
   int total_edges;
   MPI_Reduce(&my_edges_num, &total_edges, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
-  if (0 == rank)
-  {
+  if (0 == rank) {
     std::cout << "total edges: " << total_edges << "\n";
     if (test_nb_edges)
       CHECK_EQUAL(total_edges, num_edges);
   }
 
+  my_cells_num = cells.size();
+  if (test_nb_cells && 2 == procs) {
+    if (0 == rank) {
+      CHECK_EQUAL(321, my_cells_num); // Gather set cells excluded
+      if (mixed_elements)
+        CHECK_EQUAL((size_t)2, cells.psize()); // Gather set cells excluded
+      else
+        CHECK_EQUAL((size_t)1, cells.psize()); // Gather set cells excluded
+    }
+    else if (1 == rank) {
+      CHECK_EQUAL(321, my_cells_num); // Not owned cells excluded
+      CHECK_EQUAL((size_t)1, cells.psize()); // Not owned cells excluded
+    }
+  }
+
+   std::cout << "proc: " << rank << " cells:" << my_cells_num << "\n";
+
+   int total_cells;
+   MPI_Reduce(&my_cells_num, &total_cells, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+   if (0 == rank) {
+     std::cout << "total cells: " << total_cells << "\n";
+     if (test_nb_cells)
+       CHECK_EQUAL(total_cells, num_cells);
+   }
+
   std::string write_options("PARALLEL=WRITE_PART;");
   mb.write_file("test_mpas.h5m", NULL, write_options.c_str());
 }
@@ -220,13 +280,44 @@ void test_multiple_loads_of_same_file()
     rval = mb.get_entities_by_type(0, MBVERTEX, verts);
     CHECK_ERR(rval);
 
+    Range edges;
+    rval = mb.get_entities_by_type(0, MBEDGE, edges);
+    CHECK_ERR(rval);
+
+    Range cells;
+    rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
+    CHECK_ERR(rval);
+
     int my_verts_num = verts.size();
-    if (0 == rank)
+    int my_edges_num = edges.size();
+    int my_cells_num = cells.size();
+
+    if (0 == rank) {
       CHECK_EQUAL(1120, my_verts_num);
-    else if (1 == rank)
+      CHECK_EQUAL(1438, my_edges_num);
+      CHECK_EQUAL(321, my_cells_num);
+      CHECK_EQUAL((size_t)2, cells.psize());
+
+      const double eps = 1e-20;
+      double val[2];
+
+      // Check tag for cell variable ke at timestep 0
+      Tag ke_tag0;
+      rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+      CHECK_ERR(rval);
+
+      // Check ke0 tag values on first pentagon and first hexagon
+      EntityHandle cell_ents[] = {cells[0], cells[12]};
+      rval = mb.tag_get_data(ke_tag0, &cell_ents[0], 2, val);
+      CHECK_REAL_EQUAL(1.5, val[0], eps);
+      CHECK_REAL_EQUAL(1.6, val[1], eps);
+    }
+    else if (1 == rank) {
       CHECK_EQUAL(2402, my_verts_num); // Gather set vertices included; Not owned vertices included
+      CHECK_EQUAL(3364, my_edges_num); // Gather set edges included; Not owned edges included
+      CHECK_EQUAL(963, my_cells_num); // Gather set cells included; Not owned cells included
+      CHECK_EQUAL((size_t)3, cells.psize()); // Gather set cells included; Not owned cells included
 
-    if (1 == rank) {
       // Get gather set
       EntityHandle gather_set;
       ReadUtilIface* readUtilIface;
@@ -242,12 +333,125 @@ void test_multiple_loads_of_same_file()
 
       // Remove gather set vertices in processor 1
       verts = subtract(verts, gather_ents);
+      my_verts_num = verts.size();
+      CHECK_EQUAL(1122, my_verts_num); // Gather set vertices excluded; Not owned vertices included
+
+      // Remove gather set edges in processor 1
+      edges = subtract(edges, gather_ents);
+      my_edges_num = edges.size();
+      CHECK_EQUAL(1444, my_edges_num); // Gather set edges excluded; Not owned edges included
+
+      // Remove gather set cells in processor 1
+      cells = subtract(cells, gather_ents);
+      my_cells_num = cells.size();
+      CHECK_EQUAL(321, my_cells_num); // Gather set cells excluded; Not owned cells included
+      CHECK_EQUAL((size_t)1, cells.psize()); // Gather set cells excluded; Not owned cells included
     }
+  }
+}
 
-    my_verts_num = verts.size();
-    if (0 == rank)
+void test_multiple_loads_of_same_file_no_mixed_elements()
+{
+  Core moab;
+  Interface& mb = moab;
+  EntityHandle file_set;
+  ErrorCode rval;
+  rval = mb.create_meshset(MESHSET_SET, file_set);
+  CHECK_ERR(rval);
+
+  // Read first only header information, no mesh, no variable
+  std::string opts("PARALLEL=READ_PART;PARTITION;NOMESH;VARIABLE=;PARTITION_METHOD=TRIVIAL;NO_MIXED_ELEMENTS");
+  rval = mb.load_file(example, &file_set, opts.c_str());
+  CHECK_ERR(rval);
+
+  // Create mesh, no variable
+  opts="PARALLEL=READ_PART;PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION_METHOD=TRIVIAL;NO_MIXED_ELEMENTS;VARIABLE=";
+  // Create gather set in processor 1
+  opts += std::string(";GATHER_SET=1");
+  rval = mb.load_file(example, &file_set, opts.c_str());
+  CHECK_ERR(rval);
+
+  // Read variable ke at timestep 0, no mesh
+  opts = "PARALLEL=READ_PART;PARTITION;PARTITION_METHOD=TRIVIAL;NO_MIXED_ELEMENTS;NOMESH;VARIABLE=ke;TIMESTEP=0";
+  rval = mb.load_file(example, &file_set, opts.c_str());
+  CHECK_ERR(rval);
+
+  ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  int procs = pcomm->proc_config().proc_size();
+  int rank = pcomm->proc_config().proc_rank();
+
+  // Make check runs this test in two processors
+  if (2 == procs) {
+    Range verts;
+    rval = mb.get_entities_by_type(0, MBVERTEX, verts);
+    CHECK_ERR(rval);
+
+    Range edges;
+    rval = mb.get_entities_by_type(0, MBEDGE, edges);
+    CHECK_ERR(rval);
+
+    Range cells;
+    rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
+    CHECK_ERR(rval);
+
+    int my_verts_num = verts.size();
+    int my_edges_num = edges.size();
+    int my_cells_num = cells.size();
+
+    if (0 == rank) {
       CHECK_EQUAL(1120, my_verts_num);
-    else if (1 == rank)
+      CHECK_EQUAL(1438, my_edges_num);
+      CHECK_EQUAL(321, my_cells_num);
+      CHECK_EQUAL((size_t)1, cells.psize());
+
+      const double eps = 1e-20;
+      double val[2];
+
+      // Check tag for cell variable ke at timestep 0
+      Tag ke_tag0;
+      rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+      CHECK_ERR(rval);
+
+      // Check ke0 tag values on first pentagon and first hexagon
+      EntityHandle cell_ents[] = {cells[0], cells[12]};
+      rval = mb.tag_get_data(ke_tag0, &cell_ents[0], 2, val);
+      CHECK_REAL_EQUAL(1.5, val[0], eps);
+      CHECK_REAL_EQUAL(1.6, val[1], eps);
+    }
+    else if (1 == rank) {
+      CHECK_EQUAL(2402, my_verts_num); // Gather set vertices included; Not owned vertices included
+      CHECK_EQUAL(3364, my_edges_num); // Gather set edges included; Not owned edges included
+      CHECK_EQUAL(963, my_cells_num); // Gather set cells included; Not owned cells included
+      CHECK_EQUAL((size_t)1, cells.psize()); // Gather set cells included; Not owned cells included
+
+      // Get gather set
+      EntityHandle gather_set;
+      ReadUtilIface* readUtilIface;
+      rval = mb.query_interface(readUtilIface);
+      CHECK_ERR(rval);
+      rval = readUtilIface->get_gather_set(gather_set);
+      CHECK_ERR(rval);
+
+      // Get gather set entities
+      Range gather_ents;
+      rval = mb.get_entities_by_handle(gather_set, gather_ents);
+      CHECK_ERR(rval);
+
+      // Remove gather set vertices in processor 1
+      verts = subtract(verts, gather_ents);
+      my_verts_num = verts.size();
       CHECK_EQUAL(1122, my_verts_num); // Gather set vertices excluded; Not owned vertices included
+
+      // Remove gather set edges in processor 1
+      edges = subtract(edges, gather_ents);
+      my_edges_num = edges.size();
+      CHECK_EQUAL(1444, my_edges_num); // Gather set edges excluded; Not owned edges included
+
+      // Remove gather set cells in processor 1
+      cells = subtract(cells, gather_ents);
+      my_cells_num = cells.size();
+      CHECK_EQUAL(321, my_cells_num); // Gather set cells excluded; Not owned cells included
+      CHECK_EQUAL((size_t)1, cells.psize()); // Gather set cells excluded; Not owned cells included
+    }
   }
 }

diff --git a/test/parallel/ucdtrvpart.cpp b/test/parallel/ucdtrvpart.cpp
index 720df36..0800b4c 100644
--- a/test/parallel/ucdtrvpart.cpp
+++ b/test/parallel/ucdtrvpart.cpp
@@ -169,10 +169,9 @@ void test_multiple_loads_of_same_file()
     int my_num = verts.size();
     if (0 == rank)
       CHECK_EQUAL(1825, my_num);
-    else if (1 == rank)
+    else if (1 == rank) {
       CHECK_EQUAL(5283, my_num); // Gather set vertices included; Not owned vertices included
 
-    if (1 == rank) {
       // Get gather set
       EntityHandle gather_set;
       ReadUtilIface* readUtilIface;
@@ -188,13 +187,9 @@ void test_multiple_loads_of_same_file()
 
       // Remove gather set vertices in processor 1
       verts = subtract(verts, gather_ents);
-    }
-
-    my_num = verts.size();
-    if (0 == rank)
-      CHECK_EQUAL(1825, my_num);
-    else if (1 == rank)
+      my_num = verts.size();
       CHECK_EQUAL(1825, my_num); // Gather set vertices excluded; Not owned vertices included
+    }
 
     Tag Ttag0;
     rval = mb.tag_get_handle("T0", 26, MB_TYPE_DOUBLE, Ttag0, MB_TAG_DENSE);

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