[MOAB-dev] commit/MOAB: danwu: Update unit test read_mpas_nc for MPAS reader.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Nov 8 17:57:17 CST 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/f84d88d127b3/
Changeset:   f84d88d127b3
Branch:      master
User:        danwu
Date:        2013-11-09 00:56:47
Summary:     Update unit test read_mpas_nc for MPAS reader.

Affected #:  1 file

diff --git a/test/io/read_mpas_nc.cpp b/test/io/read_mpas_nc.cpp
index d6e886f..75923fd 100644
--- a/test/io/read_mpas_nc.cpp
+++ b/test/io/read_mpas_nc.cpp
@@ -25,7 +25,9 @@ void test_read_no_mixed_elements(); // Test read option NO_MIXED_ELEMENTS
 void test_read_no_edges(); // Test read option NO_EDGES
 void test_gather_onevar(); // Test gather set with one variable
 
-ErrorCode get_options(std::string& opts);
+void get_options(std::string& opts);
+
+const double eps = 1e-20;
 
 int main(int argc, char* argv[])
 {
@@ -63,10 +65,10 @@ void test_read_all()
   Interface& mb = moab;
 
   std::string opts;
-  ErrorCode rval = get_options(opts);
-  CHECK_ERR(rval);
+  get_options(opts);
 
-  rval = mb.load_file(example, NULL, opts.c_str());
+  // Read mesh and read all variables at all timesteps
+  ErrorCode rval = mb.load_file(example, NULL, opts.c_str());
   CHECK_ERR(rval);
 
   int procs = 1;
@@ -75,8 +77,11 @@ void test_read_all()
   procs = pcomm->proc_config().proc_size();
 #endif
 
-  // Make check runs this test in one processor
+  // Make check runs this test on one processor
   if (1 == procs) {
+    // For each tag, check two values
+    double val[2];
+
     // Check tags for vertex variable vorticity
     Tag vorticity_tag0, vorticity_tag1;
     rval = mb.tag_get_handle("vorticity0", 1, MB_TYPE_DOUBLE, vorticity_tag0);
@@ -87,19 +92,18 @@ void test_read_all()
     // Get vertices (1280 edges)
     Range verts;
     rval = mb.get_entities_by_type(0, MBVERTEX, verts);
-    assert(rval == MB_SUCCESS);
+    CHECK_ERR(rval);
     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);
+    rval = mb.tag_get_data(vorticity_tag0, vert_ents, 2, val);
+    CHECK_ERR(rval);
     CHECK_REAL_EQUAL(1.1, val[0], eps);
     CHECK_REAL_EQUAL(1.2, val[1], eps);
-    rval = mb.tag_get_data(vorticity_tag1, &vert_ents[0], 2, val);
+    rval = mb.tag_get_data(vorticity_tag1, vert_ents, 2, val);
+    CHECK_ERR(rval);
     CHECK_REAL_EQUAL(2.1, val[0], eps);
     CHECK_REAL_EQUAL(2.2, val[1], eps);
 
@@ -113,16 +117,18 @@ void test_read_all()
     // Get edges (1920 edges)
     Range edges;
     rval = mb.get_entities_by_type(0, MBEDGE, edges);
-    assert(rval == MB_SUCCESS);
+    CHECK_ERR(rval);
     CHECK_EQUAL((size_t)1920, edges.size());
     CHECK_EQUAL((size_t)1, edges.psize());
 
     // Check u tag values on two specified edges
     EntityHandle edge_ents[] = {edges[5], edges[6]};
-    rval = mb.tag_get_data(u_tag0, &edge_ents[0], 2, val);
+    rval = mb.tag_get_data(u_tag0, edge_ents, 2, val);
+    CHECK_ERR(rval);
     CHECK_REAL_EQUAL(1.113138721544778, val[0], eps);
     CHECK_REAL_EQUAL(-1.113138721930009, val[1], eps);
-    rval = mb.tag_get_data(u_tag1, &edge_ents[0], 2, val);
+    rval = mb.tag_get_data(u_tag1, edge_ents, 2, val);
+    CHECK_ERR(rval);
     CHECK_REAL_EQUAL(2.113138721544778, val[0], eps);
     CHECK_REAL_EQUAL(-2.113138721930009, val[1], eps);
 
@@ -136,7 +142,7 @@ void test_read_all()
     // Get cells (12 pentagons and 630 hexagons)
     Range cells;
     rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
-    assert(rval == MB_SUCCESS);
+    CHECK_ERR(rval);
     CHECK_EQUAL((size_t)642, cells.size());
 #ifdef USE_MPI
     // If MOAB is compiled parallel, sequence size requested are increased
@@ -149,10 +155,12 @@ void test_read_all()
 
     // Check ke 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);
+    rval = mb.tag_get_data(ke_tag0, cell_ents, 2, val);
+    CHECK_ERR(rval);
     CHECK_REAL_EQUAL(15.001, val[0], eps);
     CHECK_REAL_EQUAL(16.013, val[1], eps);
-    rval = mb.tag_get_data(ke_tag1, &cell_ents[0], 2, val);
+    rval = mb.tag_get_data(ke_tag1, cell_ents, 2, val);
+    CHECK_ERR(rval);
     CHECK_REAL_EQUAL(25.001, val[0], eps);
     CHECK_REAL_EQUAL(26.013, val[1], eps);
   }
