[MOAB-dev] commit/MOAB: danwu: Updated NC reader unit test to check tag values of GCRM variable pressure.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Jun 3 10:43:07 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/a5ddba111639/
Changeset:   a5ddba111639
Branch:      master
User:        danwu
Date:        2014-06-03 17:42:53
Summary:     Updated NC reader unit test to check tag values of GCRM variable pressure.

Affected #:  1 file

diff --git a/test/io/read_gcrm_nc.cpp b/test/io/read_gcrm_nc.cpp
index 91608f2..35d6bcb 100644
--- a/test/io/read_gcrm_nc.cpp
+++ b/test/io/read_gcrm_nc.cpp
@@ -28,6 +28,7 @@ void get_options(std::string& opts);
 
 const double eps = 1e-6;
 const int layers = 3;
+const int interfaces = 3;
 
 int main(int argc, char* argv[])
 {
@@ -80,8 +81,7 @@ void test_read_all()
 
   // Make check runs this test on one processor
   if (1 == procs) {
-    // For each tag, check values on two entities
-    // There are 256 layers, only check on first two
+    // For u, wind and vorticity, check tag values on two entities
     double val[2 * layers];
 
     // Check tags for vertex variable u
@@ -91,7 +91,7 @@ void test_read_all()
     rval = mb.tag_get_handle("u1", layers, MB_TYPE_DOUBLE, u_tag1);
     CHECK_ERR(rval);
 
-    // Get vertices (1280 edges)
+    // Get vertices (1280 vertices)
     Range verts;
     rval = mb.get_entities_by_type(0, MBVERTEX, verts);
     CHECK_ERR(rval);
@@ -101,6 +101,7 @@ void test_read_all()
     // Check u tag values on first and last vertices
     EntityHandle vert_ents[] = {verts[0], verts[1279]};
 
+    // Only check first two layers
     // Timestep 0
     rval = mb.tag_get_data(u_tag0, vert_ents, 2, val);
     CHECK_ERR(rval);
@@ -138,6 +139,7 @@ void test_read_all()
     // Check wind tag values on first and last edges
     EntityHandle edge_ents[] = {edges[0], edges[1919]};
 
+    // Only check first two layers
     // Timestep 0
     rval = mb.tag_get_data(wind_tag0, edge_ents, 2, val);
     CHECK_ERR(rval);
@@ -177,6 +179,7 @@ void test_read_all()
     // Check vorticity tag values on first and last cells
     EntityHandle cell_ents[] = {cells[0], cells[641]};
 
+    // Only check first two layers
     // Timestep 0
     rval = mb.tag_get_data(vorticity_tag0, cell_ents, 2, val);
     CHECK_ERR(rval);
@@ -196,6 +199,38 @@ void test_read_all()
     // Layer 1
     CHECK_REAL_EQUAL(3.534306, val[0 * layers + 1], eps);
     CHECK_REAL_EQUAL(-0.540262, val[1 * layers + 1], eps);
+
+    // Check tags for cell variable pressure
+    Tag pressure_tag0, pressure_tag1;
+    rval = mb.tag_get_handle("pressure0", interfaces, MB_TYPE_DOUBLE, pressure_tag0);
+    CHECK_ERR(rval);
+    rval = mb.tag_get_handle("pressure1", interfaces, MB_TYPE_DOUBLE, pressure_tag1);
+    CHECK_ERR(rval);
+
+    // For pressure, check tag values on two cells
+    double pressure_val[2 * interfaces];
+
+    // Check pressure tag values on first and last cells
+    // Only check first two interfaces
+    // Timestep 0
+    rval = mb.tag_get_data(pressure_tag0, cell_ents, 2, pressure_val);
+    CHECK_ERR(rval);
+    // Interface 0
+    CHECK_REAL_EQUAL(4.44234e-06, pressure_val[0 * interfaces], 1e-11);
+    CHECK_REAL_EQUAL(0.2486804, pressure_val[1 * interfaces], 1e-7);
+    // Interface 1
+    CHECK_REAL_EQUAL(4.44234e-06, pressure_val[0 * interfaces + 1], 1e-11);
+    CHECK_REAL_EQUAL(0.2486804, pressure_val[1 * interfaces + 1], 1e-7);
+
+    // Timestep 1
+    rval = mb.tag_get_data(pressure_tag1, cell_ents, 2, pressure_val);
+    CHECK_ERR(rval);
+    // Interface 0
+    CHECK_REAL_EQUAL(2.365176e-07, pressure_val[0 * interfaces], 1e-13);
+    CHECK_REAL_EQUAL(0.02234409, pressure_val[1 * interfaces], 1e-8);
+    // Interface 1
+    CHECK_REAL_EQUAL(2.365176e-07, pressure_val[0 * interfaces + 1], 1e-13);
+    CHECK_REAL_EQUAL(0.02234409, pressure_val[1 * interfaces + 1], 1e-8);
   }
 }
 
@@ -238,9 +273,9 @@ void test_read_onevar()
 
     // Check vorticity tag values on 4 cells: first cell, two median cells, and last cell
     EntityHandle cell_ents[] = {cells[0], cells[320], cells[321], cells[641]};
-    // There are 256 layers, only check on first two
     double vorticity_val[4 * layers];
 
+    // Only check first two layers
     // Timestep 0
     rval = mb.tag_get_data(vorticity_tag0, cell_ents, 4, vorticity_val);
     CHECK_ERR(rval);
@@ -405,9 +440,9 @@ void test_read_novars()
 
     // Check vorticity tag values on 4 cells: first cell, two median cells, and last cell
     EntityHandle cell_ents[] = {cells[0], cells[320], cells[321], cells[641]};
-    // There are 256 layers, only check on first two
     double vorticity_val[4 * layers];
 
+    // Only check first two layers
     // Timestep 0
     rval = mb.tag_get_data(vorticity_tag0, cell_ents, 4, vorticity_val);
     CHECK_ERR(rval);

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