[MOAB-dev] commit/MOAB: iulian07: adjacency avoidance for geometric methods

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Oct 4 17:28:40 CDT 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/229c588ce7f2/
Changeset:   229c588ce7f2
Branch:      master
User:        iulian07
Date:        2013-10-05 00:24:54
Summary:     adjacency avoidance for geometric methods

adjacency is not needed for geometric methods, like RCB, HSFC, RIB
skip it in these cases
Also, pass timing to the main method, to get a better idea of where the
time is spent.

Affected #:  3 files

diff --git a/tools/mbzoltan/MBZoltan.cpp b/tools/mbzoltan/MBZoltan.cpp
index 1ec6757..45b8a35 100644
--- a/tools/mbzoltan/MBZoltan.cpp
+++ b/tools/mbzoltan/MBZoltan.cpp
@@ -254,7 +254,8 @@ ErrorCode MBZoltan::partition_mesh_geom(const double part_geom_mesh_size,
                                         const int obj_weight,
                                         const int edge_weight,
                                         const bool part_surf,
-                                        const bool ghost) 
+                                        const bool ghost,
+                                        const bool print_time)
 {
     // should only be called in serial
   if (mbpc->proc_config().proc_size() != 1) {
@@ -262,7 +263,7 @@ ErrorCode MBZoltan::partition_mesh_geom(const double part_geom_mesh_size,
               << std::endl;
     return MB_FAILURE;
   }
-  
+  clock_t t = clock();
   if (NULL != zmethod && strcmp(zmethod, "RR") && strcmp(zmethod, "RCB") && strcmp(zmethod, "RIB") &&
       strcmp(zmethod, "HSFC") && strcmp(zmethod, "Hypergraph") &&
       strcmp(zmethod, "PHG") && strcmp(zmethod, "PARMETIS") &&
@@ -274,6 +275,10 @@ ErrorCode MBZoltan::partition_mesh_geom(const double part_geom_mesh_size,
     return MB_FAILURE;
   }
 
+  bool part_geom = false;
+  if ( 0==  strcmp(zmethod, "RR") || 0== strcmp(zmethod, "RCB") || 0== strcmp(zmethod, "RIB")
+      || 0==strcmp(zmethod, "HSFC") )
+    part_geom=true; // so no adjacency / edges needed
   std::vector<double> pts; // x[0], y[0], z[0], ... from MOAB
   std::vector<int> ids; // point ids from MOAB
   std::vector<int> adjs, length, parts;
@@ -321,7 +326,7 @@ ErrorCode MBZoltan::partition_mesh_geom(const double part_geom_mesh_size,
   
   if (part_geom_mesh_size < 0.) {
     //if (!part_geom) {
-    result = assemble_graph(part_dim, pts, ids, adjs, length, elems); RR;
+       result = assemble_graph(part_dim, pts, ids, adjs, length, elems, part_geom); RR;
   }
   else {
 #ifdef CGM
@@ -347,20 +352,29 @@ ErrorCode MBZoltan::partition_mesh_geom(const double part_geom_mesh_size,
     }
 #endif
   }
-  
+  if (print_time)
+  {
+    std::cout << " time to assemble graph: " << (clock() - t) / (double) CLOCKS_PER_SEC  << "s. \n";
+    t = clock();
+  }
   double* o_wgt = NULL;
   double* e_wgt = NULL;
   if (obj_weights.size() > 0) o_wgt = &obj_weights[0];
   if (edge_weights.size() > 0) e_wgt = &edge_weights[0];
     
   myNumPts = mbInitializePoints((int)ids.size(), &pts[0], &ids[0], &adjs[0],
-                                &length[0], o_wgt, e_wgt, &parts[0]);
+                                &length[0], o_wgt, e_wgt, &parts[0], part_geom);
   
 
   // Initialize Zoltan.  This is a C call.  The simple C++ code 
   // that creates Zoltan objects does not keep track of whether 
   // Zoltan_Initialize has been called.
 
+  if (print_time)
+  {
+    std::cout << " time to initialize points: " << (clock() - t) / (double) CLOCKS_PER_SEC  << "s. \n";
+    t = clock();
+  }
   float version;
 
   std::cout << "Initializing zoltan..." << std::endl;
@@ -458,6 +472,11 @@ ErrorCode MBZoltan::partition_mesh_geom(const double part_geom_mesh_size,
                               assign_procs, assign_parts);
   if (ZOLTAN_OK != retval) return MB_FAILURE;
   
+  if (print_time)
+  {
+    std::cout << " time to LB_partition " << (clock() - t) / (double) CLOCKS_PER_SEC  << "s. \n";
+    t = clock();
+  }
   // take results & write onto MOAB partition sets
   std::cout << "Saving partition information to MOAB..." << std::endl;
   
@@ -473,6 +492,12 @@ ErrorCode MBZoltan::partition_mesh_geom(const double part_geom_mesh_size,
 #endif
   }
 
+  if (print_time)
+  {
+    std::cout << " time to write partition in memory " <<(clock() - t) / (double) CLOCKS_PER_SEC  << "s. \n";
+    t = clock();
+  }
+
   if (MB_SUCCESS != result) return result;
 
 
@@ -550,7 +575,7 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
                                    std::vector<int> &moab_ids,
                                    std::vector<int> &adjacencies, 
                                    std::vector<int> &length,
-                                   Range &elems) 
+                                   Range &elems, bool  part_geom)
 {
     // assemble a graph with vertices equal to elements of specified dimension, edges
     // signified by list of other elements to which an element is connected
@@ -580,21 +605,24 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
   
   for (Range::iterator rit = elems.begin(); rit != elems.end(); rit++) {
 
-      // get bridge adjacencies
-    adjs.clear();
-    result = mtu.get_bridge_adjacencies(*rit, (dimension > 0 ? dimension-1 : 3), 
-                                        dimension, adjs); RR;
 
-      // get the graph vertex ids of those
-    if (!adjs.empty()) {
-      assert(adjs.size() < 5*MAX_SUB_ENTITIES);
-      result = mbImpl->tag_get_data(gid, adjs, neighbors); RR;
-    }
+    if (!part_geom)
+    {
+      // get bridge adjacencies
+      adjs.clear();
+      result = mtu.get_bridge_adjacencies(*rit, (dimension > 0 ? dimension-1 : 3),
+                                          dimension, adjs); RR;
 
-      // copy those into adjacencies vector
-    length.push_back((int)adjs.size());
-    std::copy(neighbors, neighbors+adjs.size(), std::back_inserter(adjacencies));
+        // get the graph vertex ids of those
+      if (!adjs.empty()) {
+        assert(adjs.size() < 5*MAX_SUB_ENTITIES);
+        result = mbImpl->tag_get_data(gid, adjs, neighbors); RR;
+      }
 
+        // copy those into adjacencies vector
+      length.push_back((int)adjs.size());
+      std::copy(neighbors, neighbors+adjs.size(), std::back_inserter(adjacencies));
+    }
 
       // get average position of vertices
     result = mtu.get_average_position(*rit, avg_position); RR;
@@ -1305,7 +1333,7 @@ ErrorCode MBZoltan::write_partition(const int nparts,
                                     Range &elems, 
                                     const int *assignment,
                                     const bool write_as_sets,
-                                    const bool write_as_tags) 
+                                    const bool write_as_tags)
 {
   ErrorCode result;
 
@@ -1347,10 +1375,9 @@ ErrorCode MBZoltan::write_partition(const int nparts,
         result = mbImpl->delete_entities(&old_set, 1); RR;
       }
     }
-  
-      // assign partition sets to vector
+    // assign partition sets to vector
     partSets.swap(tagged_sets);
-  
+
       // write a tag to those sets denoting they're partition sets, with a value of the
       // proc number
     int *dum_ids = new int[nparts];
@@ -1358,14 +1385,26 @@ ErrorCode MBZoltan::write_partition(const int nparts,
   
     result = mbImpl->tag_set_data(part_set_tag, partSets, dum_ids); RR;
 
-      // assign entities to the relevant sets
+    // assign entities to the relevant sets
     std::vector<EntityHandle> tmp_part_sets;
+    //int N = (int)elems.size();
     std::copy(partSets.begin(), partSets.end(), std::back_inserter(tmp_part_sets));
+    /*Range::reverse_iterator riter;
+    for (i = N-1, riter = elems.rbegin(); riter != elems.rend(); riter++, i--) {
+      int assigned_part = assignment[i];
+      part_ranges[assigned_part].insert(*riter);
+      //result = mbImpl->add_entities(tmp_part_sets[assignment[i]], &(*rit), 1); RR;
+    }*/
+
     Range::iterator rit;
     for (i = 0, rit = elems.begin(); rit != elems.end(); rit++, i++) {
       result = mbImpl->add_entities(tmp_part_sets[assignment[i]], &(*rit), 1); RR;
     }
-
+    /*for (i=0; i<nparts; i++)
+    {
+      result = mbImpl->add_entities(tmp_part_sets[i], part_ranges[i]); RR;
+    }
+    delete [] part_ranges;*/
       // check for empty sets, warn if there are any
     Range empty_sets;
     for (rit = partSets.begin(); rit != partSets.end(); rit++) {
@@ -1474,17 +1513,17 @@ void MBZoltan::SetOCTPART_Parameters(const char *oct_method)
 int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids, 
                                  int *adjs, int *length,
                                  double *obj_weights, double *edge_weights,
-                                 int *parts)
+                                 int *parts, bool part_geom)
 {
   unsigned int i;
   int j;
-  int *numPts, *nborProcs;
+  int *numPts, *nborProcs = NULL;
   int sum, ptsPerProc, ptsAssigned, mySize;
   MPI_Status stat;
   double *sendPts;
   int *sendIds;
-  int *sendEdges;
-  int *sendNborId;
+  int *sendEdges = NULL;
+  int *sendNborId = NULL;
   int *sendProcs;
 
   if (mbpc->proc_config().proc_rank() == 0) {
@@ -1504,19 +1543,22 @@ int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids,
     mySize = numPts[mbpc->proc_config().proc_rank()];
     sendPts = pts + (3 * numPts[0]);
     sendIds = ids + numPts[0];
-    sendEdges = length + numPts[0];
-    sum = 0;
+    sum = 0; // possible no adjacency sent
+    if (!part_geom)
+    {
+      sendEdges = length + numPts[0];
 
-    for (j = 0; j < numPts[0]; j++)
-      sum += length[j];
 
-    sendNborId = adjs + sum;
+      for (j = 0; j < numPts[0]; j++)
+        sum += length[j];
 
-    for (j = numPts[0]; j < npts; j++)
-      sum += length[j];
+      sendNborId = adjs + sum;
 
-    nborProcs = (int *)malloc(sizeof(int) * sum);
+      for (j = numPts[0]; j < npts; j++)
+        sum += length[j];
 
+      nborProcs = (int *)malloc(sizeof(int) * sum);
+    }
     for (j = 0; j < sum; j++)
       if ((i = adjs[j] / ptsPerProc) < mbpc->proc_config().proc_size())
         nborProcs[j] = i;

diff --git a/tools/mbzoltan/MBZoltan.hpp b/tools/mbzoltan/MBZoltan.hpp
index 269d9ae..4a0e999 100644
--- a/tools/mbzoltan/MBZoltan.hpp
+++ b/tools/mbzoltan/MBZoltan.hpp
@@ -112,7 +112,8 @@ using namespace moab;
                                   const int obj_weight = 0,
                                   const int edge_weight = 0,
                                   const bool part_surf = false,
-                                  const bool ghost = false);
+                                  const bool ghost = false,
+                                  const bool print_time = false);
     
     int get_mesh(std::vector<double> &pts, std::vector<int> &ids,
                  std::vector<int> &adjs, std::vector<int> &length,
@@ -198,7 +199,7 @@ using namespace moab;
                              std::vector<int> &moab_ids,
                              std::vector<int> &adjacencies, 
                              std::vector<int> &length,
-                             Range &elems);
+                             Range &elems, bool part_geom = false);
     
 #ifdef CGM
     std::map<int, int> body_vertex_map, surf_vertex_map;
@@ -234,7 +235,7 @@ using namespace moab;
                            int *adjs, int *length,
                            double *obj_weights = NULL,
                            double *edge_weights = NULL,
-                           int *parts = NULL);
+                           int *parts = NULL, bool part_geom = false);
 
 #ifdef CGM
     GeometryQueryTool *gti;