@@ -162,12 +170,13 @@ void test_read_onevar()
 {
   Core moab;
   Interface& mb = moab;
+
   std::string opts;
-  ErrorCode rval = get_options(opts);
-  CHECK_ERR(rval);
+  get_options(opts);
 
-  opts += std::string(";VARIABLE=ke");
-  rval = mb.load_file(example, NULL, opts.c_str());
+  // Read mesh and read cell variable ke at all timesteps
+  opts += ";VARIABLE=ke";
+  ErrorCode rval = mb.load_file(example, NULL, opts.c_str());
   CHECK_ERR(rval);
 
   int procs = 1;
@@ -176,9 +185,9 @@ void test_read_onevar()
   procs = pcomm->proc_config().proc_size();
 #endif
 
-  // Make check runs this test in one processor
+  // Make check runs this test on one processor
   if (1 == procs) {
-    // Check for proper tags
+    // Check ke tags
     Tag ke_tag0, ke_tag1;
     rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
     CHECK_ERR(rval);
@@ -188,7 +197,7 @@ void test_read_onevar()
     // Get cells (12 pentagons and 630 hexagons)
     Range cells;
     rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
-    assert(rval == MB_SUCCESS);
+    CHECK_ERR(rval);
     CHECK_EQUAL((size_t)642, cells.size());
 
 #ifdef USE_MPI
@@ -200,16 +209,23 @@ void test_read_onevar()
     CHECK_EQUAL((size_t)1, cells.psize());
 #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(15.001, val[0], eps);
-    CHECK_REAL_EQUAL(16.013, val[1], eps);
-    rval = mb.tag_get_data(ke_tag1, &cell_ents[0], 2, val);
-    CHECK_REAL_EQUAL(25.001, val[0], eps);
-    CHECK_REAL_EQUAL(26.013, val[1], eps);
+    // Check ke tag values on 4 cells: first pentagon, last pentagon,
+    // first hexagon, and last hexagon
+    EntityHandle cell_ents[] = {cells[0], cells[11], cells[12], cells[641]};
+    double ke0_val[4];
+    rval = mb.tag_get_data(ke_tag0, cell_ents, 4, ke0_val);
+    CHECK_ERR(rval);
+    CHECK_REAL_EQUAL(15.001, ke0_val[0], eps);
+    CHECK_REAL_EQUAL(15.012, ke0_val[1], eps);
+    CHECK_REAL_EQUAL(16.013, ke0_val[2], eps);
+    CHECK_REAL_EQUAL(16.642, ke0_val[3], eps);
+    double ke1_val[4];
+    rval = mb.tag_get_data(ke_tag1, cell_ents, 4, ke1_val);
+    CHECK_ERR(rval);
+    CHECK_REAL_EQUAL(25.001, ke1_val[0], eps);
+    CHECK_REAL_EQUAL(25.012, ke1_val[1], eps);
+    CHECK_REAL_EQUAL(26.013, ke1_val[2], eps);
+    CHECK_REAL_EQUAL(26.642, ke1_val[3], eps);
   }
 }
 
