[MOAB-dev] r2294 - MOAB/trunk/refiner

dcthomp at mcs.anl.gov dcthomp at mcs.anl.gov
Tue Dec 2 00:26:44 CST 2008


Author: dcthomp
Date: 2008-12-02 00:26:44 -0600 (Tue, 02 Dec 2008)
New Revision: 2294

Modified:
   MOAB/trunk/refiner/MBMeshOutputFunctor.cpp
   MOAB/trunk/refiner/MBProcessSet.cpp
   MOAB/trunk/refiner/MBRefinerTagManager.cpp
   MOAB/trunk/refiner/MBSplitVertices.cpp
   MOAB/trunk/refiner/MBSplitVertices.hpp
   MOAB/trunk/refiner/test_mesh_refiner.cpp
Log:
BUG: Use "unsigned char" in MBProcessSet iteration to
     properly handle bit vectors with high bit set.
ENH: Compile out many print statements unless MB_DEBUG is defined.


Modified: MOAB/trunk/refiner/MBMeshOutputFunctor.cpp
===================================================================
--- MOAB/trunk/refiner/MBMeshOutputFunctor.cpp	2008-12-01 20:16:35 UTC (rev 2293)
+++ MOAB/trunk/refiner/MBMeshOutputFunctor.cpp	2008-12-02 06:26:44 UTC (rev 2294)
@@ -9,6 +9,8 @@
 #include <iterator>
 #include <algorithm>
 
+#undef MB_DEBUG
+
 MBMeshOutputFunctor::MBMeshOutputFunctor( MBRefinerTagManager* tag_mgr )
 {
   this->mesh_in  = tag_mgr->get_input_mesh();
@@ -84,7 +86,9 @@
   std::vector<int> lpsizes;
   lpdefns.resize( MBProcessSet::SHARED_PROC_BYTES * lnparts );
   lpsizes.resize( lnparts );
+#ifdef MB_DEBUG
   std::cout << "**** Partition Counts ****\n";
+#endif // MB_DEBUG
   int i = 0;
   std::map<MBProcessSet,int>::iterator it;
   for ( it = this->proc_partition_counts.begin(); it != this->proc_partition_counts.end(); ++ it, ++ i )
@@ -92,7 +96,9 @@
     for ( int j = 0; j < MBProcessSet::SHARED_PROC_BYTES; ++ j )
       lpdefns[MBProcessSet::SHARED_PROC_BYTES * i + j] = it->first.data()[j];
     lpsizes[i] = it->second;
+#ifdef MB_DEBUG
     std::cout << "Partition " << it->first << ": " << it->second << "\n";
+#endif // MB_DEBUG
     }
 
   if ( ! comm )
@@ -109,7 +115,9 @@
   for ( int rank = 1; rank <= psize; ++ rank )
     {
     dparts[rank] = nparts[rank - 1] + dparts[rank - 1];
+#ifdef MB_DEBUG
     std::cout << "Proc " << rank << ": " << nparts[rank-1] << " partitions, offset: " << dparts[rank] << "\n";
+#endif // MB_DEBUG
     }
   std::vector<unsigned char> part_defns;
   std::vector<int> part_sizes;
