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

pebay at mcs.anl.gov pebay at mcs.anl.gov
Thu Dec 27 13:42:37 CST 2007


Author: pebay
Date: 2007-12-27 13:42:29 -0600 (Thu, 27 Dec 2007)
New Revision: 1492

Modified:
   MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp
   MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp
Log:
ENH: refiner checkpoint


Modified: MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp	2007-12-27 17:13:44 UTC (rev 1491)
+++ MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp	2007-12-27 19:42:29 UTC (rev 1492)
@@ -48,7 +48,7 @@
       rval = this->refine_1_simplex( 0,  &entity_coords[0], 0,  &entity_coords[6], 0 ); // FIXME
       break;
     case MBTRI:
-      rval = this->refine_2_simplex( 0 ,   0, 0,   0, 0,   0, 0 ); // FIXME
+      rval = this->refine_2_simplex( 0, 0,   0, 0,   0, 0,   0, 0 ); // FIXME
       break;
     case MBQUAD:
       std::cerr << "Quadrilaterals not handled yet\n";
@@ -161,9 +161,9 @@
 /**\brief Refine a triangle.
   */
 bool MBSimplexTemplateRefiner::refine_2_simplex(
-  int max_depth, const double* v0, const void* t0, const double* v1, const void* t1, const double* v2, const void* t2 )
+  int max_depth, int move, const double* v0, const void* t0, const double* v1, const void* t1, const double* v2, const void* t2 )
 {
-  int edgeCode = 0;
+  int edge_code = 0;
 
   double* midpt0c;
   double* midpt1c;
@@ -175,10 +175,95 @@
   if ( max_depth-- > 0 )
     {
     int i;
-    for ( i = 0; i < 3; ++i )
+    for ( i = 0; i < 6; ++i )
       {
+      midpt0c[i] = ( v0[i] + v1[i] ) / 2.;
+      midpt1c[i] = ( v1[i] + v2[i] ) / 2.;
+      midpt2c[i] = ( v2[i] + v0[i] ) / 2.;
+      }
+    this->edge_size_evaluator->evaluate_tags_at_midpoint( v0, t0, midpt0c, midpt0t, v1, t1 );
+    this->edge_size_evaluator->evaluate_tags_at_midpoint( v1, t1, midpt1c, midpt1t, v2, t2 );
+    this->edge_size_evaluator->evaluate_tags_at_midpoint( v2, t2, midpt2c, midpt2t, v0, t0 );
+    if ( ( move & 1 ) && this->edge_size_evaluator->evaluate_edge( v0, t0, midpt0c, midpt0t, v1, t1 ) )
+      edge_code += 1;
+    if ( ( move & 2 ) && this->edge_size_evaluator->evaluate_edge( v1, t1, midpt1c, midpt1t, v2, t2 ) )
+      edge_code += 2;
+    if ( ( move & 4 ) && this->edge_size_evaluator->evaluate_edge( v2, t2, midpt2c, midpt2t, v0, t0 ) )
+      edge_code += 4;
+    }
 
+  switch ( edge_code )
+    {
+    // No edges to subdivide
+  case 0:
+    (*this->output_functor)( v0, t0 );
+    (*this->output_functor)( v1, t1 );
+    (*this->output_functor)( v2, t2 );
+    (*this->output_functor)( MBTRI );
+    break ;
+
+    // One edge to subdivide
+  case 1:
+    this->refine_2_simplex( max_depth, move | 2, v0, t0, midpt0c, midpt0t, v2, t2 );
+    this->refine_2_simplex( max_depth, move | 4, midpt0c, midpt0t, v1, t1, v2, t2 );
+    break;
+  case 2:
+    this->refine_2_simplex( max_depth, move | 4, v0, t0, v1, t1, midpt1c, midpt1t );
+    this->refine_2_simplex( max_depth, move | 1, v0, t0, midpt1c, midpt1t, v2, t2 );
+    break;
+  case 4:
+    this->refine_2_simplex( max_depth, move | 2, v0, t0, v1, t1, midpt2c, midpt2t );
+    this->refine_2_simplex( max_depth, move | 1, midpt2c, midpt2t, v1, t1, v2, t2 );
+    break;
+
+    // Two edges to subdivide
+  case 3:
+    this->refine_2_simplex( max_depth, move | 4, midpt0c, midpt0t, v1, t1, midpt1c, midpt1t );
+    if ( this->compare_Hopf_cross_string_dist( v2, midpt0c, v0, midpt1c ) )
+      {
+      this->refine_2_simplex( max_depth, move | 5, midpt0c, midpt0t, midpt1c, midpt1t,   v2,      t2    );
+      this->refine_2_simplex( max_depth, move | 2,   v0,      t0,    midpt0c, midpt0t,   v2,      t2    );
       }
+    else                                         
+      {
+      this->refine_2_simplex( max_depth, move | 6,   v0,      t0,    midpt0c, midpt0t, midpt1c, midpt1t );
+      this->refine_2_simplex( max_depth, move | 1,   v0,      t0,    midpt1c, midpt1t,   v2,      t2    );
+      }
+    break;
+  case 5:
+    this->refine_2_simplex( max_depth, move | 2, v0, t0, midpt0c, midpt0t, midpt2c, midpt2t );
+    if ( this->compare_Hopf_cross_string_dist( v2, midpt0c, v1, midpt2c ) )
+      {
+      this->refine_2_simplex( max_depth, move | 4, midpt0c, midpt0t,   v1,      t1,       v2,      t2   );
+      this->refine_2_simplex( max_depth, move | 3, midpt2c, midpt2t, midpt0c, midpt0t,    v2,      t2   );
+      }
+    else
+      {
+      this->refine_2_simplex( max_depth, move | 6, midpt0c, midpt0t,   v1,      t1,    midpt2c, midpt2t );
+      this->refine_2_simplex( max_depth, move | 1, midpt2c, midpt2t,   v1,      t1,       v2,      t2   );
+      }
+    break;
+  case 6:
+    this->refine_2_simplex( max_depth, move | 1, midpt2c, midpt2t, midpt1c, midpt1t, v2, t2 );
+    if ( this->compare_Hopf_cross_string_dist( v0, midpt1c, v1, midpt2c ) )
+      {
+      this->refine_2_simplex( max_depth, move | 3,   v0,      t0,    midpt1c, midpt1t, midpt2c, midpt2t );
+      this->refine_2_simplex( max_depth, move | 4,   v0,      t0,      v1,      t1,    midpt1c, midpt1t );
+      }
+    else
+      {
+      this->refine_2_simplex( max_depth, move | 2,   v0,      t0,      v1,      t1,    midpt2c, midpt2t );
+      this->refine_2_simplex( max_depth, move | 5, midpt2c, midpt2t,   v1,      t1,    midpt1c, midpt1t );
+      }
+    break;
+
+    // Three edges to subdivide
+  case 7:
+    this->refine_2_simplex( max_depth,        7, midpt0c, midpt0t, midpt1c, midpt1t, midpt2c, midpt2t );
+    this->refine_2_simplex( max_depth, move | 2,   v0   ,   t0   , midpt0c, midpt0t, midpt2c, midpt2t );
+    this->refine_2_simplex( max_depth, move | 4, midpt0c, midpt0t,   v1   ,   t1   , midpt1c, midpt1t );
+    this->refine_2_simplex( max_depth, move | 1, midpt2c, midpt2t, midpt1c, midpt1t,   v2   ,   t2    );
+    break;
     }
 
   return true;
@@ -191,4 +276,24 @@
   return true;
 }
 
