77 int main(
int argc,
char** argv )
81 if( NULL == mbImpl )
return 1;
83 int nquads = 1000, nholes = 1;
87 opts.
addOpt<
int >( string(
"nquads,n" ), string(
"Number of quads in the mesh (default = 1000" ), &nquads );
88 opts.
addOpt<
int >( string(
"holes,H" ), string(
"Number of holes in the element handle space (default = 1" ),
91 if( nholes >= nquads )
93 cerr <<
"Number of holes needs to be < number of elements." << endl;
107 Tag tag1, tag2, tag3;
109 "Trouble creating tag1" );
110 double def_val[3] = { 0.0, 0.0, 0.0 };
112 "Trouble creating tag2" );
116 "Trouble creating tag3" );
120 double *x_ptr, *y_ptr, *z_ptr, *tag1_ptr, *tag2_ptr;
134 "Error in coords_iterate" );
135 assert( count == (
int)verts.
size() );
141 while( e_it != elems.
end() )
146 "Error in connect_iterate" );
148 "Error in tag1_iterate" );
151 for(
int i = 0; i < count; i++ )
153 tag1_ptr[0] = tag1_ptr[1] = tag1_ptr[2] = 0.0;
154 for(
int j = 0; j < vpere; j++ )
156 int v_index = conn_ptr[j] - first_vert;
157 tag1_ptr[0] += x_ptr[v_index];
158 tag1_ptr[1] += y_ptr[v_index];
159 tag1_ptr[2] += z_ptr[v_index];
161 tag1_ptr[0] /= vpere;
162 tag1_ptr[1] /= vpere;
163 tag1_ptr[2] /= vpere;
183 map< EntityHandle, tag_struct > elem_map;
184 e_it = elems.
begin();
185 while( e_it != elems.
end() )
189 "Error in tag2_iterate" );
191 "Error in tag3_iterate" );
192 elem_map[*e_it] = ts;
200 const vector< EntityHandle >** adjs_ptr;
201 while( v_it != verts.
end() )
206 "Error in coords_iterate" );
208 "Error in adjacencies_iterate" );
210 for(
int v = 0; v < count; v++ )
212 const vector< EntityHandle >* avec = *( adjs_ptr + v );
213 for( vector< EntityHandle >::const_iterator ait = avec->begin(); ait != avec->end(); ++ait )
218 map< EntityHandle, tag_struct >::iterator mit = elem_map.upper_bound( *ait );
221 int a_ind = *ait - ( *mit ).first;
223 ts.
avg_ptr[3 * a_ind + 0] += x_ptr[v];
224 ts.
avg_ptr[3 * a_ind + 1] += y_ptr[v];
225 ts.
avg_ptr[3 * a_ind + 2] += z_ptr[v];
235 e_it = elems.
begin();
236 while( e_it != elems.
end() )
241 "Error in tag1_iterate" );
243 "Error in tag2_iterate" );
245 "Error in tag3_iterate" );
248 for(
int i = 0; i < count; i++ )
250 for(
int j = 0; j < 3; j++ )
251 tag2_ptr[3 * i + j] /= (
double)tag3_ptr[i];
252 if( tag1_ptr[3 * i] != tag2_ptr[3 * i] || tag1_ptr[3 * i + 1] != tag2_ptr[3 * i + 1] ||
253 tag1_ptr[3 * i + 2] != tag2_ptr[3 * i + 2] )
254 cout <<
"Tag1, tag2 disagree for element " << *e_it + i << endl;
272 vector< double* > coords;
277 "Error in get_node_arrays" );
280 "Error in get_element_connect" );
281 for(
int i = 0; i < nquads; i++ )
283 coords[0][2 * i] = coords[0][2 * i + 1] = (double)i;
284 coords[1][2 * i] = 0.0;
285 coords[1][2 * i + 1] = 1.0;
286 coords[2][2 * i] = coords[2][2 * i + 1] = (double)0.0;
288 for(
int j = 0; j < 4; j++ )
289 connect[4 * i + j] = quad_v + j;
293 coords[0][2 * nquads] = coords[0][2 * nquads + 1] = (double)nquads;
294 coords[1][2 * nquads] = 0.0;
295 coords[1][2 * nquads + 1] = 1.0;
296 coords[2][2 * nquads] = coords[2][2 * nquads + 1] = (double)0.0;
300 int de = nquads / ( nholes + 1 );
301 for(
int i = 0; i < nholes; i++ )