[MOAB-dev] r1958 - in MOAB/trunk: . parallel tools/mbcoupler

tautges at mcs.anl.gov tautges at mcs.anl.gov
Sun Jun 29 20:31:57 CDT 2008


Author: tautges
Date: 2008-06-29 20:31:57 -0500 (Sun, 29 Jun 2008)
New Revision: 1958

Modified:
   MOAB/trunk/Tqdcfr.cpp
   MOAB/trunk/TypeSequenceManager.cpp
   MOAB/trunk/parallel/ReadParallel.cpp
   MOAB/trunk/tools/mbcoupler/addfield.cpp
   MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
Log:
Another fix to SequenceManager.  This time:
- there was no sequence data allocated for the target range
- there was exactly enough room in unallocated sequence data for the target range
- the next data sequence up had a couple of empty slots, so the first occupied handle was a couple spaces from the start of the sequence data
- the upper end of the range of the allocated sequence data was computed based on the first handle in the next sequence data

Fixed by setting the size using the parameter I added before.

Also:
- adding another command line argument to mbcoupler_test to specify output file name.
- adding another command line arg to addfield to allow specification of an inverse scaling factor.
- fixed another mistake in Tqdcfr, declaring a variable which stomped on a member variable

Passes make check.



Modified: MOAB/trunk/Tqdcfr.cpp
===================================================================
--- MOAB/trunk/Tqdcfr.cpp	2008-06-29 22:15:35 UTC (rev 1957)
+++ MOAB/trunk/Tqdcfr.cpp	2008-06-30 01:31:57 UTC (rev 1958)
@@ -213,7 +213,6 @@
   mFileSet = file_set;
 
     // get "before" entities