+/**\brief Returns true if || a0a1 || < || b0b1 ||
+  *
+  * We use this to test which triangulation has the best
+  * aspect ratio when there are 2 to choose from.
+  */
+bool MBSimplexTemplateRefiner::compare_Hopf_cross_string_dist(
+  const double* a0, const double* a1, const double* b0, const double* b1 )
+{   
+  double sq_mag_a = 0.;
+  double sq_mag_b = 0.;
+  for (int i=0; i<3; i++)
+    {
+    double tmp;
+    tmp = a0[i] - a1[i];
+    sq_mag_a += tmp*tmp;
+    tmp = b0[i] - b1[i];
+    sq_mag_b += tmp*tmp;
+    } 
+  return sq_mag_a < sq_mag_b;
+}
 

Modified: MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp	2007-12-27 17:13:44 UTC (rev 1491)
+++ MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp	2007-12-27 19:42:29 UTC (rev 1492)
@@ -47,9 +47,10 @@
   void refine_0_simplex( const double* v0, const void* t0 );
   bool refine_1_simplex( int max_depth,
     const double* v0, const void* t0, const double* v1, const void* t1 );
-  bool refine_2_simplex( int max_depth,
+  bool refine_2_simplex( int max_depth, int move,
     const double* v0, const void* t0, const double* v1, const void* t1, const double* v2, const void* t2 );
   bool refine_3_simplex();
+  static bool compare_Hopf_cross_string_dist( const double* v00, const double* v01, const double* v10, const double* v11 );
 };
 #endif // MB_SIMPLEXTEMPLATEREFINER_H
 




More information about the moab-dev mailing list