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

dcthomp at mcs.anl.gov dcthomp at mcs.anl.gov
Fri Jun 13 00:53:14 CDT 2008


Author: dcthomp
Date: 2008-06-13 00:53:13 -0500 (Fri, 13 Jun 2008)
New Revision: 1893

Modified:
   MOAB/trunk/refiner/MBEdgeSizeEvaluator.cpp
   MOAB/trunk/refiner/MBEdgeSizeEvaluator.hpp
   MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.cpp
   MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.hpp
   MOAB/trunk/refiner/MBEntityRefiner.cpp
   MOAB/trunk/refiner/MBMeshRefiner.cpp
   MOAB/trunk/refiner/MBRefinerTagManager.cpp
   MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp
   MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp
   MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp
   MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp
   MOAB/trunk/refiner/test_mesh_refiner.cpp
Log:
ENH: Further rearrangement of MBRefinementTagManager (now
     MBEdgeSizeEvaluator "has a" instead of "is a").
ENH: Better debug output from test_mesh_refiner in parallel mode.
BUG: Tag manager had bad loop boundaries (testing wrong vector's end()).


Modified: MOAB/trunk/refiner/MBEdgeSizeEvaluator.cpp
===================================================================
--- MOAB/trunk/refiner/MBEdgeSizeEvaluator.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBEdgeSizeEvaluator.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -1,13 +1,14 @@
 #include "MBEdgeSizeEvaluator.hpp"
 
+#include "MBRefinerTagManager.hpp"
 #include "MBInterface.hpp"
 
 #include <assert.h>
 
 /// Construct an evaluator.
-MBEdgeSizeEvaluator::MBEdgeSizeEvaluator( MBInterface* mesh_in, MBInterface* mesh_out )
-  : MBRefinerTagManager( mesh_in, mesh_out )
+MBEdgeSizeEvaluator::MBEdgeSizeEvaluator( MBRefinerTagManager* tag_mgr )
 {
+  this->tag_manager = tag_mgr;
 }
 
 /// Destruction is virtual so subclasses may clean up after refinement.

Modified: MOAB/trunk/refiner/MBEdgeSizeEvaluator.hpp
===================================================================
--- MOAB/trunk/refiner/MBEdgeSizeEvaluator.hpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBEdgeSizeEvaluator.hpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -28,16 +28,21 @@
 
 #include "MBRefinerTagManager.hpp"
 
-class MB_DLL_EXPORT MBEdgeSizeEvaluator : public MBRefinerTagManager
+class MB_DLL_EXPORT MBEdgeSizeEvaluator
 {
 public:
-  MBEdgeSizeEvaluator( MBInterface*, MBInterface* );
+  MBEdgeSizeEvaluator( MBRefinerTagManager* );
   virtual ~MBEdgeSizeEvaluator();
 
   virtual bool evaluate_edge(
     const double* p0, const void* t0,
     double* p1, void* t1,
     const double* p2, const void* t2 ) = 0;
+
+  MBRefinerTagManager* get_tag_manager() { return this->tag_manager; }
+
+protected:
+  MBRefinerTagManager* tag_manager;
 };
 
 #endif // MB_EDGESIZEEVALUATOR_H

Modified: MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.cpp
===================================================================
--- MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -1,7 +1,7 @@
 #include "MBEdgeSizeSimpleImplicit.hpp"
 
-MBEdgeSizeSimpleImplicit::MBEdgeSizeSimpleImplicit( MBInterface* mesh_in, MBInterface* mesh_out )
-  : MBEdgeSizeEvaluator( mesh_in, mesh_out )
+MBEdgeSizeSimpleImplicit::MBEdgeSizeSimpleImplicit( MBRefinerTagManager* tag_mgr )
+  : MBEdgeSizeEvaluator( tag_mgr )
 {
   int i;
   // Default to the plane: x = 0.

Modified: MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.hpp
===================================================================
--- MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.hpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBEdgeSizeSimpleImplicit.hpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -36,7 +36,7 @@
 {
 public:
   /// Construct an evaluator.
-  MBEdgeSizeSimpleImplicit( MBInterface*, MBInterface* );
+  MBEdgeSizeSimpleImplicit( MBRefinerTagManager* );
   /// Destruction is virtual so subclasses may clean up after refinement.
   virtual ~MBEdgeSizeSimpleImplicit();
 

Modified: MOAB/trunk/refiner/MBEntityRefiner.cpp
===================================================================
--- MOAB/trunk/refiner/MBEntityRefiner.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBEntityRefiner.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -154,7 +154,7 @@
   this->coord_heap.resize( 6 * n );
   if ( this->edge_size_evaluator )
     {
-    unsigned long m = this->edge_size_evaluator->get_vertex_tag_size();
+    unsigned long m = this->edge_size_evaluator->get_tag_manager()->get_vertex_tag_size();
     this->tag_heap.resize( m * n );
     }
 }
@@ -200,7 +200,7 @@
   if ( this->edge_size_evaluator && this->current_tag != this->tag_heap.end() )
     {
     rval = (void*) &(*this->current_tag);
-    this->current_tag += this->edge_size_evaluator->get_vertex_tag_size();
+    this->current_tag += this->edge_size_evaluator->get_tag_manager()->get_vertex_tag_size();
     }
   else
     {

Modified: MOAB/trunk/refiner/MBMeshRefiner.cpp
===================================================================
--- MOAB/trunk/refiner/MBMeshRefiner.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBMeshRefiner.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -113,7 +113,7 @@
     int tag_offset;
     for ( int i = 0; i < num_tags; ++i )
       {
-      this->edge_size_evaluator->get_output_vertex_tag( i, tag_handle, tag_offset );
+      this->edge_size_evaluator->get_tag_manager()->get_output_vertex_tag( i, tag_handle, tag_offset );
       this->mesh->tag_set_data( tag_handle, &vertex_handle, 1, (char*)vtags + tag_offset );
       }
     return vertex_handle;
@@ -133,7 +133,7 @@
     int tag_offset;
     for ( int i = 0; i < num_tags; ++i )
       {
-      this->edge_size_evaluator->get_output_vertex_tag( i, tag_handle, tag_offset );
+      this->edge_size_evaluator->get_tag_manager()->get_output_vertex_tag( i, tag_handle, tag_offset );
       this->mesh->tag_set_data( tag_handle, &hv, 1, (char*)vtags + tag_offset );
       }
     return hv;

Modified: MOAB/trunk/refiner/MBRefinerTagManager.cpp
===================================================================
--- MOAB/trunk/refiner/MBRefinerTagManager.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBRefinerTagManager.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -113,7 +113,7 @@
   MBTagType tag_type;
   MBDataType tag_data_type;
   int tag_size;
-  for ( it = this->input_vertex_tags.begin(); it != this->output_vertex_tags.end(); ++ it )
+  for ( it = this->input_vertex_tags.begin(); it != this->input_vertex_tags.end(); ++ it )
     {
     MBTag tag_in = it->first;
     tag_rec.second = it->second;
@@ -125,6 +125,9 @@
     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 );
+    std::cout
+      << "Creating output tag: \"" << tag_name.c_str() << "\" handle: " << tag_rec.first
+      << " input handle: " << tag_in << "\n";
     if ( res == MB_FAILURE )
       {
       std::cerr

Modified: MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -1,6 +1,8 @@
 #include "MBSimplexTemplateRefiner.hpp"
 
 #include "MBEdgeSizeEvaluator.hpp"
+#include "MBRefinerTagManager.hpp"
+
 #include "MBInterface.hpp"
 
 #include <iostream>
@@ -24,6 +26,7 @@
 MBSimplexTemplateRefiner::MBSimplexTemplateRefiner( MBInterface* mesh )
   : MBEntityRefiner( mesh )
 {
+  this->tag_manager = 0;
   this->tag_assigner = new MBSimplexTemplateTagAssigner( this );
   this->corner_coords.resize( 6 * 8 ); // Hex has 8 verts w/ 6 coordinates each
   this->corner_tags.resize( 8 ); // Hex has 8 verts (this is a pointer, not the actual tag data)
@@ -65,9 +68,9 @@
       return false;
       }
     tag_data = this->heap_tag_storage();
-    for ( int i = 0; i < this->edge_size_evaluator->get_number_of_vertex_tags(); ++ i )
+    for ( int i = 0; i < this->tag_manager->get_number_of_vertex_tags(); ++ i )
       {
-      this->edge_size_evaluator->get_input_vertex_tag( i, tag_handle, tag_offset );
+      this->tag_manager->get_input_vertex_tag( i, tag_handle, tag_offset );
       if ( this->mesh->tag_get_data( tag_handle, &conn[n], 1, (char*)tag_data + tag_offset ) != MB_SUCCESS )
         {
         return false;
@@ -170,6 +173,7 @@
   if ( this->MBEntityRefiner::set_edge_size_evaluator( es ) )
     {
     this->tag_assigner->set_edge_size_evaluator( es );
+    this->tag_manager = this->edge_size_evaluator->get_tag_manager();
     return true;
     }
   return false;

Modified: MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -34,6 +34,8 @@
 
 #include "MBTypes.h" // for MB_DLL_EXPORT
 
+class MBRefinerTagManager;
+
 class MB_DLL_EXPORT MBSimplexTemplateRefiner : public MBEntityRefiner
 {
 public:
@@ -50,6 +52,7 @@
 
 protected:
   MBSimplexTemplateTagAssigner* tag_assigner;
+  MBRefinerTagManager* tag_manager;
   std::vector<double> corner_coords;
   std::vector<void*> corner_tags;
   std::vector<MBEntityHandle> corner_handles;

Modified: MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -15,6 +15,9 @@
 {
   this->mesh_refiner = r;
   this->edge_size_evaluator = r->get_edge_size_evaluator();
+  this->tag_manager = 0;
+  if ( this->edge_size_evaluator )
+    this->tag_manager = this->edge_size_evaluator->get_tag_manager();
 }
 
 /// Empty destructor for good form.
@@ -56,12 +59,12 @@
   MBDataType data_type;
   int tag_size;
   int num_components;
-  int num_tags = this->edge_size_evaluator->get_number_of_vertex_tags();
+  int num_tags = this->tag_manager->get_number_of_vertex_tags();
   MBTag tag_handle;
   int tag_offset;
   for ( int i = 0; i < num_tags; ++i )
     {
-    this->edge_size_evaluator->get_input_vertex_tag( i, tag_handle, tag_offset );
+    this->tag_manager->get_input_vertex_tag( i, tag_handle, tag_offset );
     this->mesh_refiner->get_mesh()->tag_get_data_type( tag_handle, data_type );
     this->mesh_refiner->get_mesh()->tag_get_size( tag_handle, tag_size );
     
@@ -94,3 +97,10 @@
   (void)t2;
   (void)tp;
 }
+
+void MBSimplexTemplateTagAssigner::set_edge_size_evaluator( MBEdgeSizeEvaluator* es )
+{
+  this->edge_size_evaluator = es;
+  this->tag_manager = es ? es->get_tag_manager() : 0;
+}
+

Modified: MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -30,6 +30,7 @@
 #include "MBTypes.h" // for MB_DLL_EXPORT
 
 class MBEdgeSizeEvaluator;
+class MBRefinerTagManager;
 class MBSimplexTemplateRefiner;
 
 class MB_DLL_EXPORT MBSimplexTemplateTagAssigner
@@ -45,11 +46,12 @@
                              const void* t1,
                              const void* t2,
                              void* tp );
-  virtual void set_edge_size_evaluator( MBEdgeSizeEvaluator* es ) { this->edge_size_evaluator = es; }
+  virtual void set_edge_size_evaluator( MBEdgeSizeEvaluator* es );
 
 protected:
   MBSimplexTemplateRefiner* mesh_refiner;
   MBEdgeSizeEvaluator* edge_size_evaluator;
+  MBRefinerTagManager* tag_manager;
 };
 
 #endif // MB_SIMPLEXTEMPLATETAGASSIGNER_H

Modified: MOAB/trunk/refiner/test_mesh_refiner.cpp
===================================================================
--- MOAB/trunk/refiner/test_mesh_refiner.cpp	2008-06-13 01:30:49 UTC (rev 1892)
+++ MOAB/trunk/refiner/test_mesh_refiner.cpp	2008-06-13 05:53:13 UTC (rev 1893)
@@ -24,7 +24,7 @@
   MBSplitVertexIndex& operator = ( const MBSplitVertexIndex<_n>& src )
     { for ( int i = 0; i < _n; ++ i ) this->handles[i] = src.handles[i]; return *this; }
 
-  virtual bool operator < ( const MBSplitVertexIndex<_n>& other ) const
+  bool operator < ( const MBSplitVertexIndex<_n>& other ) const
     {
     for ( int i = 0; i < _n; ++ i )
       if ( this->handles[i] < other.handles[i] )
@@ -44,6 +44,7 @@
     {
     this->mesh = m;
     }
+  virtual ~MBSplitVerticesBase() { }
   virtual bool find_or_create( const MBEntityHandle* split_src, const double* coords, MBEntityHandle& vert_handle ) = 0;
   MBInterface* mesh;
 };
@@ -59,6 +60,7 @@
     : MBSplitVerticesBase( m )
     {
     }
+  virtual ~MBSplitVertices() { }
   virtual bool find_or_create( const MBEntityHandle* split_src, const double* coords, MBEntityHandle& vert_handle )
     {
     MapIteratorType it = this->find( MBSplitVertexIndex<_n>( split_src ) );
@@ -83,13 +85,13 @@
   bool input_is_output;
   std::vector<MBSplitVerticesBase*> split_vertices;
   std::vector<MBEntityHandle> elem_vert;
-  MBEdgeSizeEvaluator* edge_size_evaluator;
+  MBRefinerTagManager* tag_manager;
 
-  MBTestOutputFunctor( MBInterface* imesh, MBInterface* omesh, MBEdgeSizeEvaluator* size_eval )
+  MBTestOutputFunctor( MBInterface* imesh, MBInterface* omesh, MBRefinerTagManager* tag_mgr )
     {
     this->mesh = omesh;
     this->input_is_output = ( imesh == omesh );
-    this->edge_size_evaluator = size_eval;
+    this->tag_manager = tag_mgr;
 
     this->split_vertices.resize( 4 );
     this->split_vertices[0] = 0; // Vertices (0-faces) cannot be split
@@ -130,12 +132,12 @@
     if ( ! vhandle )
       return; // Ignore bad vertices
 
-    int num_tags = this->edge_size_evaluator->get_number_of_vertex_tags();
+    int num_tags = this->tag_manager->get_number_of_vertex_tags();
     MBTag tag_handle;
     int tag_offset;
     for ( int i = 0; i < num_tags; ++i )
       {
-      this->edge_size_evaluator->get_output_vertex_tag( i, tag_handle, tag_offset );
+      this->tag_manager->get_output_vertex_tag( i, tag_handle, tag_offset );
       this->mesh->tag_set_data( tag_handle, &vhandle, 1, vtags );
       }
     }
@@ -210,16 +212,27 @@
   int err = MPI_Init( &argc, &argv );
   err = MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
   err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-  std::cout << "Rank: " << ( rank + 1 ) << " of: " << nprocs << "\n";
 #else // USE_MPI
   nprocs = 1;
   rank = 0;
 #endif // USE_MPI
 
   bool input_is_output = ( argc > 1 && ! strcmp( argv[1], "-new-mesh" ) ) ? false : true;
-  MBInterface* imesh = new MBCore;
-  MBInterface* omesh = input_is_output ? imesh : new MBCore;
-  MBEdgeSizeSimpleImplicit* eval = new MBEdgeSizeSimpleImplicit( imesh, omesh );
+  MBInterface* imesh = new MBCore( rank, nprocs );
+  MBInterface* omesh = input_is_output ? imesh : new MBCore( rank, nprocs );
+#ifdef USE_MPI
+  for ( int i = 0; i < nprocs; ++ i )
+    {
+    MPI_Barrier( MPI_COMM_WORLD );
+    if ( i == rank )
+      {
+      std::cout << "Rank: " << ( rank + 1 ) << " of: " << nprocs << "\n";
+      }
+    MPI_Barrier( MPI_COMM_WORLD );
+    }
+#endif // USE_MPI
+  MBRefinerTagManager* tmgr = new MBRefinerTagManager( imesh, omesh );
+  MBEdgeSizeSimpleImplicit* eval = new MBEdgeSizeSimpleImplicit( tmgr );
 
   double coords[][6] = {
     {  0. ,  0.0,  0. ,  0. ,  0.0,  0.  }, // 0
@@ -280,7 +293,6 @@
 
   MBEntityHandle node_handles[4];
   MBEntityHandle tet_handle;
-  MBEntityHandle tri_handle;
 
   MBTag tag_floatular;
   imesh->tag_create( "floatular", 2 * sizeof( double ), MB_TAG_DENSE, MB_TYPE_DOUBLE, tag_floatular, default_floatular );
@@ -300,43 +312,70 @@
   void const* sptrs[4];
   for ( int i = 0; i < 4; ++ i )
     {
-    imesh->create_vertex( coords[proc_nodes[rank][i]], node_handles[i] );
-    iptrs[i] = (void const*) intular_values[proc_nodes[rank][i]];
-    fptrs[i] = (void const*) floatular_values[proc_nodes[rank][i]];
-    gptrs[i] = (void const*) &gid_values[proc_nodes[rank][i]];
-    sptrs[i] = (void const*) &node_procs[proc_nodes[rank][i]];
+    int pnode = proc_nodes[rank][i];
+    imesh->create_vertex( coords[pnode], node_handles[i] );
+    iptrs[i] = (void const*) intular_values[pnode];
+    fptrs[i] = (void const*) floatular_values[pnode];
+    gptrs[i] = (void const*) &gid_values[pnode];
+    sptrs[i] = (void const*) &node_procs[pnode];
     }
 
   imesh->tag_set_data( tag_floatular, node_handles, 4, fptrs, 0 );
-  eval->add_vertex_tag( tag_floatular );
+  tmgr->add_vertex_tag( tag_floatular );
 
   imesh->tag_set_data( tag_intular, node_handles, 4, iptrs, 0 );
-  eval->add_vertex_tag( tag_intular );
+  tmgr->add_vertex_tag( tag_intular );
 
   imesh->tag_set_data( tag_gid, node_handles, 4, gptrs, 0 );
   imesh->tag_set_data( tag_spr, node_handles, 4, sptrs, 0 );
 
   imesh->create_element( MBTET, node_handles, 4, tet_handle );
   imesh->tag_set_data( tag_gid, &tet_handle, 1, gid_values + 6 + rank );
+#ifdef USE_MPI
+  for ( int i = 0; i < nprocs; ++ i )
+    {
+    MPI_Barrier( MPI_COMM_WORLD );
+    if ( i == rank )
+      {
+      std::cout << "\n************** Rank: " << ( rank + 1 ) << " of: " << nprocs << "\n";
+      imesh->list_entities( 0, 1 );
+      std::cout << "**************\n\n";
+      }
+    MPI_Barrier( MPI_COMM_WORLD );
+    }
+#else // USE_MPI
   imesh->list_entities( 0, 1 );
+#endif // USE_MPI
 
   MBSimplexTemplateRefiner eref( imesh );
-  MBTestOutputFunctor* ofunc = new MBTestOutputFunctor( imesh, omesh, eval );
+  MBTestOutputFunctor* ofunc = new MBTestOutputFunctor( imesh, omesh, tmgr );
   eref.set_edge_size_evaluator( eval );
   eref.set_output_functor( ofunc );
-  eval->create_output_tags();
+  tmgr->create_output_tags();
   eref.refine_entity( tet_handle );
 
-  ofunc->mesh->list_entities( 0, 1 );
+#ifdef USE_MPI
+  for ( int i = 0; i < nprocs; ++ i )
+    {
+    MPI_Barrier( MPI_COMM_WORLD );
+    if ( i == rank )
+      {
+      std::cout << "\n************** Rank: " << ( rank + 1 ) << " of: " << nprocs << "\n";
+      omesh->list_entities( 0, 1 );
+      std::cout << "**************\n\n";
+      }
+    MPI_Barrier( MPI_COMM_WORLD );
+    }
+#else // USE_MPI
+  omesh->list_entities( 0, 1 );
+#endif // USE_MPI
 
   if ( ! ofunc->input_is_output )
     delete ofunc->mesh;
   delete imesh;
 
-#ifdef USE_MPI
   err = MPI_Barrier( MPI_COMM_WORLD );
   err = MPI_Finalize();
-#endif // USE_MPI
   return 0;
 }
 




More information about the moab-dev mailing list