[MOAB-dev] commit/MOAB: danwu: Added two test cases to write_nc for CAM-SE (HOMME). NC writer will be updated later to make them pass.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Apr 14 11:59:47 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/2fb4dfece902/
Changeset:   2fb4dfece902
Branch:      ncwriter
User:        danwu
Date:        2014-04-14 18:59:16
Summary:     Added two test cases to write_nc for CAM-SE (HOMME). NC writer will be updated later to make them pass.

Affected #:  1 file

diff --git a/test/io/write_nc.cpp b/test/io/write_nc.cpp
index de42ae7..72256e5 100644
--- a/test/io/write_nc.cpp
+++ b/test/io/write_nc.cpp
@@ -6,8 +6,10 @@ using namespace moab;
 
 #ifdef MESHDIR
 static const char example_eul[] = STRINGIFY(MESHDIR) "/io/camEul26x48x96.t3.nc";
+static const char example_homme[] = STRINGIFY(MESHDIR) "/io/homme26x3458.t.3.nc";
 #else
 static const char example_eul[] = "/io/camEul26x48x96.t3.nc";
+static const char example_homme[] = "/io/homme26x3458.t.3.nc";
 #endif
 
 #ifdef USE_MPI
@@ -16,10 +18,15 @@ static const char example_eul[] = "/io/camEul26x48x96.t3.nc";
 #endif
 
 // CAM-EUL
-void test_read_write_T_gw();
-void test_check_T_gw_values();
+void test_eul_read_write_T_gw();
+void test_eul_check_T_gw_values();
 
-ErrorCode get_options(std::string& opts);
+// CAM-SE (HOMME)
+void test_homme_read_write_T();
+void test_homme_check_T_values();
+
+void get_eul_options(std::string& opts);
+void get_homme_options(std::string& opts);
 
 int main(int argc, char* argv[])
 {
@@ -33,8 +40,10 @@ int main(int argc, char* argv[])
   argv[0] = argv[argc - argc]; // To remove the warnings in serial mode about unused variables
 #endif
 
-  result += RUN_TEST(test_read_write_T_gw);
-  result += RUN_TEST(test_check_T_gw_values);
+  result += RUN_TEST(test_eul_read_write_T_gw);
+  result += RUN_TEST(test_eul_check_T_gw_values);
+  //result += RUN_TEST(test_homme_read_write_T);
+  //result += RUN_TEST(test_homme_check_T_values);
 
 #ifdef USE_MPI
   fail = MPI_Finalize();
@@ -45,17 +54,16 @@ int main(int argc, char* argv[])
   return result;
 }
 
-void test_read_write_T_gw()
+void test_eul_read_write_T_gw()
 {
   Core moab;
   Interface& mb = moab;
 
   std::string orig;
-  ErrorCode rval = get_options(orig);
-  CHECK_ERR(rval);
+  get_eul_options(orig);
 
   EntityHandle set;
-  rval = mb.create_meshset(MESHSET_SET, set);
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
   CHECK_ERR(rval);
 
   // Load non-set variable T, set variable gw, and the mesh
@@ -67,26 +75,25 @@ void test_read_write_T_gw()
   // To load the output file with mesh, variable gw is required
   std::string writeopts;
   writeopts = std::string(";;VARIABLE=T,gw;DEBUG_IO=2;");
-  rval = mb.write_file("testTgw.nc", 0, writeopts.c_str(), &set, 1);
+  rval = mb.write_file("test_eul_T_gw.nc", 0, writeopts.c_str(), &set, 1);
   CHECK_ERR(rval);
 }
 