@@ -137,7 +145,9 @@
     std::map<MBProcessSet,int>::iterator it = this->proc_partition_counts.find( pset );
     if ( it != this->proc_partition_counts.end() )
       {
+#ifdef MB_DEBUG
       std::cout << "Partition " << pset << ( it->second == part_sizes[i] ? " matches" : " broken" ) << ".\n";
+#endif // MB_DEBUG
       }
     else
       {
@@ -151,7 +161,9 @@
     {
     gids[pcit->first] = start_gid;
     start_gid += pcit->second;
+#ifdef MB_DEBUG
     std::cout << "Partition " << pcit->first << ": " << pcit->second << " # [" << gids[pcit->first] << "]\n";
+#endif // MB_DEBUG
     }
   std::vector<MBSplitVerticesBase*>::iterator vit;
   vit = this->split_vertices.begin();
@@ -192,7 +204,9 @@
 {
   if ( this->input_is_output )
     { // Don't copy the original vertex!
+#ifdef MB_DEBUG
     this->print_vert_crud( vhash, 1, &vhash, vcoords, vtags );
+#endif // MB_DEBUG
     return vhash;
     }
   MBEntityHandle vertex_handle;
@@ -211,8 +225,10 @@
     {
     std::cerr << "Could not insert vertex into new mesh!\n";
     }
+#ifdef MB_DEBUG
   this->print_vert_crud( vertex_handle, 1, &vhash, vcoords, vtags );
   std::cout << "\nMap vert: " << vhash << " to: " << vertex_handle << "\n";
+#endif // MB_DEBUG
   return vertex_handle;
 }
 
@@ -231,8 +247,10 @@
       {
       std::cerr << "Could not insert mid-edge vertex!\n";
       }
+#ifdef MB_DEBUG
     std::cout << "(-" << nvhash << "-) ";
     this->print_vert_crud( vertex_handle, nvhash, vhash, vcoords, vtags );
+#endif // MB_DEBUG
     }
   else
     {
@@ -244,7 +262,9 @@
 
 void MBMeshOutputFunctor::operator () ( MBEntityHandle h )
 {
+#ifdef MB_DEBUG
   std::cout << h << " ";
+#endif // MB_DEBUG
   if ( ! this->input_is_output )
     {
     // FIXME: Copy to output mesh
@@ -260,11 +280,15 @@
     etyp, nconn, &this->elem_vert[0], elem_handle, this->proc_partition_counts );
   if ( newly_created )
     {
+#ifdef MB_DEBUG
     std::cout << " *** ";
+#endif // MB_DEBUG
     // FIXME: Handle tag assignment for elements as well as vertices
     this->tag_manager->assign_element_tags( elem_handle );
     }
+#ifdef MB_DEBUG
   std::cout << "---------> " << elem_handle << " ( " << etyp << " )\n\n";
+#endif // MB_DEBUG
   this->elem_vert.clear();
 }
 

Modified: MOAB/trunk/refiner/MBProcessSet.cpp
===================================================================
--- MOAB/trunk/refiner/MBProcessSet.cpp	2008-12-01 20:16:35 UTC (rev 2293)
+++ MOAB/trunk/refiner/MBProcessSet.cpp	2008-12-02 06:26:44 UTC (rev 2294)
@@ -79,13 +79,13 @@
   for ( int byte = 0; byte < SHARED_PROC_BYTES; ++ byte )
     {
     i = byte * 8;
-    for ( char val = this->processes[byte]; val; ++ i, val >>= 1 )
+    for ( unsigned char val = this->processes[byte]; val; ++ i, val >>= 1 )
       {
       if ( val & 0x1 )
         {
         if ( i != rank )
           {
-          std::cout << " " << i;
+          //std::cout << " " << i;
           procs.push_back( i );
           }
         else if ( ! procs.size() )

Modified: MOAB/trunk/refiner/MBRefinerTagManager.cpp
===================================================================
--- MOAB/trunk/refiner/MBRefinerTagManager.cpp	2008-12-01 20:16:35 UTC (rev 2293)
+++ MOAB/trunk/refiner/MBRefinerTagManager.cpp	2008-12-02 06:26:44 UTC (rev 2294)
@@ -9,6 +9,8 @@
 #include <stdexcept>
 #include <assert.h>
 
+#undef MB_DEBUG
+
 /// Construct an evaluator.
 MBRefinerTagManager::MBRefinerTagManager( MBInterface* in_mesh, MBInterface* out_mesh )
   : shared_procs_in( 5 * MAX_SHARING_PROCS, -1 ), shared_procs_out( MAX_SHARING_PROCS, -1 )
@@ -28,7 +30,9 @@
     opcomm = MBParallelComm::get_pcomm( this->output_mesh, 0 );
     if ( ! opcomm )
       {
+#ifdef MB_DEBUG
       std::cout << "Creating opcomm: " << opcomm << "\n";
+#endif // MB_DEBUG
       opcomm = new MBParallelComm( this->output_mesh, MPI_COMM_WORLD );
       }
     }
@@ -85,6 +89,7 @@
     throw new std::logic_error( "Unable to find/create output mesh global ID tag \"" GLOBAL_ID_TAG_NAME "\"" );
     }
 
+#ifdef MB_DEBUG
   std::cout
     << "psproc:  " << this->tag_ipsproc  << ", " << this->tag_opsproc << "\n"
     << "psprocs: " << this->tag_ipsprocs << ", " << this->tag_opsprocs << "\n"
@@ -92,6 +97,7 @@
     << "pshands: " << this->tag_ipshands << ", " << this->tag_opshands << "\n"
     << "pstatus: " << this->tag_ipstatus << ", " << this->tag_opstatus << "\n"
     << "gid:     " << this->tag_igid     << ", " << this->tag_ogid     << "\n";
+#endif // MB_DEBUG
 }
 
 /// Destruction is virtual so subclasses may clean up after refinement.
@@ -455,8 +461,10 @@
       common_shared_procs.set_process_member( this->rank );
       }
     }
+#ifdef MB_DEBUG
   std::cout << "    Common procs " << common_shared_procs;
   std::cout << "\n";
+#endif // MB_DEBUG
 }
 
 void MBRefinerTagManager::create_tag_internal( MBTag tag_in, int offset )
@@ -477,9 +485,11 @@
   tag_default.resize( tag_size );
   MBErrorCode res = this->output_mesh->tag_create(
     tag_name.c_str(), tag_size, tag_type, tag_data_type, tag_rec.first, (void*) &tag_default[0], true );
