[MOAB-dev] commit/MOAB: danwu: Update unit test read_mpas_nc to test NO_MIXED_ELEMENTS read option in serial mode.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Oct 4 14:43:21 CDT 2013
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/e63de1833d30/
Changeset: e63de1833d30
Branch: master
User: danwu
Date: 2013-10-04 21:43:08
Summary: Update unit test read_mpas_nc to test NO_MIXED_ELEMENTS read option in serial mode.
Affected #: 1 file
diff --git a/test/io/read_mpas_nc.cpp b/test/io/read_mpas_nc.cpp
index d442577..0bc2d5a 100644
--- a/test/io/read_mpas_nc.cpp
+++ b/test/io/read_mpas_nc.cpp
@@ -11,6 +11,7 @@ static const char example[] = "/io/mpasx1.642.t.2.nc";
#ifdef USE_MPI
#include "moab_mpi.h"
+#include "moab/ParallelComm.hpp"
#endif
void test_read_all();
@@ -18,6 +19,7 @@ void test_read_onevar();
void test_read_onetimestep();
void test_read_nomesh();
void test_read_novars();
+void test_read_no_mixed_elements();
ErrorCode get_options(std::string& opts);
@@ -30,7 +32,7 @@ int main(int argc, char* argv[])
if (fail)
return 1;
#else
- argv[0] = argv[argc-argc]; // To remove the warnings in serial mode about unused variables
+ argv[0] = argv[argc - argc]; // To remove the warnings in serial mode about unused variables
#endif
result += RUN_TEST(test_read_all);
@@ -38,6 +40,8 @@ int main(int argc, char* argv[])
result += RUN_TEST(test_read_onetimestep);
result += RUN_TEST(test_read_nomesh);
result += RUN_TEST(test_read_novars);
+ // Test read option NO_MIXED_ELEMENTS
+ result += RUN_TEST(test_read_no_mixed_elements);
#ifdef USE_MPI
fail = MPI_Finalize();
@@ -69,74 +73,84 @@ void test_read_all()
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);
- assert(rval == MB_SUCCESS);
- CHECK_EQUAL((size_t)1280, verts.size());
- CHECK_EQUAL((size_t)1, verts.psize());
-
- // 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);
- 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);
- CHECK_REAL_EQUAL(2.1, val[0], eps);
- CHECK_REAL_EQUAL(2.2, val[1], eps);
-
- // Check tags for edge variable u
- 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("u1", 1, MB_TYPE_DOUBLE, u_tag1);
- CHECK_ERR(rval);
-
- // Get edges (1920 edges)
- Range edges;
- rval = mb.get_entities_by_type(0, MBEDGE, edges);
- assert(rval == MB_SUCCESS);
- 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);
- 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);
- CHECK_REAL_EQUAL(2.113138721544778, val[0], eps);
- CHECK_REAL_EQUAL(-2.113138721930009, val[1], eps);
-
- // Check tags for cell variable ke
- 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);
+ // Check values of tag T0 at some strategically chosen places below
+ int procs = 1;
+#ifdef USE_MPI
+ ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+ procs = pcomm->proc_config().proc_size();
+#endif
- // 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)642, cells.size());
+ // Make check runs this test in one processor
+ if (1 == procs) {
+ // Get vertices (1280 edges)
+ Range verts;
+ rval = mb.get_entities_by_type(0, MBVERTEX, verts);
+ assert(rval == MB_SUCCESS);
+ CHECK_EQUAL((size_t)1280, verts.size());
+ CHECK_EQUAL((size_t)1, verts.psize());
+
+ // 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);
+ 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);
+ CHECK_REAL_EQUAL(2.1, val[0], eps);
+ CHECK_REAL_EQUAL(2.2, val[1], eps);
+
+ // Check tags for edge variable u
+ 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("u1", 1, MB_TYPE_DOUBLE, u_tag1);
+ CHECK_ERR(rval);
+
+ // Get edges (1920 edges)
+ Range edges;
+ rval = mb.get_entities_by_type(0, MBEDGE, edges);
+ assert(rval == MB_SUCCESS);
+ 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);
+ 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);
+ CHECK_REAL_EQUAL(2.113138721544778, val[0], eps);
+ CHECK_REAL_EQUAL(-2.113138721930009, val[1], eps);
+
+ // Check tags for cell variable ke
+ 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)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());
+ // 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 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);
- 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);
+ // 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(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_onevar()
@@ -261,6 +275,55 @@ void test_read_novars()
CHECK_ERR(rval);
}
+void test_read_no_mixed_elements()
+{
+ Core moab;
+ Interface& mb = moab;
+ std::string opts;
+ ErrorCode rval = get_options(opts);
+ CHECK_ERR(rval);
+
+ opts += std::string(";NO_MIXED_ELEMENTS;VARIABLE=ke");
+ 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) {
+ // 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)642, cells.size());
+ // Only one group of cells (each cell is actually represented by a 10-vertex polygon)
+ 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(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);
+ }
+}
+
ErrorCode get_options(std::string &opts)
{
#ifdef USE_MPI
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