-void test_check_T_gw_values()
+void test_eul_check_T_gw_values()
 {
   Core moab;
   Interface& mb = moab;
 
   std::string opts;
-  ErrorCode rval = get_options(opts);
-  CHECK_ERR(rval);
+  get_eul_options(opts);
 
   EntityHandle set;
-  rval = mb.create_meshset(MESHSET_SET, set);
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
   CHECK_ERR(rval);
 
   // Load non-set variable T, set variable gw, and the mesh
   opts += std::string(";VARIABLE=T,gw");
-  rval = mb.load_file("testTgw.nc", &set, opts.c_str());
+  rval = mb.load_file("test_eul_T_gw.nc", &set, opts.c_str());
   CHECK_ERR(rval);
 
   int procs = 1;
@@ -120,7 +127,7 @@ void test_check_T_gw_values()
     rval = mb.tag_get_handle("T0", 26, MB_TYPE_DOUBLE, Ttag0);
     CHECK_ERR(rval);
 
-    // Check some values of tag T0
+    // Check some values of tag T0 on first level
     double val[4 * 26];
     Range global_quads;
     rval = mb.get_entities_by_type(set, MBQUAD, global_quads);
@@ -137,14 +144,99 @@ void test_check_T_gw_values()
   }
 }
 
-ErrorCode get_options(std::string& opts)
+void test_homme_read_write_T()
+{
+  Core moab;
+  Interface& mb = moab;
+
+  std::string orig;
+  get_homme_options(orig);
+
+  EntityHandle set;
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
+  CHECK_ERR(rval);
+
+  // Load non-set variable T and the mesh
+  std::string opts = orig + std::string(";DEBUG_IO=0;VARIABLE=T");
+  rval = mb.load_file(example_homme, &set, opts.c_str());
+  CHECK_ERR(rval);
+
+  // This test will write information about variable T
+  std::string writeopts;
+  writeopts = std::string(";;VARIABLE=T;DEBUG_IO=0;");
+  rval = mb.write_file("test_homme_T.nc", 0, writeopts.c_str(), &set, 1);
+  CHECK_ERR(rval);
+}
+
+void test_homme_check_T_values()
+{
+  Core moab;
+  Interface& mb = moab;
+
+  std::string opts;
+  get_homme_options(opts);
+
+  EntityHandle set;
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
+  CHECK_ERR(rval);
+
+  // Load non-set variable T and the mesh
+  opts += std::string(";VARIABLE=T");
+  rval = mb.load_file("test_homme_T.nc", &set, 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
+
+  // Only test serial case for the time being
+  if (1 == procs) {
+    // Get tag T0
+    Tag Ttag0;
+    rval = mb.tag_get_handle("T0", 26, MB_TYPE_DOUBLE, Ttag0);
+    CHECK_ERR(rval);
+
+    // Get vertices
+    Range verts;
+    rval = mb.get_entities_by_type(0, MBVERTEX, verts);
+    CHECK_ERR(rval);
+    CHECK_EQUAL((size_t)3458, verts.size());
+
+    // Get all values of tag T0
+    int count;
+    void* Tbuf;
+    rval = mb.tag_iterate(Ttag0, verts.begin(), verts.end(), count, Tbuf);
+    CHECK_ERR(rval);
+    CHECK_EQUAL((size_t)count, verts.size());
+
+    // Check some values of tag T0 on first level
+    const double eps = 0.0001;
+    double* data = (double*) Tbuf;
+    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
+    CHECK_REAL_EQUAL(234.0416, data[3457 * 26], eps); // Last vert
+  }
+}
+
+void get_eul_options(std::string& opts)
 {
 #ifdef USE_MPI
   // Use parallel options
   opts = std::string(";;PARALLEL=READ_PART;PARTITION_METHOD=SQIJ");
-  return MB_SUCCESS;
 #else
   opts = std::string(";;");
-  return MB_SUCCESS;
+#endif
+}
+
+void get_homme_options(std::string& opts)
+{
+#ifdef USE_MPI
+  // Use parallel options
+  opts = std::string(";;PARALLEL=READ_PART;PARTITION_METHOD=TRIVIAL");
+#else
+  opts = std::string(";;");
 #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