+#ifdef MB_DEBUG
   std::cout
     << "Creating output tag: \"" << tag_name.c_str() << "\" handle: " << tag_rec.first
     << " input handle: " << tag_in << "\n";
+#endif // MB_DEBUG
   if ( res == MB_FAILURE )
     {
     std::cerr

Modified: MOAB/trunk/refiner/MBSplitVertices.cpp
===================================================================
--- MOAB/trunk/refiner/MBSplitVertices.cpp	2008-12-01 20:16:35 UTC (rev 2293)
+++ MOAB/trunk/refiner/MBSplitVertices.cpp	2008-12-02 06:26:44 UTC (rev 2294)
@@ -59,7 +59,9 @@
     {
     int gid = gids[it->process_set] ++;
     this->tag_manager->set_gid( it->handle, gid );
+#ifdef MB_DEBUG
     std::cout << "Assigning entity: " << it->handle << " GID: " << gid << "\n";
+#endif // MB_DEBUG
     }
 }
 

Modified: MOAB/trunk/refiner/MBSplitVertices.hpp
===================================================================
--- MOAB/trunk/refiner/MBSplitVertices.hpp	2008-12-01 20:16:35 UTC (rev 2293)
+++ MOAB/trunk/refiner/MBSplitVertices.hpp	2008-12-02 06:26:44 UTC (rev 2294)
@@ -29,6 +29,8 @@
 #include <vector>
 #include <algorithm>
 
+#undef MB_DEBUG
+
 class MBRefinerTagManager;
 
 template< int _n >
@@ -219,7 +221,9 @@
   MapIteratorType it = this->find( key );
   if ( it == this->end() )
     {
+#ifdef MB_DEBUG
     std::cout << " wrt output: " << handles_on_output_mesh << " ";
+#endif // MB_DEBUG
     this->tag_manager->get_common_processes( _n, split_src, this->common_shared_procs, handles_on_output_mesh );
     proc_partition_counts[this->common_shared_procs]++;
     key.set_common_processes( this->common_shared_procs );
@@ -243,7 +247,9 @@
     {
     int gid = gids[it->first.process_set] ++;
     this->tag_manager->set_gid( it->second, gid );
+#ifdef MB_DEBUG
     std::cout << "Assigning entity: " << it->first << " GID: " << gid << "\n";
+#endif // MB_DEBUG
     }
 }
 

Modified: MOAB/trunk/refiner/test_mesh_refiner.cpp
===================================================================
--- MOAB/trunk/refiner/test_mesh_refiner.cpp	2008-12-01 20:16:35 UTC (rev 2293)
+++ MOAB/trunk/refiner/test_mesh_refiner.cpp	2008-12-02 06:26:44 UTC (rev 2294)
@@ -16,6 +16,8 @@
 #include <sstream>
 #include <map>
 
+#include "sys/time.h"
+
 int TestMeshRefiner( int argc, char* argv[] )
 {
   int nprocs, rank;
@@ -54,6 +56,7 @@
 #ifdef USE_MPI
   //readpar->load_file( ifname, set_handle, FileOptions( parallel_options.str().c_str() ), 0, 0 );
   imesh->load_file( ifname, set_handle, parallel_options.str().c_str() );
+#  if 0
   // Print out what we have so far, one process at a time
   for ( int i = 0; i < nprocs; ++ i )
     {
@@ -66,6 +69,7 @@
       }
     MPI_Barrier( MPI_COMM_WORLD );
     }
+#  endif // 0
 #else // USE_MPI
   imesh->load_file( ifname, set_handle, parallel_options.str().c_str() );
   imesh->list_entities( 0, 1 );
@@ -88,13 +92,18 @@
   MBRange ents_to_refine;
   imesh->get_entities_by_type( set_handle, MBTET, ents_to_refine ); // refine just the tets
   //ents_to_refine.insert( set_handle ); // refine everything multiple times (because subsets are not disjoint)
+  struct timeval tic, toc;
+  gettimeofday( &tic, 0 );
   mref->refine( ents_to_refine );
+  gettimeofday( &toc, 0 );
+  std::cout << "\nTime: " << ( (toc.tv_sec - tic.tv_sec) * 1000 + (toc.tv_usec - tic.tv_usec) / 1000. ) << " ms\n\n";
 
   std::ostringstream ofs;
   ofs << "refiner." << nprocs << "." << rank << ".vtk";
   omesh->write_mesh( ofs.str().c_str() );
   // Print out the results, one process at a time
 #ifdef USE_MPI
+#  if 0
   for ( int i = 0; i < nprocs; ++ i )
     {
     MPI_Barrier( MPI_COMM_WORLD );
@@ -106,6 +115,7 @@
       }
     MPI_Barrier( MPI_COMM_WORLD );
     }
+#  endif // 0
 #else // USE_MPI
   omesh->list_entities( 0, 1 );
 #endif // USE_MPI




More information about the moab-dev mailing list