@@ -217,19 +233,21 @@ void test_read_onetimestep()
 {
   Core moab;
   Interface& mb = moab;
+
   std::string opts;
-  ErrorCode rval = get_options(opts);
-  CHECK_ERR(rval);
+  get_options(opts);
 
-  opts += std::string(";TIMESTEP=1");
-  rval = mb.load_file(example, NULL, opts.c_str());
+  // Read mesh and read all variables at 2nd timestep
+  opts += ";TIMESTEP=1";
+  ErrorCode 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 vorticity tags
+  Tag vorticity_tag0, vorticity_tag1;
+  rval = mb.tag_get_handle("vorticity0", 1, MB_TYPE_DOUBLE, vorticity_tag0);
+  // Tag vorticity0 should not exist
   CHECK_EQUAL(rval, MB_TAG_NOT_FOUND);
-  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+  rval = mb.tag_get_handle("vorticity1", 1, MB_TYPE_DOUBLE, vorticity_tag1);
   CHECK_ERR(rval);
 }
 
@@ -238,33 +256,35 @@ void test_read_nomesh()
   Core moab;
   Interface& mb = moab;
 
-  // Need a set for nomesh to work right
-  EntityHandle set;
-  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
+  // Need a file set for nomesh to work right
+  EntityHandle file_set;
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, file_set);
   CHECK_ERR(rval);
 
   std::string orig, opts;
-  rval = get_options(orig);
-  CHECK_ERR(rval);
+  get_options(orig);
 
-  opts = orig + std::string(";TIMESTEP=0");
-  rval = mb.load_file(example, &set, opts.c_str());
+  // Read mesh and read all variables at 1st timestep
+  opts = orig + ";TIMESTEP=0";
+  rval = mb.load_file(example, &file_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);
+  // Check u tags
+  Tag u_tag0, u_tag1;
+  rval = mb.tag_get_handle("u0", 1, MB_TYPE_DOUBLE, u_tag0);
   CHECK_ERR(rval);
-  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+  // Tag u1 should not exist
+  rval = mb.tag_get_handle("u1", 1, MB_TYPE_DOUBLE, u_tag1);
   CHECK_EQUAL(rval, MB_TAG_NOT_FOUND);
 
-  // Now read 2nd timestep with nomesh option
-  opts = orig + std::string(";TIMESTEP=1;NOMESH");
-  rval = mb.load_file(example, &set, opts.c_str());
+  // Read all variables at 2nd timestep 0, no need to read mesh
+  opts = orig + ";TIMESTEP=1;NOMESH";
+  rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check for proper tag
-  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+  // Check tag u1 again
+  rval = mb.tag_get_handle("u1", 1, MB_TYPE_DOUBLE, u_tag1);
+  // Tag u1 should exist at this time
   CHECK_ERR(rval);
 }
 
@@ -273,58 +293,111 @@ void test_read_novars()
   Core moab;
   Interface& mb = moab;
 
-  // Need a set for nomesh to work right
-  EntityHandle set;
-  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
+  // Need a file set for nomesh to work right
+  EntityHandle file_set;
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, file_set);
   CHECK_ERR(rval);
 
   std::string orig, opts;
-  rval = get_options(orig);
+  get_options(orig);
   CHECK_ERR(rval);
 
-  opts = orig + std::string(";NOMESH;VARIABLE=");
-  rval = mb.load_file(example, &set, opts.c_str());
+  // Read header info only, no mesh, no variables
+  opts = orig + ";NOMESH;VARIABLE=";
+  rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
-  opts = orig + std::string(";VARIABLE=;TIMESTEP=0");
-  rval = mb.load_file(example, &set, opts.c_str());
+  // Read mesh, but still no variables
+  opts = orig + ";VARIABLE=;TIMESTEP=0";
+  rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check for proper tag
+  // Check ke tags
   Tag ke_tag0, ke_tag1;
   rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+  // Tag ke0 should not exist
