[MOAB-dev] r2632 - in MOAB/trunk: . tools/dagmc

janehu at mcs.anl.gov janehu at mcs.anl.gov
Wed Feb 4 16:34:32 CST 2009


Author: janehu
Date: 2009-02-04 16:34:32 -0600 (Wed, 04 Feb 2009)
New Revision: 2632

Modified:
   MOAB/trunk/ReadNCDF.cpp
   MOAB/trunk/ReadNCDF.hpp
   MOAB/trunk/tools/dagmc/main.cc
Log:
Modified update function according to tests, still need to make node_map to work.

Modified: MOAB/trunk/ReadNCDF.cpp
===================================================================
--- MOAB/trunk/ReadNCDF.cpp	2009-02-04 19:19:52 UTC (rev 2631)
+++ MOAB/trunk/ReadNCDF.cpp	2009-02-04 22:34:32 UTC (rev 2632)
@@ -2000,23 +2000,43 @@
 
     //read in the coordinates from the database.
     MBEntityHandle node_handle = 0;
-    std::vector<double*> arrays, deform_arrays ;
+    std::vector<double*> arrays, orig_coords, deform_arrays ;
     double*    array1 = new double [numberNodes_loading];
     double*    array2 = new double [numberNodes_loading];
     double*    array3 = new double [numberNodes_loading];
+    double*    array4 = new double [numberNodes_loading];
+    double*    array5 = new double [numberNodes_loading];
+    double*    array6 = new double [numberNodes_loading];
     deform_arrays.push_back(array1);
     deform_arrays.push_back(array2);
     deform_arrays.push_back(array3);
+    orig_coords.push_back(array4);
+    orig_coords.push_back(array5);
+    orig_coords.push_back(array6);
 
     readMeshIface->get_node_arrays(3, numberNodes_loading,
-      MB_START_ID, node_handle, arrays);
+                                   MB_START_ID, node_handle, arrays);
 
-    // read in the coordinates from the exodus file
+
+    //read in the original coordinates from the exodus file
+    NcVar *coord1 = ncFile->get_var("coordx");
+    NcVar *coord2 = ncFile->get_var("coordy");
+    NcVar *coord3;
+    if(numberDimensions_loading == 3)
+      coord3 = ncFile->get_var("coordz");
+    if (NULL == coord1 || !coord1->is_valid() ||
+        NULL == coord2 || !coord2->is_valid() ||
+        (numberDimensions_loading == 3 && (NULL == coord3 || !coord3->is_valid())) ) {
+      readMeshIface->report_error("MBCN:: Problem getting coords variable.");
+      return MB_FAILURE;
+    }
+ 
+    // read in the deformation from the exodus file
     NcVar *coordx = ncFile->get_var("vals_nod_var1");
     NcVar *coordy = ncFile->get_var("vals_nod_var2");
     NcVar *coordz;
     if(numberDimensions_loading == 3)
-      ncFile->get_var("vals_nod_var3");
+      coordz = ncFile->get_var("vals_nod_var3");
     if (NULL == coordx || !coordx->is_valid() ||
         NULL == coordy || !coordy->is_valid() ||
         (numberDimensions_loading == 3 && (NULL == coordz || !coordz->is_valid())) ) {
@@ -2024,6 +2044,44 @@
       return MB_FAILURE;
     }
 
+    NcBool status = coord1->get(orig_coords[0], 1, numberNodes_loading);
+    if (0 == status) {
+      readMeshIface->report_error("MBCN:: Problem getting x coord array.");
+      return MB_FAILURE;
+    }
+    status = coord2->get(orig_coords[1], 1, numberNodes_loading);
+    if (0 == status) {
+      readMeshIface->report_error("MBCN:: Problem getting y coord array.");
+      return MB_FAILURE;
+    }
+    if (numberDimensions_loading == 3 )
+    {
+      status = coord3->get(orig_coords[2], 1, numberNodes_loading);
+      if (0 == status) {
+        readMeshIface->report_error("MBCN:: Problem getting z coord array.");
+        return MB_FAILURE;
+      }
+    }
+
+    status = coordx->get(deform_arrays[0], 1, numberNodes_loading);
+    if (0 == status) {
+      readMeshIface->report_error("MBCN:: Problem getting x coord array.");
+      return MB_FAILURE;
+    }
+    status = coordy->get(deform_arrays[1], 1, numberNodes_loading);
+    if (0 == status) {
+      readMeshIface->report_error("MBCN:: Problem getting y coord array.");
+      return MB_FAILURE;
+    }
+    if (numberDimensions_loading == 3 )
+    {
+      status = coordz->get(deform_arrays[2], 1, numberNodes_loading);
+      if (0 == status) {
+        readMeshIface->report_error("MBCN:: Problem getting z coord array.");
+        return MB_FAILURE;
+      }
+    }
+
     //do operations on all coordinates.
     for(int node_num = 0; node_num < numberNodes_loading; )
     {
@@ -2046,52 +2104,34 @@
         return MB_FAILURE;
       }
 
