[MOAB-dev] r1889 - in MOAB/trunk: . refiner
dcthomp at mcs.anl.gov
dcthomp at mcs.anl.gov
Tue Jun 10 19:00:51 CDT 2008
Author: dcthomp
Date: 2008-06-10 19:00:51 -0500 (Tue, 10 Jun 2008)
New Revision: 1889
Modified:
MOAB/trunk/refiner/MBEntityRefiner.cpp
MOAB/trunk/refiner/MBEntityRefiner.hpp
MOAB/trunk/refiner/MBMeshRefiner.cpp
MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp
MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp
MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp
MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp
MOAB/trunk/test_mesh_refiner.cpp
Log:
BUG: edge_code in refine_3_simplex should be an int, not a bool
ENH: Vertices are now created at the time evaluate_edge_size is called instead of
at the time a simplex referring to them is created.
ENH: Since we now have vertex handles as we recurse, the interface can be simplified.
Modified: MOAB/trunk/refiner/MBEntityRefiner.cpp
===================================================================
--- MOAB/trunk/refiner/MBEntityRefiner.cpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/refiner/MBEntityRefiner.cpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -157,7 +157,6 @@
unsigned long m = this->edge_size_evaluator->get_vertex_tag_size();
this->tag_heap.resize( m * n );
}
- this->hash_heap.resize( 2 * n * this->maximum_number_of_subdivisions + 1 );
}
/**\brief Subclasses should call this on entry to refine_entity().
@@ -169,7 +168,6 @@
{
this->current_coord = this->coord_heap.begin();
this->current_tag = this->tag_heap.begin();
- this->current_hash = this->hash_heap.begin();
}
/**\brief Return a pointer to temporary storage for edge midpoint vertex coordinates inside refine_entity().
@@ -211,60 +209,3 @@
return rval;
}
-/**\brief Return a pointer to temporary storage for vertex hash vectors inside refine_entity().
- *
- * The returned pointer references enough bytes to store all the hashes for a vertex.
- * @param[in] h0 The pre-existing vertex hash for the first endpoint
- * @param[in] h1 The pre-existing vertex hash for the second endpoint
- * @retval The hash, filled in with values from h0 and h1 and null-terminated.
- */
-MBEntityHandle* MBEntityRefiner::heap_hash_storage( MBEntityHandle* h0, MBEntityHandle* h1 )
-{
- MBEntityHandle* rval;
- if ( this->edge_size_evaluator && this->current_hash != this->hash_heap.end() )
- {
- rval = (MBEntityHandle*) &(*this->current_hash);
- MBEntityHandle* h2 = rval;
- while ( *h0 )
- {
- *h2 = *h0;
- ++h0; ++h2;
- ++this->current_hash;
- }
- while ( *h1 )
- {
- *h2 = *h1;
- ++h1; ++h2;
- ++this->current_hash;
- }
- *h2 = 0; // NULL terminator
- ++this->current_hash;
- }
- else
- {
- rval = 0;
- }
- return rval;
-}
-
-/**\brief Return a pointer to temporary storage for vertex hash vectors inside refine_entity().
- *
- * The returned pointer references enough bytes to store all the hashes for a vertex.
- * @param[in] sz The number of vertex handles to use as a hash, not including the NULL terminator.
- * @retval A pointer to the hash storage, uninitialized but NULL-terminated.
- */
-MBEntityHandle* MBEntityRefiner::heap_hash_storage( int sz )
-{
- MBEntityHandle* rval;
- if ( this->edge_size_evaluator && this->current_hash != this->hash_heap.end() )
- {
- rval = (MBEntityHandle*) &(*this->current_hash);
- rval[sz] = 0;
- this->current_hash += sz + 1;
- }
- else
- {
- rval = 0;
- }
- return rval;
-}
Modified: MOAB/trunk/refiner/MBEntityRefiner.hpp
===================================================================
--- MOAB/trunk/refiner/MBEntityRefiner.hpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/refiner/MBEntityRefiner.hpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -70,7 +70,24 @@
{
public:
virtual ~MBEntityRefinerOutputFunctor() { }
- virtual void operator () ( const double* vcoords, const void* vtags, MBEntityHandle* vhash ) = 0;
+ virtual MBEntityHandle operator () ( MBEntityHandle vhash, const double* vcoords, const void* vtags ) = 0;
+ MBEntityHandle operator () ( MBEntityHandle h0, MBEntityHandle h1, const double* vcoords, const void* vtags )
+ {
+ MBEntityHandle harr[2];
+ harr[0] = h0;
+ harr[1] = h1;
+ return (*this)( 2, harr, vcoords, vtags );
+ }
+ virtual MBEntityHandle operator () ( MBEntityHandle h0, MBEntityHandle h1, MBEntityHandle h2, const double* vcoords, const void* vtags )
+ {
+ MBEntityHandle harr[3];
+ harr[0] = h0;
+ harr[1] = h1;
+ harr[2] = h2;
+ return (*this)( 3, harr, vcoords, vtags );
+ }
+ virtual MBEntityHandle operator () ( int nhash, MBEntityHandle* hash, const double* vcoords, const void* vtags ) = 0;
+ virtual void operator () ( MBEntityHandle vhash ) = 0;
virtual void operator () ( MBEntityType etyp ) = 0;
};
@@ -107,15 +124,11 @@
std::vector<double>::iterator current_coord;
std::vector<char> tag_heap;
std::vector<char>::iterator current_tag;
- std::vector<MBEntityHandle> hash_heap;
- std::vector<MBEntityHandle>::iterator current_hash;
void update_heap_size();
void reset_heap_pointers();
double* heap_coord_storage();
void* heap_tag_storage();
- MBEntityHandle* heap_hash_storage( MBEntityHandle* h0, MBEntityHandle* h1 );
- MBEntityHandle* heap_hash_storage( int sz );
};
#endif // MB_ENTITYREFINER_H
Modified: MOAB/trunk/refiner/MBMeshRefiner.cpp
===================================================================
--- MOAB/trunk/refiner/MBMeshRefiner.cpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/refiner/MBMeshRefiner.cpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -98,18 +98,17 @@
this->edge_size_evaluator = es;
}
virtual ~MBMeshRefinerOutputFunctor() { }
- virtual void operator () ( const double* vcoords, const void* vtags, MBEntityHandle* hash )
+ /// Insert a new vertex into the mesh and set its tag values. This has no effect when output_is_input is true.
+ virtual MBEntityHandle operator () ( MBEntityHandle hash, const double* vcoords, const void* vtags )
{
- if ( ! hash[1] && this->output_is_input )
+ if ( this->output_is_input )
{
// Don't insert vertices that already exist in the output
- this->vertex_accum.push_back( hash[0] );
- return;
+ return hash;
}
MBEntityHandle vertex_handle;
this->mesh->create_vertex( vcoords + 3, vertex_handle );
- this->vertex_accum.push_back( vertex_handle );
MBTag tag_handle;
int tag_offset;
for ( int i = 0; i < num_tags; ++i )
@@ -117,7 +116,34 @@
this->edge_size_evaluator->get_vertex_tag( i, tag_handle, tag_offset );
this->mesh->tag_set_data( tag_handle, &vertex_handle, 1, (char*)vtags + tag_offset );
}
+ return vertex_handle;
}
+ /// Insert a new n-way hashed vertex into the mesh and set its tag values.
+ virtual MBEntityHandle operator () ( int nhash, MBEntityHandle* hash, const double* vcoords, const void* vtags )
+ {
+ // First, see if we've already created this vertex
+ MBEntityHandle hv;
+ if ( this->find_hashed_vertex( hv, nhash, hash ) )
+ {
+ return hv;
+ }
+
+ this->mesh->create_vertex( vcoords + 3, hv );
+ MBTag tag_handle;
+ int tag_offset;
+ for ( int i = 0; i < num_tags; ++i )
+ {
+ this->edge_size_evaluator->get_vertex_tag( i, tag_handle, tag_offset );
+ this->mesh->tag_set_data( tag_handle, &hv, 1, (char*)vtags + tag_offset );
+ }
+ return hv;
+ }
+ /// Accumulate a vertex for use in the connectivity record of an element.
+ virtual void operator () ( MBEntityHandle hash )
+ {
+ this->vertex_accum.push_back( hash );
+ }
+ /// Create an element from all the accumulated vertices since the last element was created.
virtual void operator () ( MBEntityType etyp )
{
if ( ! this->vertex_accum.size() )
@@ -127,6 +153,13 @@
this->mesh->create_element( etyp, &this->vertex_accum[0], this->vertex_accum.size(), elem_handle );
this->vertex_accum.clear();
}
+ bool find_hashed_vertex( MBEntityHandle& vout, int nhash, MBEntityHandle* hash )
+ {
+ return false;
+ }
+ void hash_vertex( MBEntityHandle vout, int nhash, MBEntityHandle* hash )
+ {
+ }
};
MBMeshRefiner::MBMeshRefiner( MBInterface* parent_mesh )
Modified: MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/refiner/MBSimplexTemplateRefiner.cpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -57,12 +57,9 @@
MBTag tag_handle;
int tag_offset;
void* tag_data;
- MBEntityHandle* tag_vhandle;
for ( int n = 0; n < num_nodes; ++ n )
{
- tag_vhandle = this->heap_hash_storage( 1 );
- tag_vhandle[0] = conn[n];
- this->corner_handles[n] = tag_vhandle;
+ this->corner_handles[n] = conn[n];
if ( this->mesh->get_coords( &conn[n], 1, &corner_coords[6 * n + 3] ) != MB_SUCCESS )
{
return false;
@@ -193,9 +190,14 @@
* in space and vertices as degrees-of-freedom in a mesh (i.e. a vertex that is
* treated as a lumped-parameter model).
*/
-void MBSimplexTemplateRefiner::refine_0_simplex( const double* v0, const void* t0, MBEntityHandle* h0 )
+void MBSimplexTemplateRefiner::refine_0_simplex( const double* v0, const void* t0, MBEntityHandle h0 )
{
- (*this->output_functor)( v0, t0, h0 );
+ // Ignore these arguments... the caller is responsible for calling the output functor to ensure the
+ // vertex exists on the output.
+ (void) v0;
+ (void) t0;
+
+ (*this->output_functor)( h0 );
(*this->output_functor)( MBVERTEX );
}
@@ -203,8 +205,8 @@
*/
bool MBSimplexTemplateRefiner::refine_1_simplex(
int max_depth,
- const double* v0, const void* t0, MBEntityHandle* h0,
- const double* v1, const void* t1, MBEntityHandle* h1 )
+ const double* v0, const void* t0, MBEntityHandle h0,
+ const double* v1, const void* t1, MBEntityHandle h1 )
{
bool edge_code = false;
@@ -212,8 +214,7 @@
void* midptt;
// NB: If support for multiple recursive subdivisions (without a merge in between) is required,
// this will have to change as it assumes that h0 and h1 have only a single entry.
- MBEntityHandle midpth[3];
- midpth[0] = h0[0]; midpth[1] = h1[0]; midpth[2] = 0;
+ MBEntityHandle midpth = 0;
if ( max_depth-- > 0 )
{
@@ -227,14 +228,18 @@
(*this->tag_assigner)( v0, t0, h0, midptc, midptt, v1, t1, h1 );
edge_code = this->edge_size_evaluator->evaluate_edge( v0, t0, midptc, midptt, v1, t1 );
+ if ( edge_code )
+ {
+ midpth = (*this->output_functor)( h0, h1, midptc, midptt );
+ }
}
switch ( edge_code )
{
// No edges to subdivide
case 0:
- (*this->output_functor)( v0, t0, h0 );
- (*this->output_functor)( v1, t1, h1 );
+ (*this->output_functor)( h0 );
+ (*this->output_functor)( h1 );
(*this->output_functor)( MBEDGE );
break ;
@@ -252,9 +257,9 @@
*/
bool MBSimplexTemplateRefiner::refine_2_simplex(
int max_depth, int move,
- const double* v0, const void* t0, MBEntityHandle* h0,
- const double* v1, const void* t1, MBEntityHandle* h1,
- const double* v2, const void* t2, MBEntityHandle* h2 )
+ const double* v0, const void* t0, MBEntityHandle h0,
+ const double* v1, const void* t1, MBEntityHandle h1,
+ const double* v2, const void* t2, MBEntityHandle h2 )
{
int edge_code = 0;
@@ -264,9 +269,9 @@
void* midpt0t;
void* midpt1t;
void* midpt2t;
- MBEntityHandle* midpt0h;
- MBEntityHandle* midpt1h;
- MBEntityHandle* midpt2h;
+ MBEntityHandle midpt0h;
+ MBEntityHandle midpt1h;
+ MBEntityHandle midpt2h;
if ( max_depth-- > 0 )
{
@@ -277,9 +282,9 @@
midpt0t = this->heap_tag_storage();
midpt1t = this->heap_tag_storage();
midpt2t = this->heap_tag_storage();
- midpt0h = this->heap_hash_storage( h0, h1 );
- midpt1h = this->heap_hash_storage( h1, h2 );
- midpt2h = this->heap_hash_storage( h2, h0 );
+ midpt0h = 0;
+ midpt1h = 0;
+ midpt2h = 0;
for ( i = 0; i < 6; ++i )
{
midpt0c[i] = ( v0[i] + v1[i] ) / 2.;
@@ -290,20 +295,29 @@
(*this->tag_assigner)( v1, t1, h1, midpt1c, midpt1t, v2, t2, h2 );
(*this->tag_assigner)( v2, t2, h2, midpt2c, midpt2t, v0, t0, h0 );
if ( ( move & 1 ) && this->edge_size_evaluator->evaluate_edge( v0, t0, midpt0c, midpt0t, v1, t1 ) )
+ {
edge_code += 1;
+ midpt0h = (*this->output_functor)( h0, h1, midpt0c, midpt0t );
+ }
if ( ( move & 2 ) && this->edge_size_evaluator->evaluate_edge( v1, t1, midpt1c, midpt1t, v2, t2 ) )
+ {
edge_code += 2;
+ midpt1h = (*this->output_functor)( h1, h2, midpt1c, midpt1t );
+ }
if ( ( move & 4 ) && this->edge_size_evaluator->evaluate_edge( v2, t2, midpt2c, midpt2t, v0, t0 ) )
+ {
edge_code += 4;
+ midpt2h = (*this->output_functor)( h2, h0, midpt2c, midpt2t );
+ }
}
switch ( edge_code )
{
// No edges to subdivide
case 0:
- (*this->output_functor)( v0, t0, h0 );
- (*this->output_functor)( v1, t1, h1 );
- (*this->output_functor)( v2, t2, h2 );
+ (*this->output_functor)( h0 );
+ (*this->output_functor)( h1 );
+ (*this->output_functor)( h2 );
(*this->output_functor)( MBTRI );
break ;
@@ -378,12 +392,12 @@
*/
bool MBSimplexTemplateRefiner::refine_3_simplex(
int max_depth,
- double* v0, void* t0, MBEntityHandle* h0,
- double* v1, void* t1, MBEntityHandle* h1,
- double* v2, void* t2, MBEntityHandle* h2,
- double* v3, void* t3, MBEntityHandle* h3 )
+ double* v0, void* t0, MBEntityHandle h0,
+ double* v1, void* t1, MBEntityHandle h1,
+ double* v2, void* t2, MBEntityHandle h2,
+ double* v3, void* t3, MBEntityHandle h3 )
{
- bool edge_code = false;
+ int edge_code = 0;
double* midpt0c;
double* midpt1c;
@@ -399,12 +413,12 @@
void* midpt4t;
void* midpt5t;
- MBEntityHandle* midpt0h;
- MBEntityHandle* midpt1h;
- MBEntityHandle* midpt2h;
- MBEntityHandle* midpt3h;
- MBEntityHandle* midpt4h;
- MBEntityHandle* midpt5h;
+ MBEntityHandle midpt0h;
+ MBEntityHandle midpt1h;
+ MBEntityHandle midpt2h;
+ MBEntityHandle midpt3h;
+ MBEntityHandle midpt4h;
+ MBEntityHandle midpt5h;
if ( max_depth-- > 0 )
{
@@ -422,13 +436,6 @@
midpt4t = this->heap_tag_storage();
midpt5t = this->heap_tag_storage();
- midpt0h = this->heap_hash_storage( h0, h1 );
- midpt1h = this->heap_hash_storage( h1, h2 );
- midpt2h = this->heap_hash_storage( h2, h0 );
- midpt3h = this->heap_hash_storage( h0, h3 );
- midpt4h = this->heap_hash_storage( h1, h3 );
- midpt5h = this->heap_hash_storage( h2, h3 );
-
for ( int i = 0; i < 6; ++ i )
{
midpt0c[i] = ( v0[i] + v1[i] ) * .5;
@@ -447,27 +454,40 @@
(*this->tag_assigner)( v2, t2, h2, midpt5c, midpt5t, v3, t3, h3 );
if ( this->edge_size_evaluator->evaluate_edge( v0, t0, midpt0c, midpt0t, v1, t1 ) )
+ {
edge_code |= 1;
+ midpt0h = (*this->output_functor)( h0, h1, midpt0c, midpt0t );
+ }
if ( this->edge_size_evaluator->evaluate_edge( v1, t1, midpt1c, midpt1t, v2, t2 ) )
+ {
edge_code |= 2;
+ midpt1h = (*this->output_functor)( h1, h2, midpt1c, midpt1t );
+ }
if ( this->edge_size_evaluator->evaluate_edge( v2, t2, midpt2c, midpt2t, v0, t0 ) )
+ {
edge_code |= 4;
+ midpt2h = (*this->output_functor)( h2, h0, midpt2c, midpt2t );
+ }
if ( this->edge_size_evaluator->evaluate_edge( v0, t0, midpt3c, midpt3t, v3, t3 ) )
+ {
edge_code |= 8;
+ midpt3h = (*this->output_functor)( h0, h3, midpt3c, midpt3t );
+ }
if ( this->edge_size_evaluator->evaluate_edge( v1, t1, midpt4c, midpt4t, v3, t3 ) )
+ {
edge_code |= 16;
+ midpt4h = (*this->output_functor)( h1, h3, midpt4c, midpt4t );
+ }
if ( this->edge_size_evaluator->evaluate_edge( v2, t2, midpt5c, midpt5t, v3, t3 ) )
+ {
edge_code |= 32;
+ midpt5h = (*this->output_functor)( h2, h3, midpt5c, midpt5t );
+ }
}
double edge_length2[6];
- edge_length2[0]
- = edge_length2[1]
- = edge_length2[2]
- = edge_length2[3]
- = edge_length2[4]
- = edge_length2[5]
- = 0;
+ for ( int ei = 0; ei < 6; ++ ei )
+ edge_length2[ei] = 0.;
for ( int c = 0; c < 3; ++ c )
{
@@ -489,10 +509,10 @@
if ( ! edge_code )
{
// No edges to subdivide
- (*this->output_functor)( v0, t0, h0 );
- (*this->output_functor)( v1, t1, h1 );
- (*this->output_functor)( v2, t2, h2 );
- (*this->output_functor)( v3, t3, h3 );
+ (*this->output_functor)( h0 );
+ (*this->output_functor)( h1 );
+ (*this->output_functor)( h2 );
+ (*this->output_functor)( h3 );
(*this->output_functor)( MBTET );
return false;
@@ -524,28 +544,24 @@
facept0t, facept1t, facept2t, facept3t
};
- MBEntityHandle* facept0h = this->heap_hash_storage( 3 );
- MBEntityHandle* facept1h = this->heap_hash_storage( 3 );
- MBEntityHandle* facept2h = this->heap_hash_storage( 3 );
- MBEntityHandle* facept3h = this->heap_hash_storage( 3 );
- MBEntityHandle* vertex_hash[14] = {
+ MBEntityHandle vertex_hash[14] = {
h0, h1, h2, h3,
midpt0h, midpt1h, midpt2h,
midpt3h, midpt4h, midpt5h,
- facept0h, facept1h, facept2h, facept3h
+ 0, 0, 0, 0
};
// Generate tetrahedra that are compatible except when edge
// lengths are equal on indeterminately subdivided faces.
double* permuted_coords[14];
void* permuted_tags[14];
- MBEntityHandle* permuted_hash[14];
+ MBEntityHandle permuted_hash[14];
double permlen[6]; // permuted edge lengths
int C = MBSimplexTemplateRefiner::template_index[edge_code][0];
int P = MBSimplexTemplateRefiner::template_index[edge_code][1];
// 1. Permute the tetrahedron into our canonical configuration
- for ( int i = 0; i < 4; ++ i )
+ for ( int i = 0; i < 14; ++ i )
{
permuted_coords[i] = vertex_coords[MBSimplexTemplateRefiner::permutations_from_index[P][i]];
permuted_tags[i] = vertex_tags[MBSimplexTemplateRefiner::permutations_from_index[P][i]];
@@ -554,25 +570,9 @@
for ( int i = 4 ; i < 10; ++ i )
{
- // permute edges too
- permuted_coords[i] = vertex_coords[MBSimplexTemplateRefiner::permutations_from_index[P][i]];
- permuted_tags[i] = vertex_tags[MBSimplexTemplateRefiner::permutations_from_index[P][i]];
- permuted_hash[i] = vertex_hash[MBSimplexTemplateRefiner::permutations_from_index[P][i]];
+ // permute edge lengths too
permlen[i-4] = edge_length2[MBSimplexTemplateRefiner::permutations_from_index[P][i] - 4];
}
- // Add our local (heap) storage for face point coordinates to the list.
- permuted_coords[10] = facept0c;
- permuted_coords[11] = facept1c;
- permuted_coords[12] = facept2c;
- permuted_coords[13] = facept3c;
- permuted_tags[10] = facept0t;
- permuted_tags[11] = facept1t;
- permuted_tags[12] = facept2t;
- permuted_tags[13] = facept3t;
- permuted_hash[10] = facept0h;
- permuted_hash[11] = facept1h;
- permuted_hash[12] = facept2h;
- permuted_hash[13] = facept3h;
int comparison_bits;
std::stack<int*> output_tets;
@@ -603,7 +603,9 @@
{
permuted_coords[10][i] = ( permuted_coords[0][i] + permuted_coords[2][i] ) * .375 + permuted_coords[1][i] * .25;
}
- (*this->tag_assigner)( t0, t2, t1, permuted_tags[10] );
+ (*this->tag_assigner)( permuted_tags[0], permuted_tags[2], permuted_tags[1], permuted_tags[10] );
+ permuted_hash[10] = (*this->output_functor)(
+ permuted_hash[0], permuted_hash[2], permuted_hash[1], permuted_coords[10], permuted_tags[10] );
}
MB_TESSELLATOR_INCR_CASE_COUNT(1);
output_tets.push( MBSimplexTemplateRefiner::templates + 9 );
@@ -652,7 +654,9 @@
{
permuted_coords[11][i] = ( permuted_coords[1][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25;
}
- (*this->tag_assigner)( t1, t3, t0, permuted_tags[11] );
+ (*this->tag_assigner)( permuted_tags[1], permuted_tags[3], permuted_tags[0], permuted_tags[11] );
+ permuted_hash[11] = (*this->output_functor)(
+ permuted_hash[1], permuted_hash[3], permuted_hash[0], permuted_coords[11], permuted_tags[11] );
}
if ( ( comparison_bits & 12 ) == 12 )
{
@@ -661,7 +665,9 @@
{
permuted_coords[13][i] = ( permuted_coords[2][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25;
}
- (*this->tag_assigner)( t2, t3, t0, permuted_tags[13] );
+ (*this->tag_assigner)( permuted_tags[2], permuted_tags[3], permuted_tags[0], permuted_tags[13] );
+ permuted_hash[13] = (*this->output_functor)(
+ permuted_hash[2], permuted_hash[3], permuted_hash[0], permuted_coords[13], permuted_tags[13] );
}
if ( ( comparison_bits & 48 ) == 48 )
{
@@ -670,7 +676,9 @@
{
permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[2][i] ) * .375 + permuted_coords[0][i] * .25;
}
- (*this->tag_assigner)( t1, t2, t0, permuted_tags[10] );
+ (*this->tag_assigner)( permuted_tags[1], permuted_tags[2], permuted_tags[0], permuted_tags[10] );
+ permuted_hash[10] = (*this->output_functor)(
+ permuted_hash[1], permuted_hash[2], permuted_hash[0], permuted_coords[10] , permuted_tags[10] );
}
MB_TESSELLATOR_INCR_CASE_COUNT(3);
output_tets.push( MBSimplexTemplateRefiner::templates + 57 );
@@ -778,7 +786,9 @@
{
permuted_coords[10][i] = ( permuted_coords[0][i] + permuted_coords[2][i] ) * .375 + permuted_coords[1][i] * .25;
}
- (*this->tag_assigner)( t0, t2, t1, permuted_tags[10] );
+ (*this->tag_assigner)( permuted_tags[0], permuted_tags[2], permuted_tags[1], permuted_tags[10] );
+ permuted_hash[10] = (*this->output_functor)(
+ permuted_hash[0], permuted_hash[2], permuted_hash[1], permuted_coords[10], permuted_tags[10] );
}
if ( ( comparison_bits & 12 ) == 12 )
{
@@ -787,7 +797,9 @@
{
permuted_coords[11][i] = ( permuted_coords[1][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25;
}
- (*this->tag_assigner)( t1, t3, t0, permuted_tags[11] );
+ (*this->tag_assigner)( permuted_tags[1], permuted_tags[3], permuted_tags[0], permuted_tags[11] );
+ permuted_hash[11] = (*this->output_functor)(
+ permuted_hash[1], permuted_hash[3], permuted_hash[0], permuted_coords[11], permuted_tags[11] );
}
MB_TESSELLATOR_INCR_CASE_COUNT(5);
switch ( comparison_bits )
@@ -860,7 +872,9 @@
{
permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[2][i] ) * .375 + permuted_coords[0][i] * .25;
}
- (*this->tag_assigner)( t1, t2, t0, permuted_tags[10] );
+ (*this->tag_assigner)( permuted_tags[1], permuted_tags[2], permuted_tags[0], permuted_tags[10] );
+ permuted_hash[10] = (*this->output_functor)(
+ permuted_hash[1], permuted_hash[2], permuted_hash[0], permuted_coords[10], permuted_tags[10] );
}
if ( ( comparison_bits & 12 ) == 12 )
{
@@ -869,7 +883,9 @@
{
permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[3][i] ) * .375 + permuted_coords[1][i] * .25;
}
- (*this->tag_assigner)( t0, t3, t1, permuted_tags[11] );
+ (*this->tag_assigner)( permuted_tags[0], permuted_tags[3], permuted_tags[1], permuted_tags[11] );
+ permuted_hash[11] = (*this->output_functor)(
+ permuted_hash[0], permuted_hash[3], permuted_hash[1], permuted_coords[11], permuted_tags[11] );
}
MB_TESSELLATOR_INCR_CASE_COUNT(6);
switch ( comparison_bits )
@@ -942,7 +958,9 @@
{
permuted_coords[12][i] = ( permuted_coords[1][i] + permuted_coords[2][i] ) * .375 + permuted_coords[3][i] * .25;
}
- (*this->tag_assigner)( t1, t2, t3, permuted_tags[12] );
+ (*this->tag_assigner)( permuted_tags[1], permuted_tags[2], permuted_tags[3], permuted_tags[12] );
+ permuted_hash[12] = (*this->output_functor)(
+ permuted_hash[1], permuted_hash[2], permuted_hash[3], permuted_coords[12], permuted_tags[12] );
}
if ( ( comparison_bits & 12 ) == 12 )
{
@@ -951,7 +969,9 @@
{
permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[1][i] ) * .375 + permuted_coords[3][i] * .25;
}
- (*this->tag_assigner)( t0, t1, t3, permuted_tags[11] );
+ (*this->tag_assigner)( permuted_tags[0], permuted_tags[1], permuted_tags[3], permuted_tags[11] );
+ permuted_hash[11] = (*this->output_functor)(
+ permuted_hash[0], permuted_hash[1], permuted_hash[3], permuted_coords[11], permuted_tags[11] );
}
MB_TESSELLATOR_INCR_CASE_COUNT(7);
output_tets.push( MBSimplexTemplateRefiner::templates + 545 );
@@ -1030,7 +1050,9 @@
{
permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[0][i] ) * .375 + permuted_coords[2][i] * .25;
}
- (*this->tag_assigner)( t1, t0, t2, permuted_tags[10] );
+ (*this->tag_assigner)( permuted_tags[1], permuted_tags[0], permuted_tags[2], permuted_tags[10] );
+ permuted_hash[10] = (*this->output_functor)(
+ permuted_hash[1], permuted_hash[0], permuted_hash[2], permuted_coords[10], permuted_tags[10] );
}
if ( ( comparison_bits & 12 ) == 12 )
{
@@ -1039,7 +1061,9 @@
{
permuted_coords[13][i] = ( permuted_coords[2][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25;
}
- (*this->tag_assigner)( t2, t3, t0, permuted_tags[13] );
+ (*this->tag_assigner)( permuted_tags[2], permuted_tags[3], permuted_tags[0], permuted_tags[13] );
+ permuted_hash[13] = (*this->output_functor)(
+ permuted_hash[2], permuted_hash[3], permuted_hash[0], permuted_coords[13], permuted_tags[13] );
}
if ( ( comparison_bits & 48 ) == 48 )
{
@@ -1048,7 +1072,9 @@
{
permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[1][i] ) * .375 + permuted_coords[3][i] * .25;
}
- (*this->tag_assigner)( t0, t1, t3, permuted_tags[11] );
+ (*this->tag_assigner)( permuted_tags[0], permuted_tags[1], permuted_tags[3], permuted_tags[11] );
+ permuted_hash[11] = (*this->output_functor)(
+ permuted_hash[0], permuted_hash[1], permuted_hash[3], permuted_coords[11], permuted_tags[11] );
}
if ( ( comparison_bits & 192 ) == 192 )
{
@@ -1057,7 +1083,9 @@
{
permuted_coords[12][i] = ( permuted_coords[2][i] + permuted_coords[3][i] ) * .375 + permuted_coords[1][i] * .25;
}
- (*this->tag_assigner)( t2, t3, t1, permuted_tags[12] );
+ (*this->tag_assigner)( permuted_tags[2], permuted_tags[3], permuted_tags[1], permuted_tags[12] );
+ permuted_hash[12] = (*this->output_functor)(
+ permuted_hash[2], permuted_hash[3], permuted_hash[1], permuted_coords[12], permuted_tags[12] );
}
MB_TESSELLATOR_INCR_CASE_COUNT(8);
switch ( comparison_bits )
@@ -1394,7 +1422,9 @@
{
permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[0][i] ) * .375 + permuted_coords[2][i] * .25;
}
- (*this->tag_assigner)( t1, t0, t2, permuted_tags[10] );
+ (*this->tag_assigner)( permuted_tags[1], permuted_tags[0], permuted_tags[2], permuted_tags[10] );
+ permuted_hash[10] = (*this->output_functor)(
+ permuted_hash[1], permuted_hash[0], permuted_hash[2], permuted_coords[10], permuted_tags[10] );
}
if ( ( comparison_bits & 12 ) == 12 )
{
@@ -1403,7 +1433,9 @@
{
permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[1][i] ) * .375 + permuted_coords[3][i] * .25;
}
- (*this->tag_assigner)( t0, t1, t3, permuted_tags[11] );
+ (*this->tag_assigner)( permuted_tags[0], permuted_tags[1], permuted_tags[3], permuted_tags[11] );
+ permuted_hash[11] = (*this->output_functor)(
+ permuted_hash[0], permuted_hash[1], permuted_hash[3], permuted_coords[11], permuted_tags[11] );
}
MB_TESSELLATOR_INCR_CASE_COUNT(9);
output_tets.push( MBSimplexTemplateRefiner::templates + 1107 );
Modified: MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/refiner/MBSimplexTemplateRefiner.hpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -52,25 +52,25 @@
MBSimplexTemplateTagAssigner* tag_assigner;
std::vector<double> corner_coords;
std::vector<void*> corner_tags;
- std::vector<MBEntityHandle*> corner_handles;
+ std::vector<MBEntityHandle> corner_handles;
static int template_index[64][2];
static int permutations_from_index[24][14];
static int templates[];
- void refine_0_simplex( const double* v0, const void* t0, MBEntityHandle* h0 );
+ void refine_0_simplex( const double* v0, const void* t0, MBEntityHandle h0 );
bool refine_1_simplex( int max_depth,
- const double* v0, const void* t0, MBEntityHandle* h0,
- const double* v1, const void* t1, MBEntityHandle* h1 );
+ const double* v0, const void* t0, MBEntityHandle h0,
+ const double* v1, const void* t1, MBEntityHandle h1 );
bool refine_2_simplex( int max_depth, int move,
- const double* v0, const void* t0, MBEntityHandle* h0,
- const double* v1, const void* t1, MBEntityHandle* h1,
- const double* v2, const void* t2, MBEntityHandle* h2 );
+ const double* v0, const void* t0, MBEntityHandle h0,
+ const double* v1, const void* t1, MBEntityHandle h1,
+ const double* v2, const void* t2, MBEntityHandle h2 );
bool refine_3_simplex( int max_depth,
- double* v0, void* t0, MBEntityHandle* h0,
- double* v1, void* t1, MBEntityHandle* h1,
- double* v2, void* t2, MBEntityHandle* h2,
- double* v3, void* t3, MBEntityHandle* h3 );
+ double* v0, void* t0, MBEntityHandle h0,
+ double* v1, void* t1, MBEntityHandle h1,
+ double* v2, void* t2, MBEntityHandle h2,
+ double* v3, void* t3, MBEntityHandle h3 );
int best_tets( int* alternates, double*[14], int, int ) { return alternates[0]; }
void assign_parametric_coordinates( int num_nodes, const double* src, double* tgt );
Modified: MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.cpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -37,9 +37,9 @@
* @param[in] t1 Pointer to endpoint 1 tag values.
*/
void MBSimplexTemplateTagAssigner::operator () (
- const double* c0, const void* t0, MBEntityHandle* h0,
+ const double* c0, const void* t0, MBEntityHandle h0,
const double* cm, void* tm,
- const double* c1, const void* t1, MBEntityHandle* h1 )
+ const double* c1, const void* t1, MBEntityHandle h1 )
{
double c0m_squared = 0.;
double c01_squared = 0.;
@@ -78,7 +78,7 @@
}
break;
default:
- memcpy( (char*)tm + tag_offset, (char*)( *h0 < *h1 ? t0 : t1 ) + tag_offset, tag_size );
+ memcpy( (char*)tm + tag_offset, (char*)( h0 < h1 ? t0 : t1 ) + tag_offset, tag_size );
break;
}
}
Modified: MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp
===================================================================
--- MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/refiner/MBSimplexTemplateTagAssigner.hpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -38,9 +38,9 @@
MBSimplexTemplateTagAssigner( MBSimplexTemplateRefiner* );
virtual ~MBSimplexTemplateTagAssigner();
- virtual void operator () ( const double* c0, const void* t0, MBEntityHandle* h0,
+ virtual void operator () ( const double* c0, const void* t0, MBEntityHandle h0,
const double* cm, void* tm,
- const double* c1, const void* t1, MBEntityHandle* h1 );
+ const double* c1, const void* t1, MBEntityHandle h1 );
virtual void operator () ( const void* t0,
const void* t1,
const void* t2,
Modified: MOAB/trunk/test_mesh_refiner.cpp
===================================================================
--- MOAB/trunk/test_mesh_refiner.cpp 2008-06-10 20:20:16 UTC (rev 1888)
+++ MOAB/trunk/test_mesh_refiner.cpp 2008-06-11 00:00:51 UTC (rev 1889)
@@ -25,8 +25,13 @@
edge_hash_t edge_hash;
node_list_t elem_vert;
- virtual void operator () ( const double* vcoords, const void* vtags, MBEntityHandle* vhash )
+ void print_vert_crud( MBEntityHandle vout, int nvhash, MBEntityHandle* vhash, const double* vcoords, const void* vtags )
{
+ std::cout << "+ {";
+ for ( int i = 0; i < nvhash; ++ i )
+ std::cout << " " << vhash[i];
+ std::cout << " } -> " << vout << " ";
+
std::cout << "[ " << vcoords[0];
for ( int i = 1; i < 6; ++i )
std::cout << ", " << vcoords[i];
@@ -38,40 +43,33 @@
<< ", " << x[1];
for ( int i = 0; i < 4; ++i )
std::cout << ", " << m[i];
- std::cout << " > { ";
- MBEntityHandle* vin = vhash;
- while ( *vin )
+ std::cout << " >\n";
+ }
+
+ virtual MBEntityHandle operator () ( MBEntityHandle vhash, const double* vcoords, const void* vtags )
+ {
+ if ( this->input_is_output )
+ { // Don't copy the original vertex!
+ this->print_vert_crud( vhash, 1, &vhash, vcoords, vtags );
+ return vhash;
+ }
+ MBEntityHandle vertex_handle;
+ if ( this->mesh->create_vertex( vcoords + 3, vertex_handle ) != MB_SUCCESS )
{
- std::cout << *vin << " ";
- ++ vin;
+ std::cerr << "Could not insert mid-edge vertex!\n";
}
- std::cout << "}\n";
+ this->print_vert_crud( vertex_handle, 1, &vhash, vcoords, vtags );
+ return vertex_handle;
+ }
+ virtual MBEntityHandle operator () ( int nvhash, MBEntityHandle* vhash, const double* vcoords, const void* vtags )
+ {
MBEntityHandle vertex_handle;
- if ( ! vhash[1] )
+ if ( nvhash == 1 )
{
- if ( this->input_is_output )
- { // Don't copy the original vertex!
- vertex_handle = vhash[0];
- }
- else
- {
- node_hash_t::iterator it = this->node_hash.find( vhash[0] );
- if ( it == this->node_hash.end() )
- {
- if ( this->mesh->create_vertex( vcoords + 3, vertex_handle ) != MB_SUCCESS )
- {
- std::cerr << "Could not insert corner vertex!\n";
- }
- this->node_hash[vhash[0]] = vertex_handle;
- }
- else
- {
- vertex_handle = it->second;
- }
- }
+ vertex_handle = (*this)( *vhash, vcoords, vtags );
}
- else if ( ! vhash[2] )
+ else if ( nvhash == 2 )
{
node_pair_t pr;
if ( vhash[0] < vhash[1] )
@@ -97,22 +95,32 @@
{
vertex_handle = it->second;
}
+ this->print_vert_crud( vertex_handle, 2, vhash, vcoords, vtags );
}
else
{
+ vertex_handle = -1;
std::cerr << "Not handling mid-face vertices yet.\n";
// FIXME: Handle face midpoint.
}
- std::cout << " -> " << vertex_handle << "\n";
- this->elem_vert.push_back( vertex_handle );
+ return vertex_handle;
}
+ virtual void operator () ( MBEntityHandle h )
+ {
+ std::cout << h << " ";
+ this->elem_vert.push_back( h );
+ }
+
virtual void operator () ( MBEntityType etyp )
{
- std::cout << "---------- " << etyp << "\n\n";
MBEntityHandle elem_handle;
- this->mesh->create_element( etyp, &this->elem_vert[0], this->elem_vert.size(), elem_handle );
+ if ( this->mesh->create_element( etyp, &this->elem_vert[0], this->elem_vert.size(), elem_handle ) == MB_FAILURE )
+ {
+ std::cerr << " *** ";
+ }
this->elem_vert.clear();
+ std::cout << "---------> " << elem_handle << " ( " << etyp << " )\n\n";
}
};
More information about the moab-dev
mailing list