+  CHECK_EQUAL(rval, MB_TAG_NOT_FOUND);
+  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+  // Tag ke1 should not exist
   CHECK_EQUAL(rval, MB_TAG_NOT_FOUND);
 
-  opts = orig + std::string(";VARIABLE=ke;TIMESTEP=0;NOMESH");
-  rval = mb.load_file(example, &set, opts.c_str());
+  // Read ke at 1st timestep, no need to read mesh
+  opts = orig + ";VARIABLE=ke;TIMESTEP=0;NOMESH";
+  rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check for proper tags
+  // Check ke tags again
   rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+  // Tag ke0 should exist at this time
   CHECK_ERR(rval);
+  // Tag ke1 should still not exist
   rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
   CHECK_EQUAL(rval, MB_TAG_NOT_FOUND);
 
-  // Now read 2nd timestep with nomesh option
-  opts = orig + std::string(";VARIABLE=ke;TIMESTEP=1;NOMESH");
-  rval = mb.load_file(example, &set, opts.c_str());
+  // Read ke at 2nd timestep, no need to read mesh
+  opts = orig + ";VARIABLE=ke;TIMESTEP=1;NOMESH";
+  rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
-  // Check for proper tag
+  // Check tag ke1 again
   rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+  // Tag ke1 should exist at this time
   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 on one processor
+  if (1 == procs) {
+    // Get cells (12 pentagons and 630 hexagons)
+    Range cells;
+    rval = mb.get_entities_by_type(file_set, MBPOLYGON, cells);
+    CHECK_ERR(rval);
+    CHECK_EQUAL((size_t)642, cells.size());
+
+#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());
+#else
+    CHECK_EQUAL((size_t)1, cells.psize());
+#endif
+
+    // Check ke tag values on 4 cells: first pentagon, last pentagon,
+    // first hexagon, and last hexagon
+    EntityHandle cell_ents[] = {cells[0], cells[11], cells[12], cells[641]};
+    double ke0_val[4];
+    rval = mb.tag_get_data(ke_tag0, cell_ents, 4, ke0_val);
+    CHECK_ERR(rval);
+    CHECK_REAL_EQUAL(15.001, ke0_val[0], eps);
+    CHECK_REAL_EQUAL(15.012, ke0_val[1], eps);
+    CHECK_REAL_EQUAL(16.013, ke0_val[2], eps);
+    CHECK_REAL_EQUAL(16.642, ke0_val[3], eps);
+    double ke1_val[4];
+    rval = mb.tag_get_data(ke_tag1, cell_ents, 4, ke1_val);
+    CHECK_ERR(rval);
+    CHECK_REAL_EQUAL(25.001, ke1_val[0], eps);
+    CHECK_REAL_EQUAL(25.012, ke1_val[1], eps);
+    CHECK_REAL_EQUAL(26.013, ke1_val[2], eps);
+    CHECK_REAL_EQUAL(26.642, ke1_val[3], eps);
+  }
 }
 
 void test_read_no_mixed_elements()
 {
   Core moab;
   Interface& mb = moab;
+
   std::string opts;
-  ErrorCode rval = get_options(opts);
-  CHECK_ERR(rval);
+  get_options(opts);
 
-  opts += std::string(";NO_MIXED_ELEMENTS;VARIABLE=ke");
-  rval = mb.load_file(example, NULL, opts.c_str());
+  // Read mesh with no mixed elements and read all variables at all timesteps
+  opts += ";NO_MIXED_ELEMENTS";
+  ErrorCode rval = mb.load_file(example, NULL, opts.c_str());
   CHECK_ERR(rval);
 
   int procs = 1;
@@ -333,9 +406,9 @@ void test_read_no_mixed_elements()
   procs = pcomm->proc_config().proc_size();
 #endif
 
-  // Make check runs this test in one processor
+  // Make check runs this test on one processor
   if (1 == procs) {
-    // Check for proper tags
+    // Check ke tags
     Tag ke_tag0, ke_tag1;
     rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
     CHECK_ERR(rval);
@@ -345,23 +418,29 @@ void test_read_no_mixed_elements()
     // Get cells (12 pentagons and 630 hexagons)
     Range cells;
     rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
-    assert(rval == MB_SUCCESS);
+    CHECK_ERR(rval);
     CHECK_EQUAL((size_t)642, cells.size());
     // Only one group of cells (pentagons are padded to hexagons,
     // e.g. connectivity [1 2 3 4 5] => [1 2 3 4 5 5])
     CHECK_EQUAL((size_t)1, cells.psize());
 
-    const double eps = 1e-20;
-    double val[2];
-
-    // Check ke 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(15.001, val[0], eps);
-    CHECK_REAL_EQUAL(16.013, val[1], eps);
-    rval = mb.tag_get_data(ke_tag1, &cell_ents[0], 2, val);
-    CHECK_REAL_EQUAL(25.001, val[0], eps);
-    CHECK_REAL_EQUAL(26.013, val[1], eps);
+    // Check ke tag values on 4 cells: first pentagon, last pentagon,
+    // first hexagon, and last hexagon
+    EntityHandle cell_ents[] = {cells[0], cells[11], cells[12], cells[641]};
+    double ke0_val[4];
+    rval = mb.tag_get_data(ke_tag0, cell_ents, 4, ke0_val);
+    CHECK_ERR(rval);
+    CHECK_REAL_EQUAL(15.001, ke0_val[0], eps);
+    CHECK_REAL_EQUAL(15.012, ke0_val[1], eps);
+    CHECK_REAL_EQUAL(16.013, ke0_val[2], eps);
+    CHECK_REAL_EQUAL(16.642, ke0_val[3], eps);
+    double ke1_val[4];
+    rval = mb.tag_get_data(ke_tag1, cell_ents, 4, ke1_val);
+    CHECK_ERR(rval);
+    CHECK_REAL_EQUAL(25.001, ke1_val[0], eps);
+    CHECK_REAL_EQUAL(25.012, ke1_val[1], eps);
+    CHECK_REAL_EQUAL(26.013, ke1_val[2], eps);
+    CHECK_REAL_EQUAL(26.642, ke1_val[3], eps);
   }
 }
 