+      int offset = (time_step-1) * numberNodes_loading;
+
       for(int j = 1;j <= numberNodes_loading ; j++)
+      {
         //j is the number of nodes to be sequentially matched
+        if(op == "sum")
+        {
+          arrays[0][node_num + j - 1] = orig_coords[0][node_index1+j-1] + deform_arrays[0][offset+node_index1+j-1];
+          arrays[1][node_num + j - 1] = orig_coords[1][node_index1+j-1] + deform_arrays[0][offset+node_index1+j-1];
+          arrays[2][node_num + j - 1] = orig_coords[2][node_index1+j-1] + deform_arrays[0][offset+node_index1+j-1];
+        }
+
         if(ptr1[node_index1+j] != ptr2[node_num +j])  
         {
           num_of_nodes = j;
           break;
         }    
+      }
 
-      int offset = (time_step-1) * numberNodes_loading;
-
-      if(op == "sum")
-      {
-        NcBool status = coordx->get(deform_arrays[0], offset+node_index1+1, num_of_nodes);
-        if (0 == status) {
-          readMeshIface->report_error("MBCN:: Problem getting x coord array.");
-          return MB_FAILURE;
-        }
-        status = coordy->get(deform_arrays[1], offset+node_index1+1, num_of_nodes);
-        if (0 == status) {
-          readMeshIface->report_error("MBCN:: Problem getting y coord array.");
-          return MB_FAILURE;
-        }
-        if (numberDimensions_loading == 3 )
-        {
-          status = coordz->get(deform_arrays[2], offset+node_index1+1, num_of_nodes);
-          if (0 == status) {
-            readMeshIface->report_error("MBCN:: Problem getting z coord array.");
-            return MB_FAILURE;
-          }
-        }    
-      }
       node_num += num_of_nodes;
     }
-    if(op == "sum")
-    {
-      for(int i = 0; i < numberNodes_loading; i++)
-      {
-        arrays[0][i] += deform_arrays[0][i];
-        arrays[1][i] += deform_arrays[1][i];
-        arrays[2][i] += deform_arrays[2][i];
-      }
-    }
     delete [] ptr1;
     delete [] array1;
     delete [] array2;
     delete [] array3;
+    delete [] array4;
+    delete [] array5;
+    delete [] array6;
   } //if token[0] == "coord"
   
   return MB_SUCCESS;
@@ -2107,5 +2147,7 @@
     tokens.push_back( str.substr( last, pos - last ) );
     last = str.find_first_not_of( delimiters, pos );
     pos  = str.find_first_of( delimiters, last );
+    if(std::string::npos == pos)
+      pos = str.size();
   }
 }

Modified: MOAB/trunk/ReadNCDF.hpp
===================================================================
--- MOAB/trunk/ReadNCDF.hpp	2009-02-04 19:19:52 UTC (rev 2631)
+++ MOAB/trunk/ReadNCDF.hpp	2009-02-04 22:34:32 UTC (rev 2632)
@@ -31,7 +31,7 @@
 #define READNCDF_HPP
 
 #ifndef IS_BUILDING_MB
-#error "ReadNCDF.hpp isn't supposed to be included into an application"
+//#error "ReadNCDF.hpp isn't supposed to be included into an application"
 #endif
 
 #include <vector>

Modified: MOAB/trunk/tools/dagmc/main.cc
===================================================================
--- MOAB/trunk/tools/dagmc/main.cc	2009-02-04 19:19:52 UTC (rev 2631)
+++ MOAB/trunk/tools/dagmc/main.cc	2009-02-04 22:34:32 UTC (rev 2632)
@@ -4,6 +4,9 @@
 #include "MBCore.hpp"
 #include "cgm2moab.hpp"
 #include "cubfile.h"
+#include "Tqdcfr.hpp"
+#include "FileOptions.hpp"
+#include "ReadNCDF.hpp"
 
 #define GF_CUBIT_FILE_TYPE    "CUBIT"
 #define GF_STEP_FILE_TYPE     "STEP"
@@ -158,10 +161,21 @@
       exit(2);
     }
     
-    int rval = cub_file_type( cub_file, tmp_file, CUB_FILE_ACIS );
+    MBCore *my_impl = new MBCore();
+    Tqdcfr *my_tqd = new Tqdcfr(my_impl);
+    MBEntityHandle file_set;
+    FileOptions opts(NULL);
+
+    MBErrorCode result = my_tqd->load_file(input_name, file_set, opts, 0, 0);
+
+    opts = "tdata=coord, 1, sum";
+    ReadNCDF my_ex_reader(my_impl);
+    result = my_ex_reader.update("2Paul.e", opts);
+
+    int rvalue = cub_file_type( cub_file, tmp_file, CUB_FILE_ACIS );
     fclose( cub_file );
     fclose( tmp_file );
-    if (rval) {
+    if (rvalue) {
       remove( temp_name );
       free( temp_name );
       exit(2);



More information about the moab-dev mailing list