[MOAB-dev] r5875 - MOAB/trunk/src/io

iulian at mcs.anl.gov iulian at mcs.anl.gov
Fri Nov 16 15:00:08 CST 2012


Author: iulian
Date: 2012-11-16 15:00:08 -0600 (Fri, 16 Nov 2012)
New Revision: 5875

Modified:
   MOAB/trunk/src/io/ReadNC.cpp
Log:
look for ncells or ncenters in HommeMapping file


Modified: MOAB/trunk/src/io/ReadNC.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNC.cpp	2012-11-16 20:44:52 UTC (rev 5874)
+++ MOAB/trunk/src/io/ReadNC.cpp	2012-11-16 21:00:08 UTC (rev 5875)
@@ -682,7 +682,21 @@
 
   // read connectivity into temporary variable
   int num_fine_quads, num_coarse_quads, start_idx;
-  int num_quads = conn_vals[2];
+  std::vector<std::string>::iterator vit;
+  int idx;
+  if ( (vit = std::find(conn_names.begin(), conn_names.end(), "ncells")) != conn_names.end())
+  {
+    idx = vit - conn_names.begin();
+  }
+  else if ( (vit = std::find(conn_names.begin(), conn_names.end(), "ncenters")) != conn_names.end())
+  {
+    idx=vit - conn_names.begin();
+  }
+  else
+  {
+    ERRORR(MB_FAILURE, "Failed to get number of quads.");
+  }
+  int num_quads=conn_vals[idx];
 
     // get the connectivity into tmp_conn2 and permute into tmp_conn
   int cornerVarId;
@@ -891,10 +905,23 @@
    ERRORR(MB_FAILURE, "Connectivity file didn't have correct dimension names.");
    */
 
-  int num_quads = 0;
-  if (conn_names[2]=="ncells")
-    num_quads = conn_vals[2];
-  if (conn_vals[2] != gDims[3] - gDims[0] + 1-2) {
+  std::vector<std::string>::iterator vit;
+  int idx;
+  if ((vit = std::find(conn_names.begin(), conn_names.end(), "ncells")) != conn_names.end())
+  {
+    idx = vit - conn_names.begin();
+  }
+  else if ((vit = std::find(conn_names.begin(), conn_names.end(), "ncenters")) != conn_names.end())
+  {
+    idx=vit - conn_names.begin();
+  }
+  else
+  {
+    ERRORR(MB_FAILURE, "Failed to get number of quads.");
+  }
+  int num_quads=conn_vals[idx];
+


More information about the moab-dev mailing list