@@ -369,107 +448,98 @@ void test_read_no_edges()
 {
   Core moab;
   Interface& mb = moab;
+
   std::string opts;
-  ErrorCode rval = get_options(opts);
-  CHECK_ERR(rval);
+  get_options(opts);
 
-  opts += std::string(";NO_EDGES;VARIABLE=");
-  rval = mb.load_file(example, NULL, opts.c_str());
+  opts += ";NO_EDGES;VARIABLE=";
+  ErrorCode rval = mb.load_file(example, NULL, opts.c_str());
   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) {
-    // Get edges
-    Range edges;
-    rval = mb.get_entities_by_type(0, MBEDGE, edges);
-    assert(rval == MB_SUCCESS);
-    CHECK_EQUAL((size_t)0, edges.size());
-  }
+  // Get edges
+  Range edges;
+  rval = mb.get_entities_by_type(0, MBEDGE, edges);
+  CHECK_ERR(rval);
+  CHECK_EQUAL((size_t)0, edges.size());
 }
 
 void test_gather_onevar()
 {
   Core moab;
   Interface& mb = moab;
-  std::string opts;
-  ErrorCode rval = get_options(opts);
-  CHECK_ERR(rval);
 
   EntityHandle file_set;
-  rval = mb.create_meshset(MESHSET_SET, file_set);
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, file_set);
   CHECK_ERR(rval);
 
-  // Get cell variable ke
-  opts += std::string(";VARIABLE=ke;");
-  // Create gather set
-  opts += std::string(";GATHER_SET=0;");
+  std::string opts;
+  get_options(opts);
+
+  // Read cell variable ke and create gather set on processor 0
+  opts += ";VARIABLE=ke;GATHER_SET=0";
   rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
 #ifdef USE_MPI
   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 one processor
