[MOAB-dev] commit/MOAB: jayeshkrishna: Extracting the logic for adding dummy tag creation info, related to dimensions with no corresponding coordinate variables, to a separate function and calling it for all supported mesh types

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Apr 23 12:03:10 CDT 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/cfa468e59715/
Changeset:   cfa468e59715
Branch:      master
User:        jayeshkrishna
Date:        2013-04-23 18:58:51
Summary:     Extracting the logic for adding dummy tag creation info, related to dimensions with no corresponding coordinate variables, to a separate function and calling it for all supported mesh types

Affected #:  2 files

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index d7bcb35..774f7a6 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -2321,6 +2321,10 @@ ErrorCode ReadNC::init_FVCDscd_vals(const FileOptions &opts, EntityHandle file_s
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
 
+  // hack: create dummy tags, if needed, for dimensions like nbnd
+  // with no corresponding variables
+  init_dims_with_no_cvars_info();
+
   return MB_SUCCESS;
 }
 
@@ -2699,9 +2703,39 @@ ErrorCode ReadNC::init_EulSpcscd_vals(const FileOptions &opts, EntityHandle file
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
 
+  // hack: create dummy tags, if needed, for variables like nbnd
+  // with no corresponding variables
+  init_dims_with_no_cvars_info();
+
   return MB_SUCCESS;
 }
 
+void ReadNC::init_dims_with_no_cvars_info() {
+  // hack: look at all dimensions, and see if we have one that does not appear in the list of varInfo names
+  // right now, candidates are ncol and nbnd
+  // for them, create dummy tags
+  for (unsigned int i=0; i<dimNames.size(); i++)
+  {
+    // if there is a var with this name, skip, we are fine; if not, create a varInfo...
+    if ( varInfo.find(dimNames[i])!=varInfo.end())
+      continue; // we already have a variable with this dimension name
+
+    int sizeTotalVar = varInfo.size();
+    std::string var_name(dimNames[i]);
+    VarData &data = varInfo[var_name];
+    data.varName = std::string(var_name);
+    data.varId =sizeTotalVar;
+    data.varTags.resize(1, 0);
+    data.varDataType = NC_DOUBLE; // could be int, actually, but we do not really need the type
+    data.varDims.resize(1);
+    data.varDims[0]= (int)i;
+    data.numAtts=0;
+    data.entLoc = ENTLOCSET;
+    dbgOut.tprintf(2, "Dummy varInfo created for dimension %s\n", dimNames[i].c_str());
+    dummyVarNames.insert(dimNames[i]);
+  }
+}
+
 ErrorCode ReadNC::init_HOMMEucd_vals() {
   ErrorCode rval;
   unsigned int idx;
@@ -2812,29 +2846,10 @@ ErrorCode ReadNC::init_HOMMEucd_vals() {
 
   // don't read coordinates of columns until we actually create the mesh
 
-  // hack: look at all dimensions, and see if we have one that does not appear in the list of varInfo names
-  // right now, candidates are ncol and nbnd
-  // for them, create dummy tags
-  for (unsigned int i=0; i<dimNames.size(); i++)
-  {
-    // if there is a var with this name, skip, we are fine; if not, create a varInfo...
-    if ( varInfo.find(dimNames[i])!=varInfo.end())
-      continue; // we already have a variable with this dimension name
+  // hack: create dummy tags, if needed, for variables like ncol and nbnd
+  // with no corresponding variables
+  init_dims_with_no_cvars_info();
 
-    int sizeTotalVar = varInfo.size();
-    std::string var_name(dimNames[i]);
-    VarData &data = varInfo[var_name];
-    data.varName = std::string(var_name);
-    data.varId =sizeTotalVar;
-    data.varTags.resize(1, 0);
-    data.varDataType = NC_DOUBLE; // could be int, actually, but we do not really need the type
-    data.varDims.resize(1);
-    data.varDims[0]= (int)i;
-    data.numAtts=0;
-    data.entLoc = ENTLOCSET;
-    dbgOut.tprintf(2, "Dummy varInfo created for dimension %s\n", dimNames[i].c_str());
-    dummyVarNames.insert(dimNames[i]);
-  }
   return MB_SUCCESS;
 }
 

diff --git a/src/io/ReadNC.hpp b/src/io/ReadNC.hpp
index d5a18eb..7bc07d5 100644
--- a/src/io/ReadNC.hpp
+++ b/src/io/ReadNC.hpp
@@ -236,6 +236,10 @@ private:
   //! create COORDS tag for quads coordinate
   ErrorCode create_quad_coordinate_tag(EntityHandle file_set);
 
+  //! Init info for dimensions that don't have corresponding 
+  //! coordinate variables - this info is used for creating tags
+  void init_dims_with_no_cvars_info();
+
   ErrorCode init_HOMMEucd_vals();
 
   ErrorCode create_ucd_verts_quads(const FileOptions &opts, EntityHandle tmp_set, Range &quads);

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