-  MBRange beforeEnts;
   result = mdbImpl->get_entities_by_handle(0, beforeEnts);
   if (MB_SUCCESS != result) {
     readUtilIface->report_error("Couldn't get \"before\" entities.");
@@ -1180,10 +1179,13 @@
       // get a space for reading connectivity data directly into MB
     MBEntityHandle *conn, start_handle;
     
-    readUtilIface->get_element_array(num_elem, nodes_per_elem,
+    result = readUtilIface->get_element_array(num_elem, nodes_per_elem,
                                      elem_type, int_buf[0], 
                                      readUtilIface->parallel_rank(), 
                                      start_handle, conn);
+    if (MB_SUCCESS != result)
+      return result;
+    
     MBRange dum_range(start_handle, start_handle+num_elem-1);
         
     long elem_offset;

Modified: MOAB/trunk/TypeSequenceManager.cpp
===================================================================
--- MOAB/trunk/TypeSequenceManager.cpp	2008-06-29 22:15:35 UTC (rev 1957)
+++ MOAB/trunk/TypeSequenceManager.cpp	2008-06-30 01:31:57 UTC (rev 1958)
@@ -544,6 +544,7 @@
       d.last  = (*i)->data()->start_handle() - 1;
       if (check_range( d, false, result )) {
         data_out = 0;
+        data_size = d.last - d.first + 1;
         return result;
       }
     }

Modified: MOAB/trunk/parallel/ReadParallel.cpp
===================================================================
--- MOAB/trunk/parallel/ReadParallel.cpp	2008-06-29 22:15:35 UTC (rev 1957)
+++ MOAB/trunk/parallel/ReadParallel.cpp	2008-06-30 01:31:57 UTC (rev 1958)
@@ -463,7 +463,7 @@
     if (proc_rk < (int) (myPcomm->partition_sets().size() % proc_sz)) num_sets++;
 
     for (unsigned int i = 0; i < num_sets; i++) {
-// drop round-robin      tmp_sets.insert(myPcomm->partition_sets()[i*proc_sz + proc_rk]);
+//      tmp_sets.insert(myPcomm->partition_sets()[i*proc_sz + proc_rk]);
       if (num_sets*proc_rk+i < tot_sets)
         tmp_sets.insert(myPcomm->partition_sets()[num_sets*proc_rk+i]);
     }

Modified: MOAB/trunk/tools/mbcoupler/addfield.cpp
===================================================================
--- MOAB/trunk/tools/mbcoupler/addfield.cpp	2008-06-29 22:15:35 UTC (rev 1957)
+++ MOAB/trunk/tools/mbcoupler/addfield.cpp	2008-06-30 01:31:57 UTC (rev 1958)
@@ -1,16 +1,18 @@
 #include <iostream>
 #include "MBCore.hpp"
+#include <math.h>
 using namespace std;
 
 
 //make a nice picture. tweak here
 //217: x,y -> [-8, 8] /// z -> [-65, 65]
-double physField(double x, double y, double z){
+double physField(double x, double y, double z, double factor){
   double out;
 
     // 1/r^2 decay from {0,0,0}
-
-  out = x*x + y*y + z*z;
+    // tjt - changing to 1/r
+  double scale = 1.0/factor;
+  out = fabs(x*scale) + fabs(y*scale) + fabs(z*scale);
   out += 1e-1; // clamp
   out = 1/out;
 
@@ -43,7 +45,7 @@
 }
 
 
-void putElementField(MBInterface *mbi, char *tagname){
+void putElementField(MBInterface *mbi, char *tagname, double factor){
   MBRange hexes;
 
   mbi->get_entities_by_type(0, MBHEX, hexes);
@@ -61,7 +63,7 @@
     double x,y,z;
     getHexPos(mbi, &hex, x,y,z);
 
-    double fieldValue =  physField(x,y,z);
+    double fieldValue =  physField(x,y,z, factor);
 
     mbi->tag_set_data(fieldTag, &hex, 1, &fieldValue);
   }
@@ -69,7 +71,7 @@
 }
 
 
-void putVertexField(MBInterface *mbi, char *tagname){
+void putVertexField(MBInterface *mbi, char *tagname, double factor){
   MBRange verts;
 
   mbi->get_entities_by_type(0, MBVERTEX, verts);
@@ -85,7 +87,7 @@
     double vertPos[3];
     mbi->get_coords(&vert, 1, vertPos);
 
-    double fieldValue =  physField(vertPos[0], vertPos[1], vertPos[2]);
+    double fieldValue =  physField(vertPos[0], vertPos[1], vertPos[2], factor);
 
     mbi->tag_set_data(fieldTag, &vert, 1, &fieldValue);
   }
@@ -99,16 +101,19 @@
 int main(int argc, char **argv){
   MBInterface *mbi = new MBCore();
 
-  if (argc != 3){
-    cout << "Usage: " << argv[0] << " <infile> <outfile> \n"
+  if (argc < 3){
+    cout << "Usage: " << argv[0] << " <infile> <outfile> [factor]\n"
          << "Writes both vertex and element fields.\n";
     return 0;
   }
 
   mbi->load_mesh(argv[1]);
 
-  putVertexField(mbi, "vertex_field");
-  putElementField(mbi, "element_field");
+  double factor = 1.0;
+  if (argc == 4) factor = atof(argv[3]);
+  
+  putVertexField(mbi, "vertex_field", factor);
+  putElementField(mbi, "element_field", factor);
 
   MBErrorCode result = mbi->write_mesh(argv[2]);
   if (MB_SUCCESS == result) cout << "wrote " << argv[2] << endl;

Modified: MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
===================================================================
--- MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp	2008-06-29 22:15:35 UTC (rev 1957)
+++ MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp	2008-06-30 01:31:57 UTC (rev 1958)
@@ -29,6 +29,7 @@
 MBErrorCode get_file_options(int argc, char **argv, 
                              std::vector<const char *> &filenames,
                              std::string &tag_name,
+                             std::string &out_fname,
                              std::string &opts);
 
 MBErrorCode report_iface_ents(MBInterface *mbImpl,
@@ -54,6 +55,7 @@
     std::cerr << "nfiles        : number of mesh files" << std::endl;
     std::cerr << "fname1..fnamen: mesh files" << std::endl;
     std::cerr << "interp_tag    : name of tag interpolated to target mesh []" << std::endl;
+    std::cerr << "output_fname  : name of output file" << std::endl;
     std::cerr << "tag_name      : name of tag used to define partitions [GEOM_DIMENSION]" << std::endl;
     std::cerr << "tag_val       : tag values denoting partition sets [--]" << std::endl;
     std::cerr << "distrib       : if non-zero, distribute the partition sets with tag_val round-robin" << std::endl;
@@ -79,8 +81,8 @@
   MBErrorCode result = MB_SUCCESS;
 
   std::vector<const char *> filenames;
-  std::string opts, interp_tag;
-  result = get_file_options(argc, argv, filenames, interp_tag, opts);
+  std::string opts, interp_tag, out_fname;
+  result = get_file_options(argc, argv, filenames, interp_tag, out_fname, opts);
   
 
     // read in mesh(es)
@@ -114,16 +116,15 @@
 
 
     // output mesh
-  const char *outfile = "output.h5m";
   const char *out_option =
 //      "PARALLEL_FORMAT";
       NULL;
 
   if (pcs[1]->proc_config().proc_rank() == 0) {
-    result = mbImpl->write_file(outfile, NULL, out_option,
+    result = mbImpl->write_file(out_fname.c_str(), NULL, out_option,
                                 pcs[1]->partition_sets());
     PRINT_LAST_ERROR;
-    std::cout << "Wrote " << outfile << std::endl;
+    std::cout << "Wrote " << out_fname << std::endl;
   }
 
   std::cout << "Success." << std::endl;
@@ -186,6 +187,7 @@
 MBErrorCode get_file_options(int argc, char **argv, 
                              std::vector<const char *> &filenames,
                              std::string &interp_tag,
+                             std::string &out_fname,
                              std::string &opts) 
 {
   int npos = 1;
@@ -197,6 +199,8 @@
 
   if (npos < argc) interp_tag = argv[npos++];
   
+  if (npos < argc) out_fname = argv[npos++];
+  
     // get partition information
   const char *tag_name = "GEOM_DIMENSION";
   int tag_val = -1;




More information about the moab-dev mailing list