-  if (1 == procs) {
-    Range cells, cells_owned;
-    rval = mb.get_entities_by_type(file_set, MBPOLYGON, cells);
-    CHECK_ERR(rval);
+  Range cells, cells_owned;
+  rval = mb.get_entities_by_type(file_set, MBPOLYGON, cells);
+  CHECK_ERR(rval);
 
-    // Get locally owned cells
-    rval = pcomm->filter_pstatus(cells, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &cells_owned);
-    CHECK_ERR(rval);
-    CHECK_EQUAL((size_t)642, cells_owned.size());
-    CHECK_EQUAL((size_t)2, cells_owned.psize());
+  // Get local owned cells
+  rval = pcomm->filter_pstatus(cells, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &cells_owned);
+  CHECK_ERR(rval);
 
+  EntityHandle gather_set = 0;
+  if (0 == rank) {
     // Get gather set
-    EntityHandle gather_set;
     ReadUtilIface* readUtilIface;
     mb.query_interface(readUtilIface);
     rval = readUtilIface->get_gather_set(gather_set);
     CHECK_ERR(rval);
+    assert(gather_set != 0);
+  }
 
-    Tag ke_tag0, gid_tag;
-    rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0, MB_TAG_DENSE);
-    CHECK_ERR(rval);
+  Tag ke_tag0, gid_tag;
+  rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0, MB_TAG_DENSE);
+  CHECK_ERR(rval);
 
-    rval = mb.tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, gid_tag, MB_TAG_DENSE);
-    CHECK_ERR(rval);
+  rval = mb.tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, gid_tag, MB_TAG_DENSE);
+  CHECK_ERR(rval);
 
-    pcomm->gather_data(cells_owned, ke_tag0, gid_tag, gather_set);
+  pcomm->gather_data(cells_owned, ke_tag0, gid_tag, gather_set, 0);
 
+  if (0 == rank) {
     // Get gather set cells
     Range gather_set_cells;
     rval = mb.get_entities_by_type(gather_set, MBPOLYGON, gather_set_cells);
+    CHECK_ERR(rval);
     CHECK_EQUAL((size_t)642, gather_set_cells.size());
     CHECK_EQUAL((size_t)2, gather_set_cells.psize());
 
-    const double eps = 1e-20;
-    double val[2];
-
-    // Check ke0 tag values on first pentagon and first hexagon of the gather set cells
-    EntityHandle cell_ents[] = {gather_set_cells[0], gather_set_cells[12]};
-    rval = mb.tag_get_data(ke_tag0, &cell_ents[0], 2, val);
-    CHECK_REAL_EQUAL(15.001, val[0], eps);
-    CHECK_REAL_EQUAL(16.013, val[1], eps);
+    // Check ke0 tag values on 4 gather set cells: first pentagon, last pentagon,
+    // first hexagon, and last hexagon
+    double ke0_val[4];
+    EntityHandle cell_ents[] = {gather_set_cells[0], gather_set_cells[11],
+                                gather_set_cells[12], gather_set_cells[641]};
+    rval = mb.tag_get_data(ke_tag0, cell_ents, 4, ke0_val);
+    CHECK_ERR(rval);
+    CHECK_REAL_EQUAL(15.001, ke0_val[0], eps);
+    CHECK_REAL_EQUAL(15.012, ke0_val[1], eps);
+    CHECK_REAL_EQUAL(16.013, ke0_val[2], eps);
+    CHECK_REAL_EQUAL(16.642, ke0_val[3], eps);
   }
 #endif
 }
 
-ErrorCode get_options(std::string& opts)
+void get_options(std::string& opts)
 {
 #ifdef USE_MPI
   // Use parallel options
   opts = std::string(";;PARALLEL=READ_PART;PARTITION_METHOD=TRIVIAL");
-  return MB_SUCCESS;
 #else
   opts = std::string(";;");
-  return MB_SUCCESS;
 #endif
 }

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