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

xbxu at mcs.anl.gov xbxu at mcs.anl.gov
Wed Jul 25 13:44:37 CDT 2012


Author: xbxu
Date: 2012-07-25 13:44:37 -0500 (Wed, 25 Jul 2012)
New Revision: 5637

Modified:
   MOAB/trunk/src/io/ReadNC.cpp
   MOAB/trunk/src/io/ReadNC.hpp
Log:
create COORD tag for quad coordinates

Modified: MOAB/trunk/src/io/ReadNC.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNC.cpp	2012-07-25 15:24:06 UTC (rev 5636)
+++ MOAB/trunk/src/io/ReadNC.cpp	2012-07-25 18:44:37 UTC (rev 5637)
@@ -946,6 +946,10 @@
       rval = read_variable_to_nonset(file_set, vdatas, tstep_nums);
       ERRORR(rval, "Trouble read variables to entities verts/edges/quads.");
     }
+    
+    // create COORDS tag for quad
+    rval = create_quad_coordinate_tag(file_set);
+    ERRORR(rval, "Trouble creating coordinate tags to entities quads");
   } 
   else {  // unstructured HOMME data
     ErrorCode rval = read_variable_ucd_setup(var_names, tstep_nums, vdatas);
@@ -2967,4 +2971,46 @@
   return MB_SUCCESS;
 }
 
+ErrorCode ReadNC::create_quad_coordinate_tag(EntityHandle file_set)
+{
+  Range ents;
+  ErrorCode rval = mbImpl->get_entities_by_type(file_set, moab::MBQUAD, ents);  
+  ERRORR(rval, "Trouble getting QUAD entity.");
+  
+  std::size_t numOwnedEnts = 0;
+#ifdef USE_MPI
+  Range ents_owned;    
+  rval = myPcomm->filter_pstatus(ents, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &ents_owned);  
+  ERRORR(rval, "Trouble getting owned QUAD entity.");
+  numOwnedEnts = ents_owned.size();
+#else
+  numOwnedEnts = ents.size();
+#endif
+
+  if (numOwnedEnts == 0)
+    return MB_SUCCESS;
+
+  assert(numOwnedEnts == ilCVals.size() * jlCVals.size());
+  std::vector<double> coords(numOwnedEnts*3);
+  std::size_t pos = 0;
+  for (std::size_t j = 0; j != jlCVals.size(); ++j) {
+    for (std::size_t i = 0; i != ilCVals.size(); ++i) {
+      pos = j*ilCVals.size()*3 + i*3;
+      coords[pos] = ilCVals[i];
+      coords[pos+1] = jlCVals[j];
+      coords[pos+2] = 0.0;
+    }
+  }
+  std::string tag_name = "COORDS";
+  void * val = &coords[0];


More information about the moab-dev mailing list