diff --git a/tools/mbzoltan/mbpart.cpp b/tools/mbzoltan/mbpart.cpp
index 17be979..7ad6dd2 100644
--- a/tools/mbzoltan/mbpart.cpp
+++ b/tools/mbzoltan/mbpart.cpp
@@ -20,14 +20,15 @@ const char DEFAULT_ZOLTAN_METHOD[] = "RCB";
 const char ZOLTAN_PARMETIS_METHOD[] = "PARMETIS";
 const char ZOLTAN_OCTPART_METHOD[] = "OCTPART";
 
-const char BRIEF_DESC[] = 
-  "Use Zoltan to partition MOAB meshes for use on parallel computers";
+const char BRIEF_DESC[] =
+    "Use Zoltan to partition MOAB meshes for use on parallel computers";
 std::ostringstream LONG_DESC;
 
-int main( int argc, char* argv[] )
+int main(int argc, char* argv[])
 {
-  int err = MPI_Init( &argc, &argv );
-  if (err) {
+  int err = MPI_Init(&argc, &argv);
+  if (err)
+  {
     std::cerr << "MPI_Init failed.  Aborting." << std::endl;
     return 3;
   }
@@ -35,90 +36,109 @@ int main( int argc, char* argv[] )
   Core moab;
   Interface& mb = moab;
   std::vector<int> set_l;
-  
-  LONG_DESC << "This utility invokes the MBZoltan componemnt of MOAB/CGM"
-    "to partition a mesh/geometry." << std::endl
-            << "If no partitioning method is specified, the default is "
-    "the Zoltan \"" << DEFAULT_ZOLTAN_METHOD << "\" method" << std::endl;
-  
+
+  LONG_DESC << "This utility invokes the MBZoltan component of MOAB/CGM"
+      "to partition a mesh/geometry." << std::endl
+      << "If no partitioning method is specified, the default is "
+          "the Zoltan \"" << DEFAULT_ZOLTAN_METHOD << "\" method" << std::endl;
+
   ProgOptions opts(LONG_DESC.str(), BRIEF_DESC);
 
   int part_dim = 3;
-  opts.addOpt<int>( "dimension", "Specify dimension of entities to partition."
-		    "  Default is  largest in file.", 
-                    &part_dim, ProgOptions::int_flag );
+  opts.addOpt<int>("dimension", "Specify dimension of entities to partition."
+      "  Default is  largest in file.", &part_dim, ProgOptions::int_flag);
 
   std::string zoltan_method, parm_method, oct_method;
-  opts.addOpt<std::string>( "zoltan,z", "Specify Zoltan partition method.  "
-                            "One of RR, RCB, RIB, HFSC, PHG, or Hypergraph (PHG and Hypergraph "
-                            "are synonymous).", &zoltan_method);
-  opts.addOpt<std::string>( "parmetis,p", "Specify Parmetis partition method.", &parm_method);
-  opts.addOpt<std::string>( "octpart,o", "Specify OctPart partition method.", &oct_method);
-
-  bool write_sets = true, write_tags = false;
-  opts.addOpt<void>( "sets,s", "Write partition as tagged sets (Default)", &write_sets);
-  opts.addOpt<void>( "tags,t",  "Write partition by tagging entities", &write_tags);
+  opts.addOpt<std::string>("zoltan,z", "Specify Zoltan partition method.  "
+      "One of RR, RCB, RIB, HFSC, PHG, or Hypergraph (PHG and Hypergraph "
+      "are synonymous).", &zoltan_method);
+  opts.addOpt<std::string>("parmetis,p", "Specify Parmetis partition method.",
+      &parm_method);
+  opts.addOpt<std::string>("octpart,o", "Specify OctPart partition method.",
+      &oct_method);
+
+  bool no_write_sets = false, write_tags = false;
+  opts.addOpt<void>("nosets,n",
+      "Do not write partition as tagged sets (Default : write sets)",
+      &no_write_sets);
+  opts.addOpt<void>("tags,t", "Write partition by tagging entities",
+      &write_tags);
 
   bool incl_closure = false;
-  opts.addOpt<void>( "include_closure,c", "Include element closure for part sets.", &incl_closure);
+  opts.addOpt<void>("include_closure,c",
+      "Include element closure for part sets.", &incl_closure);
 
   double imbal_tol = 1.10;
-  opts.addOpt<double>( "imbalance,i",  "Imbalance tolerance (used in PHG/Hypergraph method)", &imbal_tol);
+  opts.addOpt<double>("imbalance,i",
+      "Imbalance tolerance (used in PHG/Hypergraph method)", &imbal_tol);
 
   int power = -1;
-  opts.addOpt<int>( "power,m", "Generate multiple partitions, in powers of 2, up to 2^(pow)", &power);
+  opts.addOpt<int>("power,m",
+      "Generate multiple partitions, in powers of 2, up to 2^(pow)", &power);
 
   bool reorder = false;
-  opts.addOpt<void>( "reorder,R", "Reorder mesh to group entities by partition", &reorder);
+  opts.addOpt<void>("reorder,R", "Reorder mesh to group entities by partition",
+      &reorder);
 
   double part_geom_mesh_size = -1.0;
-  opts.addOpt<double>( "geom,g", "If partition geometry, specify mesh size.", &part_geom_mesh_size);
+  opts.addOpt<double>("geom,g", "If partition geometry, specify mesh size.",
+      &part_geom_mesh_size);
 
   bool part_surf = false;
-  opts.addOpt<void>( "surf,f", "Specify if partition geometry surface.", &part_surf);
+  opts.addOpt<void>("surf,f", "Specify if partition geometry surface.",
+      &part_surf);
 
   bool ghost = false;
   long num_parts;
-  opts.addOpt<void>( "ghost,h", "Specify if partition ghost geometry body.");
+  opts.addOpt<void>("ghost,h", "Specify if partition ghost geometry body.");
 
   int obj_weight = 0;
-  opts.addOpt<int>( "vertex_w,v", "Number of weights associated with a graph vertex.");
+  opts.addOpt<int>("vertex_w,v",
+      "Number of weights associated with a graph vertex.");
 
   int edge_weight = 0;
-  opts.addOpt<int>( "edge_w,e", "Number of weights associated with an edge.");
-  opts.addOpt<std::vector<int> >("set_l,l", "Load material set(s) with specified ids (comma seperated) for partition");
+  opts.addOpt<int>("edge_w,e", "Number of weights associated with an edge.");
+  opts.addOpt<std::vector<int> >("set_l,l",
+      "Load material set(s) with specified ids (comma seperated) for partition");
 
-  opts.addRequiredArg<int>( "#parts", "Number of parts in partition" );
+  opts.addRequiredArg<int>("#parts", "Number of parts in partition");
 
   std::string input_file, output_file;
-  opts.addRequiredArg<std::string>( "input_file", "Mesh/geometry to partition", &input_file );
-  opts.addRequiredArg<std::string>( "output_file", "File to which to write partitioned mesh/geometry", &output_file );
+  opts.addRequiredArg<std::string>("input_file", "Mesh/geometry to partition",
+      &input_file);
+  opts.addRequiredArg<std::string>("output_file",
+      "File to which to write partitioned mesh/geometry", &output_file);
 
   bool print_time = false;
-  opts.addOpt<void>( ",T", "Print CPU time for each phase.", &print_time);
+  opts.addOpt<void>(",T", "Print CPU time for each phase.", &print_time);
 
-  opts.parseCommandLine( argc, argv ); 
+  opts.parseCommandLine(argc, argv);
 
   MBZoltan *tool = NULL;
 
   // check if partition geometry, if it is, should get mesh size for the geometry
-  if (part_geom_mesh_size != -1.0 && part_geom_mesh_size <= 0.0) {
-    std::cerr << part_geom_mesh_size << ": invalid geometry partition mesh size." << std::endl;
+  if (part_geom_mesh_size != -1.0 && part_geom_mesh_size <= 0.0)
+  {
+    std::cerr << part_geom_mesh_size
+        << ": invalid geometry partition mesh size." << std::endl;
     return 1;
   }
 
-  if (part_geom_mesh_size < 0.) { // partition mesh
-    tool = new MBZoltan (&mb, false, argc, argv);
+  if (part_geom_mesh_size < 0.)
+  { // partition mesh
+    tool = new MBZoltan(&mb, false, argc, argv);
   }
-  else { // partition geometry
+  else
+  { // partition geometry
 #ifdef CGM
-    CubitStatus status = InitCGMA::initialize_cgma();
-    if (CUBIT_SUCCESS != status) {
-      std::cerr << "CGM couldn't be initialized." << std::endl;
-      return 1;
-    }
-    GeometryQueryTool *gti = GeometryQueryTool::instance();
-    tool = new MBZoltan (&mb, false, argc, argv, gti);
+  CubitStatus status = InitCGMA::initialize_cgma();
+  if (CUBIT_SUCCESS != status)
+  {
+    std::cerr << "CGM couldn't be initialized." << std::endl;
+    return 1;
+  }
+  GeometryQueryTool *gti = GeometryQueryTool::instance();
+  tool = new MBZoltan (&mb, false, argc, argv, gti);
 #else
     std::cerr << "CGM should be configured to partition geometry." << std::endl;
     return 1;
@@ -131,36 +151,45 @@ int main( int argc, char* argv[] )
     zoltan_method = ZOLTAN_PARMETIS_METHOD;
   if (!oct_method.empty())
     zoltan_method = ZOLTAN_OCTPART_METHOD;
-  
-  if (!write_sets && !write_tags)
-    write_sets = true;
 
-  if (-1 == power) {
+  if (no_write_sets && !write_tags)
+    no_write_sets = false;
+
+  if (-1 == power)
+  {
     num_parts = opts.getReqArg<int>("#parts");
     power = 1;
   }
-  else if (power < 1 || power > 18) {
-    std::cerr << power << ": invalid power for multiple patitions. Expected value in [1,18]" << std::endl;
+  else if (power < 1 || power > 18)
+  {
+    std::cerr << power
+        << ": invalid power for multiple patitions. Expected value in [1,18]"
+        << std::endl;
     return 1;
   }
-  else {
+  else
+  {
     num_parts = 2;
   }
 
-  if (part_dim < 0 || part_dim > 3) {
+  if (part_dim < 0 || part_dim > 3)
+  {
     std::cerr << part_dim << " : invalid dimension" << std::endl;
     return 1;
   }
 
-  if (imbal_tol < 0.0) {
+  if (imbal_tol < 0.0)
+  {
     std::cerr << imbal_tol << ": invalid imbalance tolerance" << std::endl;
     return 1;
   }
 
   bool load_msets = false;
-  if (opts.getOpt( "set_l,l", &set_l )) {
+  if (opts.getOpt("set_l,l", &set_l))
+  {
     load_msets = true;
-    if (set_l.size() <= 0) {
+    if (set_l.size() <= 0)
+    {
       std::cerr << " No material set id's to load" << std::endl;
       return 1;
     }
@@ -170,132 +199,161 @@ int main( int argc, char* argv[] )
 
   const char* options = NULL;
   ErrorCode rval;
-  if (part_geom_mesh_size > 0.) options = "FACET_DISTANCE_TOLERANCE=0.1";
+  if (part_geom_mesh_size > 0.)
+    options = "FACET_DISTANCE_TOLERANCE=0.1";
   std::cout << "Loading file " << input_file << "..." << std::endl;
-  if(load_msets == false){	  
-    rval = mb.load_file( input_file.c_str(), 0, options );
-    if (MB_SUCCESS != rval) {
+  if (load_msets == false)
+  {
+    rval = mb.load_file(input_file.c_str(), 0, options);
+    if (MB_SUCCESS != rval)
+    {
       std::cerr << input_file << " : failed to read file." << std::endl;
-      std::cerr << "  Error code: " << mb.get_error_string(rval) << " (" << rval << ")" << std::endl;
+      std::cerr << "  Error code: " << mb.get_error_string(rval) << " (" << rval
+          << ")" << std::endl;
       std::string errstr;
       mb.get_last_error(errstr);
       if (!errstr.empty())
-	std::cerr << "  Error message: " << errstr << std::endl;
+        std::cerr << "  Error message: " << errstr << std::endl;
       return 2;
     }
   }
   // load the material set(s)
-  else{ 
-    rval = mb.load_mesh(input_file.c_str(), &set_l[0], (int)set_l.size());
-    if (MB_SUCCESS != rval) {
+  else
+  {
+    rval = mb.load_mesh(input_file.c_str(), &set_l[0], (int) set_l.size());
+    if (MB_SUCCESS != rval)
+    {
       std::cerr << input_file << " : failed to read file." << std::endl;
-      std::cerr << "  Error code: " << mb.get_error_string(rval) << " (" << rval << ")" << std::endl;
+      std::cerr << "  Error code: " << mb.get_error_string(rval) << " (" << rval
+          << ")" << std::endl;
       std::string errstr;
       mb.get_last_error(errstr);
       if (!errstr.empty())
-	std::cerr << "  Error message: " << errstr << std::endl;
+        std::cerr << "  Error message: " << errstr << std::endl;
       return 2;
     }
   }
   if (print_time)
-    std::cout << "Read input file in " << (clock() - t)/(double)CLOCKS_PER_SEC << " seconds" << std::endl;
-  
-  for (int dim = part_dim; dim >= 0; --dim) {
+    std::cout << "Read input file in "
+        << (clock() - t) / (double) CLOCKS_PER_SEC << " seconds" << std::endl;
+
+  for (int dim = part_dim; dim >= 0; --dim)
+  {
     int n;
-    rval = mb.get_number_entities_by_dimension( 0, dim, n );
-    if (MB_SUCCESS == rval && 0 != n) {
+    rval = mb.get_number_entities_by_dimension(0, dim, n);
+    if (MB_SUCCESS == rval && 0 != n)
+    {
       part_dim = dim;
       break;
     }
   }
-  if (part_dim < 0) {
-    std::cerr << input_file << " : file does not contain any mesh entities" << std::endl;
+  if (part_dim < 0)
+  {
+    std::cerr << input_file << " : file does not contain any mesh entities"
+        << std::endl;
     return 2;
   }
-  
+
   ReorderTool reorder_tool(&moab);
 
-  for (int p = 0; p < power; p++) {
+  for (int p = 0; p < power; p++)
+  {
     t = clock();
-    rval = tool->partition_mesh_geom( part_geom_mesh_size, num_parts, zoltan_method.c_str(), 
-                                      (!parm_method.empty() ? parm_method.c_str() : oct_method.c_str()),
-                                      imbal_tol, write_sets, write_tags, part_dim, obj_weight, edge_weight,
-                                      part_surf, ghost );
-    if (MB_SUCCESS != rval) {
+    rval = tool->partition_mesh_geom(part_geom_mesh_size, num_parts,
+        zoltan_method.c_str(),
+        (!parm_method.empty() ? parm_method.c_str() : oct_method.c_str()),
+        imbal_tol, !no_write_sets, write_tags, part_dim, obj_weight,
+        edge_weight, part_surf, ghost, print_time);
+    if (MB_SUCCESS != rval)
+    {
       std::cerr << "Partitioner failed!" << std::endl;
-      std::cerr << "  Error code: " << mb.get_error_string(rval) << " (" << rval << ")" << std::endl;
+      std::cerr << "  Error code: " << mb.get_error_string(rval) << " (" << rval
+          << ")" << std::endl;
       std::string errstr;
       mb.get_last_error(errstr);
       if (!errstr.empty())
         std::cerr << "  Error message: " << errstr << std::endl;
       return 3;
     }
-    if (print_time) 
+    if (print_time)
       std::cout << "Generated " << num_parts << " part partitioning in "
-		<< (clock() - t)/(double)CLOCKS_PER_SEC << " seconds" 
-		<< std::endl;
-    
-    if (reorder && part_geom_mesh_size < 0.) {
+          << (clock() - t) / (double) CLOCKS_PER_SEC << " seconds" << std::endl;
+
+    if (reorder && part_geom_mesh_size < 0.)
+    {
       std::cout << "Reordering mesh for partition..." << std::endl;
-      
+
       Tag tag, order;
-      rval = mb.tag_get_handle( "PARALLEL_PARTITION", 1, MB_TYPE_INTEGER, tag );
-      if (MB_SUCCESS != rval) {
-        std::cerr << "Partitioner did not create PARALLEL_PARTITION tag" << std::endl;
+      rval = mb.tag_get_handle("PARALLEL_PARTITION", 1, MB_TYPE_INTEGER, tag);
+      if (MB_SUCCESS != rval)
+      {
+        std::cerr << "Partitioner did not create PARALLEL_PARTITION tag"
+            << std::endl;
         return 2;
       }
-      
+
       t = clock();
-      if (write_sets) {
+      if (!no_write_sets)
+      {
         Range sets;
-        mb.get_entities_by_type_and_tag( 0, MBENTITYSET, &tag, 0, 1, sets );
-        rval = reorder_tool.handle_order_from_sets_and_adj( sets, order );
+        mb.get_entities_by_type_and_tag(0, MBENTITYSET, &tag, 0, 1, sets);
+        rval = reorder_tool.handle_order_from_sets_and_adj(sets, order);
       }
-      else {
-        rval = reorder_tool.handle_order_from_int_tag( tag, -1, order );
+      else
+      {
+        rval = reorder_tool.handle_order_from_int_tag(tag, -1, order);
       }
-      if (MB_SUCCESS != rval) {
+      if (MB_SUCCESS != rval)
+      {
         std::cerr << "Failed to calculate reordering!" << std::endl;
         return 2;
       }
-      
-      rval = reorder_tool.reorder_entities( order );
-      if (MB_SUCCESS != rval) {
+
+      rval = reorder_tool.reorder_entities(order);
+      if (MB_SUCCESS != rval)
+      {
         std::cerr << "Failed to perform reordering!" << std::endl;
         return 2;
       }
-      
-      mb.tag_delete( order );
-      if (print_time) 
+
+      mb.tag_delete(order);
+      if (print_time)
         std::cout << "Reorderd mesh in "
-                  << (clock() - t)/(double)CLOCKS_PER_SEC << " seconds" 
-                  << std::endl;
+            << (clock() - t) / (double) CLOCKS_PER_SEC << " seconds"
+            << std::endl;
     }
 
-    if (incl_closure) {
+    if (incl_closure)
+    {
       rval = tool->include_closure();
-      if (MB_SUCCESS != rval) {
+      if (MB_SUCCESS != rval)
+      {
         std::cerr << "Closure inclusion failed." << std::endl;
         return 1;
       }
     }
-  
+
     std::ostringstream tmp_output_file;
-    
-    if (power > 1) {
+
+    if (power > 1)
+    {
       // append num_parts to output filename
-      std::string::size_type idx = output_file.find_last_of( "." );
-      if (idx == std::string::npos) {
+      std::string::size_type idx = output_file.find_last_of(".");
+      if (idx == std::string::npos)
+      {
         tmp_output_file << output_file << "_" << num_parts;
-        if (part_geom_mesh_size < 0.) tmp_output_file << ".h5m";
-        else {
+        if (part_geom_mesh_size < 0.)
+          tmp_output_file << ".h5m";
+        else
+        {
           std::cerr << "output file type is not specified." << std::endl;
           return 1;
         }
       }
-      else {
+      else
+      {
         tmp_output_file << output_file.substr(0, idx) << "_" << num_parts
-                        << output_file.substr(idx);
+            << output_file.substr(idx);
       }
     }
     else
@@ -303,11 +361,14 @@ int main( int argc, char* argv[] )
 
     t = clock();
     std::cout << "Saving file to " << output_file << "..." << std::endl;
-    if (part_geom_mesh_size < 0.) {
-      rval = mb.write_file( tmp_output_file.str().c_str() );
-      if (MB_SUCCESS != rval) {
+    if (part_geom_mesh_size < 0.)
+    {
+      rval = mb.write_file(tmp_output_file.str().c_str());
+      if (MB_SUCCESS != rval)
+      {
         std::cerr << tmp_output_file << " : failed to write file." << std::endl;
-        std::cerr << "  Error code: " << mb.get_error_string(rval) << " (" << rval << ")" << std::endl;
+        std::cerr << "  Error code: " << mb.get_error_string(rval) << " ("
+            << rval << ")" << std::endl;
         std::string errstr;
         mb.get_last_error(errstr);
         if (!errstr.empty())
@@ -315,7 +376,8 @@ int main( int argc, char* argv[] )
         return 2;
       }
     }
-    else {
+    else
+    {
 #ifdef CGM
       std::string::size_type idx = output_file.find_last_of( "." );
       int c_size = output_file.length() - idx;
@@ -324,7 +386,8 @@ int main( int argc, char* argv[] )
           || output_file.compare(idx, c_size, ".OCC") == 0) file_type = "OCC";
       else if (output_file.compare(idx, c_size, ".sab") == 0) file_type = "ACIS_SAB";
       else if (output_file.compare(idx, c_size, ".sat") == 0) file_type = "ACIS_SAT";
-      else {
+      else
+      {
         std::cerr << "File type for " << output_file.c_str() << " not supported." << std::endl;
         return 1;
       }
@@ -332,25 +395,25 @@ int main( int argc, char* argv[] )
       int junk;
       DLIList<RefEntity*> ref_entity_list;
       CubitStatus status = CubitCompat_export_solid_model(ref_entity_list,
-							  tmp_output_file.str().c_str(),
-							  file_type, junk,
-							  CubitString(__FILE__));
-      if (CUBIT_SUCCESS != status) {
+          tmp_output_file.str().c_str(),
+          file_type, junk,
+          CubitString(__FILE__));
+      if (CUBIT_SUCCESS != status)
+      {
         std::cerr << "CGM couldn't export models." << std::endl;
         return 1;
       }
 #endif
     }
-    
+
     if (print_time)
       std::cout << "Wrote \"" << tmp_output_file.str() << "\" in "
-                << (clock() - t)/(double)CLOCKS_PER_SEC << " seconds" 
-                << std::endl;
-                
+          << (clock() - t) / (double) CLOCKS_PER_SEC << " seconds" << std::endl;
+
     num_parts *= 2;
   }
 
   delete tool;
-  
-  return 0;    
+
+  return 0;
 }

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