MOAB: Mesh Oriented datABase
(version 5.2.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2004 Lawrence Livermore National Laboratory. Under 00005 the terms of Contract B545069 with the University of Wisconsin -- 00006 Madison, Lawrence Livermore National Laboratory retains certain 00007 rights in this software. 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 (lgpl.txt) along with this library; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00023 kraftche@cae.wisc.edu 00024 00025 ***************************************************************** */ 00026 00027 #include <algorithm> 00028 #include <iostream> 00029 using std::cout; 00030 #include "cppunit/extensions/HelperMacros.h" 00031 00032 #include "Mesquite.hpp" 00033 #include "MsqError.hpp" 00034 #include "TopologyInfo.hpp" 00035 00036 using namespace MBMesquite; 00037 00038 class TopologyInfoTest : public CppUnit::TestFixture 00039 { 00040 private: 00041 CPPUNIT_TEST_SUITE( TopologyInfoTest ); 00042 00043 CPPUNIT_TEST( tri ); 00044 CPPUNIT_TEST( tri3 ); 00045 CPPUNIT_TEST( tri4 ); 00046 CPPUNIT_TEST( tri6 ); 00047 CPPUNIT_TEST( tri7 ); 00048 00049 CPPUNIT_TEST( quad ); 00050 CPPUNIT_TEST( quad4 ); 00051 CPPUNIT_TEST( quad5 ); 00052 CPPUNIT_TEST( quad8 ); 00053 CPPUNIT_TEST( quad9 ); 00054 00055 CPPUNIT_TEST( tet ); 00056 CPPUNIT_TEST( tet4 ); 00057 CPPUNIT_TEST( tet5 ); 00058 CPPUNIT_TEST( tet8 ); 00059 CPPUNIT_TEST( tet9 ); 00060 CPPUNIT_TEST( tet10 ); 00061 CPPUNIT_TEST( tet11 ); 00062 CPPUNIT_TEST( tet14 ); 00063 CPPUNIT_TEST( tet15 ); 00064 00065 CPPUNIT_TEST( hex ); 00066 CPPUNIT_TEST( hex8 ); 00067 CPPUNIT_TEST( hex9 ); 00068 CPPUNIT_TEST( hex14 ); 00069 CPPUNIT_TEST( hex15 ); 00070 CPPUNIT_TEST( hex20 ); 00071 CPPUNIT_TEST( hex21 ); 00072 CPPUNIT_TEST( hex26 ); 00073 CPPUNIT_TEST( hex27 ); 00074 00075 CPPUNIT_TEST( pyramid ); 00076 CPPUNIT_TEST( pyramid5 ); 00077 CPPUNIT_TEST( pyramid13 ); 00078 00079 CPPUNIT_TEST( wedge ); 00080 CPPUNIT_TEST( wedge6 ); 00081 CPPUNIT_TEST( wedge15 ); 00082 00083 CPPUNIT_TEST( polygon ); 00084 CPPUNIT_TEST( polyhedron ); 00085 00086 CPPUNIT_TEST( bad_type ); 00087 00088 CPPUNIT_TEST( tri_adj_vert ); 00089 CPPUNIT_TEST( quad_adj_vert ); 00090 CPPUNIT_TEST( tet_adj_vert ); 00091 CPPUNIT_TEST( hex_adj_vert ); 00092 CPPUNIT_TEST( pyr_adj_vert ); 00093 CPPUNIT_TEST( wdg_adj_vert ); 00094 00095 CPPUNIT_TEST( tri_rev_adj_vert ); 00096 CPPUNIT_TEST( quad_rev_adj_vert ); 00097 CPPUNIT_TEST( tet_rev_adj_vert ); 00098 CPPUNIT_TEST( hex_rev_adj_vert ); 00099 CPPUNIT_TEST( pyr_rev_adj_vert ); 00100 CPPUNIT_TEST( wdg_rev_adj_vert ); 00101 00102 CPPUNIT_TEST( higher_order_from_side ); 00103 CPPUNIT_TEST( side_from_higher_order ); 00104 CPPUNIT_TEST( find_edge ); 00105 CPPUNIT_TEST( find_face ); 00106 CPPUNIT_TEST( find_side ); 00107 CPPUNIT_TEST( compare_sides ); 00108 00109 CPPUNIT_TEST_SUITE_END(); 00110 00111 public: 00112 void setUp() {} 00113 00114 void tearDown() {} 00115 00116 TopologyInfoTest() {} 00117 00118 bool compare_edge( const unsigned* a, const unsigned* b ); 00119 00120 bool compare_face( unsigned len, const unsigned* a, const unsigned* b ); 00121 00122 bool compare_vol( unsigned len, const unsigned* a, const unsigned* b ); 00123 00124 void test_face_elem( EntityTopology topo, unsigned num_nodes, unsigned num_sides ); 00125 00126 void test_vol_elem( EntityTopology topo, unsigned num_nodes, unsigned num_verts, unsigned num_edges, 00127 unsigned num_faces ); 00128 00129 void test_poly( EntityTopology topo ); 00130 00131 void tri(); 00132 void tri3(); 00133 void tri4(); 00134 void tri6(); 00135 void tri7(); 00136 00137 void quad(); 00138 void quad4(); 00139 void quad5(); 00140 void quad8(); 00141 void quad9(); 00142 00143 void tet(); 00144 void tet4(); 00145 void tet5(); 00146 void tet8(); 00147 void tet9(); 00148 void tet10(); 00149 void tet11(); 00150 void tet14(); 00151 void tet15(); 00152 00153 void hex(); 00154 void hex8(); 00155 void hex9(); 00156 void hex14(); 00157 void hex15(); 00158 void hex20(); 00159 void hex21(); 00160 void hex26(); 00161 void hex27(); 00162 00163 void pyramid(); 00164 void pyramid5(); 00165 void pyramid13(); 00166 00167 void wedge(); 00168 void wedge6(); 00169 void wedge15(); 00170 00171 void polygon(); 00172 void polyhedron(); 00173 00174 void bad_type(); 00175 00176 void tri_adj_vert(); 00177 void quad_adj_vert(); 00178 void tet_adj_vert(); 00179 void hex_adj_vert(); 00180 void pyr_adj_vert(); 00181 void wdg_adj_vert(); 00182 void test_adj( MBMesquite::EntityTopology, const unsigned expected[][5] ); 00183 00184 void tri_rev_adj_vert() 00185 { 00186 test_rev_adj( MBMesquite::TRIANGLE ); 00187 } 00188 void quad_rev_adj_vert() 00189 { 00190 test_rev_adj( MBMesquite::QUADRILATERAL ); 00191 } 00192 void tet_rev_adj_vert() 00193 { 00194 test_rev_adj( MBMesquite::TETRAHEDRON ); 00195 } 00196 void hex_rev_adj_vert() 00197 { 00198 test_rev_adj( MBMesquite::HEXAHEDRON ); 00199 } 00200 void pyr_rev_adj_vert() 00201 { 00202 test_rev_adj( MBMesquite::PYRAMID ); 00203 } 00204 void wdg_rev_adj_vert() 00205 { 00206 test_rev_adj( MBMesquite::PRISM ); 00207 } 00208 void test_rev_adj( MBMesquite::EntityTopology type ); 00209 00210 void higher_order_from_side(); 00211 void side_from_higher_order(); 00212 void find_edge(); 00213 void find_face(); 00214 void find_side(); 00215 void compare_sides(); 00216 }; 00217 00218 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopologyInfoTest, "TopologyInfoTest" ); 00219 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopologyInfoTest, "Unit" ); 00220 00221 bool TopologyInfoTest::compare_edge( const unsigned* a, const unsigned* b ) 00222 { 00223 return ( a[0] == b[0] && a[1] == b[1] ) || ( a[0] == b[1] && a[1] == b[0] ); 00224 } 00225 00226 bool TopologyInfoTest::compare_face( unsigned len, const unsigned* a, const unsigned* b ) 00227 { 00228 unsigned i, j; 00229 for( i = 0; i < len; ++i ) 00230 { 00231 for( j = 0; j < len; ++j ) 00232 { 00233 if( a[j] != b[( i + j ) % len] ) break; 00234 } 00235 if( j == len ) return true; 00236 } 00237 return false; 00238 } 00239 00240 bool TopologyInfoTest::compare_vol( unsigned len, const unsigned* a, const unsigned* b ) 00241 { 00242 for( unsigned i = 0; i < len; ++i ) 00243 if( a[i] != b[i] ) return false; 00244 return true; 00245 } 00246 00247 void TopologyInfoTest::test_face_elem( EntityTopology topo, unsigned num_nodes, unsigned num_sides ) 00248 { 00249 MsqPrintError err( cout ); 00250 bool edge, face, vol; 00251 unsigned index = 0; 00252 TopologyInfo::higher_order( topo, num_nodes, edge, face, vol, err ); 00253 CPPUNIT_ASSERT( !err ); 00254 CPPUNIT_ASSERT( !vol ); 00255 00256 unsigned nodes = num_sides + edge * num_sides + face; 00257 CPPUNIT_ASSERT( num_nodes == nodes ); 00258 00259 unsigned side, dim; 00260 for( index = 0; index < num_sides; ++index ) 00261 { 00262 TopologyInfo::side_number( topo, num_nodes, index, dim, side, err ); 00263 CPPUNIT_ASSERT( !err ); 00264 CPPUNIT_ASSERT( dim == 0 && side == index ); 00265 } 00266 00267 if( edge ) 00268 { 00269 for( unsigned s = 0; s < num_sides; ++s ) 00270 { 00271 TopologyInfo::side_number( topo, num_nodes, index++, dim, side, err ); 00272 CPPUNIT_ASSERT( !err ); 00273 CPPUNIT_ASSERT( dim == 1 && side == s ); 00274 } 00275 } 00276 if( face ) 00277 { 00278 TopologyInfo::side_number( topo, num_nodes, index++, dim, side, err ); 00279 CPPUNIT_ASSERT( !err ); 00280 CPPUNIT_ASSERT( dim == 2 && side == 0 ); 00281 } 00282 } 00283 00284 void TopologyInfoTest::test_vol_elem( EntityTopology topo, unsigned num_nodes, unsigned num_verts, unsigned num_edges, 00285 unsigned num_faces ) 00286 { 00287 MsqPrintError err( cout ); 00288 bool edge, face, vol; 00289 unsigned index = 0; 00290 TopologyInfo::higher_order( topo, num_nodes, edge, face, vol, err ); 00291 CPPUNIT_ASSERT( !err ); 00292 00293 unsigned nodes = num_verts + edge * num_edges + face * num_faces + vol; 00294 CPPUNIT_ASSERT( num_nodes == nodes ); 00295 00296 unsigned side, dim; 00297 for( index = 0; index < num_verts; ++index ) 00298 { 00299 TopologyInfo::side_number( topo, num_nodes, index, dim, side, err ); 00300 CPPUNIT_ASSERT( !err ); 00301 CPPUNIT_ASSERT( dim == 0 && side == index ); 00302 } 00303 00304 if( edge ) 00305 { 00306 for( unsigned s = 0; s < num_edges; ++s ) 00307 { 00308 TopologyInfo::side_number( topo, num_nodes, index++, dim, side, err ); 00309 CPPUNIT_ASSERT( !err ); 00310 CPPUNIT_ASSERT( dim == 1 && side == s ); 00311 } 00312 } 00313 if( face ) 00314 { 00315 for( unsigned s = 0; s < num_faces; ++s ) 00316 { 00317 TopologyInfo::side_number( topo, num_nodes, index++, dim, side, err ); 00318 CPPUNIT_ASSERT( !err ); 00319 CPPUNIT_ASSERT( dim == 2 && side == s ); 00320 } 00321 } 00322 if( vol ) 00323 { 00324 TopologyInfo::side_number( topo, num_nodes, index++, dim, side, err ); 00325 CPPUNIT_ASSERT( !err ); 00326 CPPUNIT_ASSERT( dim == 3 && side == 0 ); 00327 } 00328 } 00329 00330 void TopologyInfoTest::tri() 00331 { 00332 MsqPrintError err( cout ); 00333 00334 CPPUNIT_ASSERT( 2 == TopologyInfo::dimension( TRIANGLE ) ); 00335 CPPUNIT_ASSERT( 3 == TopologyInfo::adjacent( TRIANGLE, 1 ) ); 00336 CPPUNIT_ASSERT( 3 == TopologyInfo::adjacent( TRIANGLE, 0 ) ); 00337 CPPUNIT_ASSERT( 1 == TopologyInfo::adjacent( TRIANGLE, 2 ) ); 00338 CPPUNIT_ASSERT( 0 == TopologyInfo::adjacent( TRIANGLE, 3 ) ); 00339 00340 CPPUNIT_ASSERT( 3 == TopologyInfo::sides( TRIANGLE ) ); 00341 CPPUNIT_ASSERT( 3 == TopologyInfo::corners( TRIANGLE ) ); 00342 CPPUNIT_ASSERT( 3 == TopologyInfo::edges( TRIANGLE ) ); 00343 CPPUNIT_ASSERT( 1 == TopologyInfo::faces( TRIANGLE ) ); 00344 00345 const unsigned num_edges = 3; 00346 const unsigned* side; 00347 const unsigned edges[num_edges][2] = { { 0, 1 }, { 1, 2 }, { 2, 0 } }; 00348 unsigned count; 00349 const unsigned face[] = { 0, 1, 2 }; 00350 00351 for( unsigned i = 0; i < num_edges; ++i ) 00352 { 00353 side = TopologyInfo::edge_vertices( TRIANGLE, i, err ); 00354 CPPUNIT_ASSERT( !err ); 00355 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00356 00357 side = TopologyInfo::side_vertices( TRIANGLE, 1, i, count, err ); 00358 CPPUNIT_ASSERT( !err ); 00359 CPPUNIT_ASSERT( 2 == count ); 00360 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00361 } 00362 00363 side = TopologyInfo::side_vertices( TRIANGLE, 2, 0, count, err ); 00364 CPPUNIT_ASSERT( !err ); 00365 CPPUNIT_ASSERT( 3 == count ); 00366 CPPUNIT_ASSERT( compare_face( 3, side, face ) ); 00367 } 00368 00369 void TopologyInfoTest::tri3() 00370 { 00371 MsqPrintError err( cout ); 00372 bool edge, face, vol; 00373 const int num_nodes = 3; 00374 00375 TopologyInfo::higher_order( TRIANGLE, num_nodes, edge, face, vol, err ); 00376 CPPUNIT_ASSERT( !err ); 00377 CPPUNIT_ASSERT( !edge ); 00378 CPPUNIT_ASSERT( !face ); 00379 00380 test_face_elem( TRIANGLE, num_nodes, 3 ); 00381 } 00382 00383 void TopologyInfoTest::tri4() 00384 { 00385 MsqPrintError err( cout ); 00386 bool edge, face, vol; 00387 const int num_nodes = 4; 00388 00389 TopologyInfo::higher_order( TRIANGLE, num_nodes, edge, face, vol, err ); 00390 CPPUNIT_ASSERT( !err ); 00391 CPPUNIT_ASSERT( !edge ); 00392 CPPUNIT_ASSERT( face ); 00393 CPPUNIT_ASSERT( !vol ); 00394 00395 test_face_elem( TRIANGLE, num_nodes, 3 ); 00396 } 00397 00398 void TopologyInfoTest::tri6() 00399 { 00400 MsqPrintError err( cout ); 00401 bool edge, face, vol; 00402 const int num_nodes = 6; 00403 00404 TopologyInfo::higher_order( TRIANGLE, num_nodes, edge, face, vol, err ); 00405 CPPUNIT_ASSERT( !err ); 00406 CPPUNIT_ASSERT( edge ); 00407 CPPUNIT_ASSERT( !face ); 00408 CPPUNIT_ASSERT( !vol ); 00409 00410 test_face_elem( TRIANGLE, num_nodes, 3 ); 00411 } 00412 00413 void TopologyInfoTest::tri7() 00414 { 00415 MsqPrintError err( cout ); 00416 bool edge, face, vol; 00417 const int num_nodes = 7; 00418 00419 TopologyInfo::higher_order( TRIANGLE, num_nodes, edge, face, vol, err ); 00420 CPPUNIT_ASSERT( !err ); 00421 CPPUNIT_ASSERT( edge ); 00422 CPPUNIT_ASSERT( face ); 00423 CPPUNIT_ASSERT( !vol ); 00424 00425 test_face_elem( TRIANGLE, num_nodes, 3 ); 00426 } 00427 00428 void TopologyInfoTest::quad() 00429 { 00430 MsqPrintError err( cout ); 00431 00432 CPPUNIT_ASSERT( 2 == TopologyInfo::dimension( QUADRILATERAL ) ); 00433 CPPUNIT_ASSERT( 4 == TopologyInfo::adjacent( QUADRILATERAL, 1 ) ); 00434 CPPUNIT_ASSERT( 4 == TopologyInfo::adjacent( QUADRILATERAL, 0 ) ); 00435 CPPUNIT_ASSERT( 1 == TopologyInfo::adjacent( QUADRILATERAL, 2 ) ); 00436 CPPUNIT_ASSERT( 0 == TopologyInfo::adjacent( QUADRILATERAL, 3 ) ); 00437 00438 CPPUNIT_ASSERT( 4 == TopologyInfo::sides( QUADRILATERAL ) ); 00439 CPPUNIT_ASSERT( 4 == TopologyInfo::corners( QUADRILATERAL ) ); 00440 CPPUNIT_ASSERT( 4 == TopologyInfo::edges( QUADRILATERAL ) ); 00441 CPPUNIT_ASSERT( 1 == TopologyInfo::faces( QUADRILATERAL ) ); 00442 00443 const unsigned num_edges = 4; 00444 const unsigned* side; 00445 const unsigned edges[num_edges][2] = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 } }; 00446 unsigned count; 00447 const unsigned face[] = { 0, 1, 2, 3 }; 00448 00449 for( unsigned i = 0; i < num_edges; ++i ) 00450 { 00451 side = TopologyInfo::edge_vertices( QUADRILATERAL, i, err ); 00452 CPPUNIT_ASSERT( !err ); 00453 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00454 00455 side = TopologyInfo::side_vertices( QUADRILATERAL, 1, i, count, err ); 00456 CPPUNIT_ASSERT( !err ); 00457 CPPUNIT_ASSERT( 2 == count ); 00458 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00459 } 00460 00461 side = TopologyInfo::side_vertices( QUADRILATERAL, 2, 0, count, err ); 00462 CPPUNIT_ASSERT( !err ); 00463 CPPUNIT_ASSERT( 4 == count ); 00464 CPPUNIT_ASSERT( compare_face( 4, side, face ) ); 00465 } 00466 00467 void TopologyInfoTest::quad4() 00468 { 00469 MsqPrintError err( cout ); 00470 bool edge, face, vol; 00471 const int num_nodes = 4; 00472 00473 TopologyInfo::higher_order( QUADRILATERAL, num_nodes, edge, face, vol, err ); 00474 CPPUNIT_ASSERT( !err ); 00475 CPPUNIT_ASSERT( !edge ); 00476 CPPUNIT_ASSERT( !face ); 00477 CPPUNIT_ASSERT( !vol ); 00478 00479 test_face_elem( QUADRILATERAL, num_nodes, 4 ); 00480 } 00481 00482 void TopologyInfoTest::quad5() 00483 { 00484 MsqPrintError err( cout ); 00485 bool edge, face, vol; 00486 const int num_nodes = 5; 00487 00488 TopologyInfo::higher_order( QUADRILATERAL, num_nodes, edge, face, vol, err ); 00489 CPPUNIT_ASSERT( !err ); 00490 CPPUNIT_ASSERT( !edge ); 00491 CPPUNIT_ASSERT( face ); 00492 CPPUNIT_ASSERT( !vol ); 00493 00494 test_face_elem( QUADRILATERAL, num_nodes, 4 ); 00495 } 00496 00497 void TopologyInfoTest::quad8() 00498 { 00499 MsqPrintError err( cout ); 00500 bool edge, face, vol; 00501 const int num_nodes = 8; 00502 00503 TopologyInfo::higher_order( QUADRILATERAL, num_nodes, edge, face, vol, err ); 00504 CPPUNIT_ASSERT( !err ); 00505 CPPUNIT_ASSERT( edge ); 00506 CPPUNIT_ASSERT( !face ); 00507 CPPUNIT_ASSERT( !vol ); 00508 00509 test_face_elem( QUADRILATERAL, num_nodes, 4 ); 00510 } 00511 00512 void TopologyInfoTest::quad9() 00513 { 00514 MsqPrintError err( cout ); 00515 bool edge, face, vol; 00516 const int num_nodes = 9; 00517 00518 TopologyInfo::higher_order( QUADRILATERAL, num_nodes, edge, face, vol, err ); 00519 CPPUNIT_ASSERT( !err ); 00520 CPPUNIT_ASSERT( edge ); 00521 CPPUNIT_ASSERT( face ); 00522 CPPUNIT_ASSERT( !vol ); 00523 00524 test_face_elem( QUADRILATERAL, num_nodes, 4 ); 00525 } 00526 00527 void TopologyInfoTest::tet() 00528 { 00529 MsqPrintError err( cout ); 00530 00531 const unsigned num_verts = 4; 00532 const unsigned num_edges = 6; 00533 const unsigned num_faces = 4; 00534 CPPUNIT_ASSERT( 3 == TopologyInfo::dimension( TETRAHEDRON ) ); 00535 CPPUNIT_ASSERT( 1 == TopologyInfo::adjacent( TETRAHEDRON, 3 ) ); 00536 CPPUNIT_ASSERT( num_faces == TopologyInfo::adjacent( TETRAHEDRON, 2 ) ); 00537 CPPUNIT_ASSERT( num_edges == TopologyInfo::adjacent( TETRAHEDRON, 1 ) ); 00538 CPPUNIT_ASSERT( num_verts == TopologyInfo::adjacent( TETRAHEDRON, 0 ) ); 00539 00540 CPPUNIT_ASSERT( num_faces == TopologyInfo::sides( TETRAHEDRON ) ); 00541 CPPUNIT_ASSERT( num_verts == TopologyInfo::corners( TETRAHEDRON ) ); 00542 CPPUNIT_ASSERT( num_edges == TopologyInfo::edges( TETRAHEDRON ) ); 00543 CPPUNIT_ASSERT( num_faces == TopologyInfo::faces( TETRAHEDRON ) ); 00544 00545 const unsigned* side; 00546 unsigned i, count; 00547 const unsigned vert_per_face = 3; 00548 unsigned edges[num_edges][2] = { { 0, 1 }, { 1, 2 }, { 2, 0 }, { 0, 3 }, { 1, 3 }, { 2, 3 } }; 00549 unsigned faces[num_faces][vert_per_face] = { { 0, 1, 3 }, { 1, 2, 3 }, { 2, 0, 3 }, { 2, 1, 0 } }; 00550 00551 for( i = 0; i < num_edges; ++i ) 00552 { 00553 side = TopologyInfo::edge_vertices( TETRAHEDRON, i, err ); 00554 CPPUNIT_ASSERT( !err ); 00555 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00556 00557 side = TopologyInfo::side_vertices( TETRAHEDRON, 1, i, count, err ); 00558 CPPUNIT_ASSERT( !err ); 00559 CPPUNIT_ASSERT( 2 == count ); 00560 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00561 } 00562 00563 for( i = 0; i < num_faces; ++i ) 00564 { 00565 side = TopologyInfo::face_vertices( TETRAHEDRON, i, count, err ); 00566 CPPUNIT_ASSERT( !err ); 00567 CPPUNIT_ASSERT( count == vert_per_face ); 00568 CPPUNIT_ASSERT( compare_face( vert_per_face, side, faces[i] ) ); 00569 00570 side = TopologyInfo::side_vertices( TETRAHEDRON, 2, i, count, err ); 00571 CPPUNIT_ASSERT( !err ); 00572 CPPUNIT_ASSERT( count == vert_per_face ); 00573 CPPUNIT_ASSERT( compare_face( vert_per_face, side, faces[i] ) ); 00574 } 00575 00576 side = TopologyInfo::side_vertices( TETRAHEDRON, 3, 0, count, err ); 00577 CPPUNIT_ASSERT( !err ); 00578 CPPUNIT_ASSERT( count == num_verts ); 00579 for( i = 0; i < num_verts; ++i ) 00580 CPPUNIT_ASSERT( side[i] == i ); 00581 } 00582 00583 void TopologyInfoTest::tet4() 00584 { 00585 MsqPrintError err( cout ); 00586 bool edge, face, vol; 00587 const int num_nodes = 4; 00588 00589 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00590 CPPUNIT_ASSERT( !err ); 00591 CPPUNIT_ASSERT( !edge ); 00592 CPPUNIT_ASSERT( !face ); 00593 CPPUNIT_ASSERT( !vol ); 00594 00595 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00596 } 00597 00598 void TopologyInfoTest::tet5() 00599 { 00600 MsqPrintError err( cout ); 00601 bool edge, face, vol; 00602 const int num_nodes = 5; 00603 00604 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00605 CPPUNIT_ASSERT( !err ); 00606 CPPUNIT_ASSERT( !edge ); 00607 CPPUNIT_ASSERT( !face ); 00608 CPPUNIT_ASSERT( vol ); 00609 00610 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00611 } 00612 00613 void TopologyInfoTest::tet8() 00614 { 00615 MsqPrintError err( cout ); 00616 bool edge, face, vol; 00617 const int num_nodes = 8; 00618 00619 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00620 CPPUNIT_ASSERT( !err ); 00621 CPPUNIT_ASSERT( !edge ); 00622 CPPUNIT_ASSERT( face ); 00623 CPPUNIT_ASSERT( !vol ); 00624 00625 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00626 } 00627 00628 void TopologyInfoTest::tet9() 00629 { 00630 MsqPrintError err( cout ); 00631 bool edge, face, vol; 00632 const int num_nodes = 9; 00633 00634 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00635 CPPUNIT_ASSERT( !err ); 00636 CPPUNIT_ASSERT( !edge ); 00637 CPPUNIT_ASSERT( face ); 00638 CPPUNIT_ASSERT( vol ); 00639 00640 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00641 } 00642 00643 void TopologyInfoTest::tet10() 00644 { 00645 MsqPrintError err( cout ); 00646 bool edge, face, vol; 00647 const int num_nodes = 10; 00648 00649 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00650 CPPUNIT_ASSERT( !err ); 00651 CPPUNIT_ASSERT( edge ); 00652 CPPUNIT_ASSERT( !face ); 00653 CPPUNIT_ASSERT( !vol ); 00654 00655 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00656 } 00657 00658 void TopologyInfoTest::tet11() 00659 { 00660 MsqPrintError err( cout ); 00661 bool edge, face, vol; 00662 const int num_nodes = 11; 00663 00664 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00665 CPPUNIT_ASSERT( !err ); 00666 CPPUNIT_ASSERT( edge ); 00667 CPPUNIT_ASSERT( !face ); 00668 CPPUNIT_ASSERT( vol ); 00669 00670 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00671 } 00672 00673 void TopologyInfoTest::tet14() 00674 { 00675 MsqPrintError err( cout ); 00676 bool edge, face, vol; 00677 const int num_nodes = 14; 00678 00679 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00680 CPPUNIT_ASSERT( !err ); 00681 CPPUNIT_ASSERT( edge ); 00682 CPPUNIT_ASSERT( face ); 00683 CPPUNIT_ASSERT( !vol ); 00684 00685 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00686 } 00687 00688 void TopologyInfoTest::tet15() 00689 { 00690 MsqPrintError err( cout ); 00691 bool edge, face, vol; 00692 const int num_nodes = 15; 00693 00694 TopologyInfo::higher_order( TETRAHEDRON, num_nodes, edge, face, vol, err ); 00695 CPPUNIT_ASSERT( !err ); 00696 CPPUNIT_ASSERT( edge ); 00697 CPPUNIT_ASSERT( face ); 00698 CPPUNIT_ASSERT( vol ); 00699 00700 test_vol_elem( TETRAHEDRON, num_nodes, 4, 6, 4 ); 00701 } 00702 00703 void TopologyInfoTest::hex() 00704 { 00705 MsqPrintError err( cout ); 00706 00707 const unsigned num_verts = 8; 00708 const unsigned num_edges = 12; 00709 const unsigned num_faces = 6; 00710 CPPUNIT_ASSERT( 3 == TopologyInfo::dimension( HEXAHEDRON ) ); 00711 CPPUNIT_ASSERT( 1 == TopologyInfo::adjacent( HEXAHEDRON, 3 ) ); 00712 CPPUNIT_ASSERT( num_faces == TopologyInfo::adjacent( HEXAHEDRON, 2 ) ); 00713 CPPUNIT_ASSERT( num_edges == TopologyInfo::adjacent( HEXAHEDRON, 1 ) ); 00714 CPPUNIT_ASSERT( num_verts == TopologyInfo::adjacent( HEXAHEDRON, 0 ) ); 00715 00716 CPPUNIT_ASSERT( num_faces == TopologyInfo::sides( HEXAHEDRON ) ); 00717 CPPUNIT_ASSERT( num_verts == TopologyInfo::corners( HEXAHEDRON ) ); 00718 CPPUNIT_ASSERT( num_edges == TopologyInfo::edges( HEXAHEDRON ) ); 00719 CPPUNIT_ASSERT( num_faces == TopologyInfo::faces( HEXAHEDRON ) ); 00720 00721 const unsigned* side; 00722 unsigned i, count; 00723 const unsigned vert_per_face = 4; 00724 unsigned edges[num_edges][2] = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 0, 4 }, { 1, 5 }, 00725 { 2, 6 }, { 3, 7 }, { 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 4 } }; 00726 unsigned faces[num_faces][vert_per_face] = { { 0, 1, 5, 4 }, { 1, 2, 6, 5 }, { 2, 3, 7, 6 }, 00727 { 3, 0, 4, 7 }, { 3, 2, 1, 0 }, { 4, 5, 6, 7 } }; 00728 00729 for( i = 0; i < num_edges; ++i ) 00730 { 00731 side = TopologyInfo::edge_vertices( HEXAHEDRON, i, err ); 00732 CPPUNIT_ASSERT( !err ); 00733 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00734 00735 side = TopologyInfo::side_vertices( HEXAHEDRON, 1, i, count, err ); 00736 CPPUNIT_ASSERT( !err ); 00737 CPPUNIT_ASSERT( 2 == count ); 00738 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00739 } 00740 00741 for( i = 0; i < num_faces; ++i ) 00742 { 00743 side = TopologyInfo::face_vertices( HEXAHEDRON, i, count, err ); 00744 CPPUNIT_ASSERT( !err ); 00745 CPPUNIT_ASSERT( count == vert_per_face ); 00746 CPPUNIT_ASSERT( compare_face( vert_per_face, side, faces[i] ) ); 00747 00748 side = TopologyInfo::side_vertices( HEXAHEDRON, 2, i, count, err ); 00749 CPPUNIT_ASSERT( !err ); 00750 CPPUNIT_ASSERT( count == vert_per_face ); 00751 CPPUNIT_ASSERT( compare_face( vert_per_face, side, faces[i] ) ); 00752 } 00753 00754 side = TopologyInfo::side_vertices( HEXAHEDRON, 3, 0, count, err ); 00755 CPPUNIT_ASSERT( !err ); 00756 CPPUNIT_ASSERT( count == num_verts ); 00757 for( i = 0; i < num_verts; ++i ) 00758 CPPUNIT_ASSERT( side[i] == i ); 00759 } 00760 00761 void TopologyInfoTest::hex8() 00762 { 00763 MsqPrintError err( cout ); 00764 bool edge, face, vol; 00765 const int num_nodes = 8; 00766 00767 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00768 CPPUNIT_ASSERT( !err ); 00769 CPPUNIT_ASSERT( !edge ); 00770 CPPUNIT_ASSERT( !face ); 00771 CPPUNIT_ASSERT( !vol ); 00772 00773 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00774 } 00775 00776 void TopologyInfoTest::hex9() 00777 { 00778 MsqPrintError err( cout ); 00779 bool edge, face, vol; 00780 const int num_nodes = 9; 00781 00782 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00783 CPPUNIT_ASSERT( !err ); 00784 CPPUNIT_ASSERT( !edge ); 00785 CPPUNIT_ASSERT( !face ); 00786 CPPUNIT_ASSERT( vol ); 00787 00788 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00789 } 00790 00791 void TopologyInfoTest::hex14() 00792 { 00793 MsqPrintError err( cout ); 00794 bool edge, face, vol; 00795 const int num_nodes = 14; 00796 00797 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00798 CPPUNIT_ASSERT( !err ); 00799 CPPUNIT_ASSERT( !edge ); 00800 CPPUNIT_ASSERT( face ); 00801 CPPUNIT_ASSERT( !vol ); 00802 00803 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00804 } 00805 00806 void TopologyInfoTest::hex15() 00807 { 00808 MsqPrintError err( cout ); 00809 bool edge, face, vol; 00810 const int num_nodes = 15; 00811 00812 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00813 CPPUNIT_ASSERT( !err ); 00814 CPPUNIT_ASSERT( !edge ); 00815 CPPUNIT_ASSERT( face ); 00816 CPPUNIT_ASSERT( vol ); 00817 00818 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00819 } 00820 00821 void TopologyInfoTest::hex20() 00822 { 00823 MsqPrintError err( cout ); 00824 bool edge, face, vol; 00825 const int num_nodes = 20; 00826 00827 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00828 CPPUNIT_ASSERT( !err ); 00829 CPPUNIT_ASSERT( edge ); 00830 CPPUNIT_ASSERT( !face ); 00831 CPPUNIT_ASSERT( !vol ); 00832 00833 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00834 } 00835 00836 void TopologyInfoTest::hex21() 00837 { 00838 MsqPrintError err( cout ); 00839 bool edge, face, vol; 00840 const int num_nodes = 21; 00841 00842 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00843 CPPUNIT_ASSERT( !err ); 00844 CPPUNIT_ASSERT( edge ); 00845 CPPUNIT_ASSERT( !face ); 00846 CPPUNIT_ASSERT( vol ); 00847 00848 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00849 } 00850 00851 void TopologyInfoTest::hex26() 00852 { 00853 MsqPrintError err( cout ); 00854 bool edge, face, vol; 00855 const int num_nodes = 26; 00856 00857 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00858 CPPUNIT_ASSERT( !err ); 00859 CPPUNIT_ASSERT( edge ); 00860 CPPUNIT_ASSERT( face ); 00861 CPPUNIT_ASSERT( !vol ); 00862 00863 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00864 } 00865 00866 void TopologyInfoTest::hex27() 00867 { 00868 MsqPrintError err( cout ); 00869 bool edge, face, vol; 00870 const int num_nodes = 27; 00871 00872 TopologyInfo::higher_order( HEXAHEDRON, num_nodes, edge, face, vol, err ); 00873 CPPUNIT_ASSERT( !err ); 00874 CPPUNIT_ASSERT( edge ); 00875 CPPUNIT_ASSERT( face ); 00876 CPPUNIT_ASSERT( vol ); 00877 00878 test_vol_elem( HEXAHEDRON, num_nodes, 8, 12, 6 ); 00879 } 00880 00881 void TopologyInfoTest::pyramid() 00882 { 00883 MsqPrintError err( cout ); 00884 00885 const unsigned num_verts = 5; 00886 const unsigned num_edges = 8; 00887 const unsigned num_faces = 5; 00888 CPPUNIT_ASSERT( 3 == TopologyInfo::dimension( PYRAMID ) ); 00889 CPPUNIT_ASSERT( 1 == TopologyInfo::adjacent( PYRAMID, 3 ) ); 00890 CPPUNIT_ASSERT( num_faces == TopologyInfo::adjacent( PYRAMID, 2 ) ); 00891 CPPUNIT_ASSERT( num_edges == TopologyInfo::adjacent( PYRAMID, 1 ) ); 00892 CPPUNIT_ASSERT( num_verts == TopologyInfo::adjacent( PYRAMID, 0 ) ); 00893 00894 CPPUNIT_ASSERT( num_faces == TopologyInfo::sides( PYRAMID ) ); 00895 CPPUNIT_ASSERT( num_verts == TopologyInfo::corners( PYRAMID ) ); 00896 CPPUNIT_ASSERT( num_edges == TopologyInfo::edges( PYRAMID ) ); 00897 CPPUNIT_ASSERT( num_faces == TopologyInfo::faces( PYRAMID ) ); 00898 00899 const unsigned* side; 00900 unsigned i, count; 00901 const unsigned num_tri_faces = 4; 00902 const unsigned num_quad_faces = 1; 00903 const bool tri_before_quad = true; 00904 CPPUNIT_ASSERT( num_tri_faces + num_quad_faces == num_faces ); 00905 unsigned edges[num_edges][2] = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 0, 4 }, { 1, 4 }, { 2, 4 }, { 3, 4 } }; 00906 unsigned tris[num_tri_faces][3] = { { 0, 1, 4 }, { 1, 2, 4 }, { 2, 3, 4 }, { 3, 0, 4 } }; 00907 unsigned quads[num_quad_faces][4] = { { 3, 2, 1, 0 } }; 00908 00909 for( i = 0; i < num_edges; ++i ) 00910 { 00911 side = TopologyInfo::edge_vertices( PYRAMID, i, err ); 00912 CPPUNIT_ASSERT( !err ); 00913 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00914 00915 side = TopologyInfo::side_vertices( PYRAMID, 1, i, count, err ); 00916 CPPUNIT_ASSERT( !err ); 00917 CPPUNIT_ASSERT( 2 == count ); 00918 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 00919 } 00920 00921 const unsigned tri_off = num_quad_faces * !tri_before_quad; 00922 for( i = 0; i < num_tri_faces; ++i ) 00923 { 00924 side = TopologyInfo::face_vertices( PYRAMID, i + tri_off, count, err ); 00925 CPPUNIT_ASSERT( !err ); 00926 CPPUNIT_ASSERT( count == 3 ); 00927 CPPUNIT_ASSERT( compare_face( 3, side, tris[i] ) ); 00928 00929 side = TopologyInfo::side_vertices( PYRAMID, 2, i + tri_off, count, err ); 00930 CPPUNIT_ASSERT( !err ); 00931 CPPUNIT_ASSERT( count == 3 ); 00932 CPPUNIT_ASSERT( compare_face( 3, side, tris[i] ) ); 00933 } 00934 00935 const unsigned quad_off = num_tri_faces * tri_before_quad; 00936 for( i = 0; i < num_quad_faces; ++i ) 00937 { 00938 side = TopologyInfo::face_vertices( PYRAMID, i + quad_off, count, err ); 00939 CPPUNIT_ASSERT( !err ); 00940 CPPUNIT_ASSERT( count == 4 ); 00941 CPPUNIT_ASSERT( compare_face( 4, side, quads[i] ) ); 00942 00943 side = TopologyInfo::side_vertices( PYRAMID, 2, i + quad_off, count, err ); 00944 CPPUNIT_ASSERT( !err ); 00945 CPPUNIT_ASSERT( count == 4 ); 00946 CPPUNIT_ASSERT( compare_face( 4, side, quads[i] ) ); 00947 } 00948 00949 side = TopologyInfo::side_vertices( PYRAMID, 3, 0, count, err ); 00950 CPPUNIT_ASSERT( !err ); 00951 CPPUNIT_ASSERT( count == num_verts ); 00952 for( i = 0; i < num_verts; ++i ) 00953 CPPUNIT_ASSERT( side[i] == i ); 00954 } 00955 00956 void TopologyInfoTest::pyramid5() 00957 { 00958 MsqPrintError err( cout ); 00959 bool edge, face, vol; 00960 const int num_nodes = 5; 00961 00962 TopologyInfo::higher_order( PYRAMID, num_nodes, edge, face, vol, err ); 00963 CPPUNIT_ASSERT( !err ); 00964 CPPUNIT_ASSERT( !edge ); 00965 CPPUNIT_ASSERT( !face ); 00966 CPPUNIT_ASSERT( !vol ); 00967 00968 test_vol_elem( PYRAMID, num_nodes, 5, 8, 5 ); 00969 } 00970 00971 void TopologyInfoTest::pyramid13() 00972 { 00973 MsqPrintError err( cout ); 00974 bool edge, face, vol; 00975 const int num_nodes = 13; 00976 00977 TopologyInfo::higher_order( PYRAMID, num_nodes, edge, face, vol, err ); 00978 CPPUNIT_ASSERT( !err ); 00979 CPPUNIT_ASSERT( edge ); 00980 CPPUNIT_ASSERT( !face ); 00981 CPPUNIT_ASSERT( !vol ); 00982 00983 test_vol_elem( PYRAMID, num_nodes, 5, 8, 5 ); 00984 } 00985 00986 void TopologyInfoTest::wedge() 00987 { 00988 MsqPrintError err( cout ); 00989 00990 const unsigned num_verts = 6; 00991 const unsigned num_edges = 9; 00992 const unsigned num_faces = 5; 00993 CPPUNIT_ASSERT( 3 == TopologyInfo::dimension( PRISM ) ); 00994 CPPUNIT_ASSERT( 1 == TopologyInfo::adjacent( PRISM, 3 ) ); 00995 CPPUNIT_ASSERT( num_faces == TopologyInfo::adjacent( PRISM, 2 ) ); 00996 CPPUNIT_ASSERT( num_edges == TopologyInfo::adjacent( PRISM, 1 ) ); 00997 CPPUNIT_ASSERT( num_verts == TopologyInfo::adjacent( PRISM, 0 ) ); 00998 00999 CPPUNIT_ASSERT( num_faces == TopologyInfo::sides( PRISM ) ); 01000 CPPUNIT_ASSERT( num_verts == TopologyInfo::corners( PRISM ) ); 01001 CPPUNIT_ASSERT( num_edges == TopologyInfo::edges( PRISM ) ); 01002 CPPUNIT_ASSERT( num_faces == TopologyInfo::faces( PRISM ) ); 01003 01004 const unsigned* side; 01005 unsigned i, count; 01006 const unsigned num_tri_faces = 2; 01007 const unsigned num_quad_faces = 3; 01008 const bool tri_before_quad = false; 01009 CPPUNIT_ASSERT( num_tri_faces + num_quad_faces == num_faces ); 01010 unsigned edges[num_edges][2] = { { 0, 1 }, { 1, 2 }, { 2, 0 }, { 0, 3 }, { 1, 4 }, 01011 { 2, 5 }, { 3, 4 }, { 4, 5 }, { 5, 3 } }; 01012 unsigned tris[num_tri_faces][3] = { { 2, 1, 0 }, { 3, 4, 5 } }; 01013 unsigned quads[num_quad_faces][4] = { { 0, 1, 4, 3 }, { 1, 2, 5, 4 }, { 2, 0, 3, 5 } }; 01014 01015 for( i = 0; i < num_edges; ++i ) 01016 { 01017 side = TopologyInfo::edge_vertices( PRISM, i, err ); 01018 CPPUNIT_ASSERT( !err ); 01019 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 01020 01021 side = TopologyInfo::side_vertices( PRISM, 1, i, count, err ); 01022 CPPUNIT_ASSERT( !err ); 01023 CPPUNIT_ASSERT( 2 == count ); 01024 CPPUNIT_ASSERT( compare_edge( side, edges[i] ) ); 01025 } 01026 01027 const unsigned tri_off = num_quad_faces * !tri_before_quad; 01028 for( i = 0; i < num_tri_faces; ++i ) 01029 { 01030 side = TopologyInfo::face_vertices( PRISM, i + tri_off, count, err ); 01031 CPPUNIT_ASSERT( !err ); 01032 CPPUNIT_ASSERT( count == 3 ); 01033 CPPUNIT_ASSERT( compare_face( 3, side, tris[i] ) ); 01034 01035 side = TopologyInfo::side_vertices( PRISM, 2, i + tri_off, count, err ); 01036 CPPUNIT_ASSERT( !err ); 01037 CPPUNIT_ASSERT( count == 3 ); 01038 CPPUNIT_ASSERT( compare_face( 3, side, tris[i] ) ); 01039 } 01040 01041 const unsigned quad_off = num_tri_faces * tri_before_quad; 01042 for( i = 0; i < num_quad_faces; ++i ) 01043 { 01044 side = TopologyInfo::face_vertices( PRISM, i + quad_off, count, err ); 01045 CPPUNIT_ASSERT( !err ); 01046 CPPUNIT_ASSERT( count == 4 ); 01047 CPPUNIT_ASSERT( compare_face( 4, side, quads[i] ) ); 01048 01049 side = TopologyInfo::side_vertices( PRISM, 2, i + quad_off, count, err ); 01050 CPPUNIT_ASSERT( !err ); 01051 CPPUNIT_ASSERT( count == 4 ); 01052 CPPUNIT_ASSERT( compare_face( 4, side, quads[i] ) ); 01053 } 01054 01055 side = TopologyInfo::side_vertices( PRISM, 3, 0, count, err ); 01056 CPPUNIT_ASSERT( !err ); 01057 CPPUNIT_ASSERT( count == num_verts ); 01058 for( i = 0; i < num_verts; ++i ) 01059 CPPUNIT_ASSERT( side[i] == i ); 01060 } 01061 01062 void TopologyInfoTest::wedge6() 01063 { 01064 MsqPrintError err( cout ); 01065 bool edge, face, vol; 01066 const int num_nodes = 6; 01067 01068 TopologyInfo::higher_order( PRISM, num_nodes, edge, face, vol, err ); 01069 CPPUNIT_ASSERT( !err ); 01070 CPPUNIT_ASSERT( !edge ); 01071 CPPUNIT_ASSERT( !face ); 01072 CPPUNIT_ASSERT( !vol ); 01073 01074 test_vol_elem( PRISM, num_nodes, 6, 9, 5 ); 01075 } 01076 01077 void TopologyInfoTest::wedge15() 01078 { 01079 MsqPrintError err( cout ); 01080 bool edge, face, vol; 01081 const int num_nodes = 15; 01082 01083 TopologyInfo::higher_order( PRISM, num_nodes, edge, face, vol, err ); 01084 CPPUNIT_ASSERT( !err ); 01085 CPPUNIT_ASSERT( edge ); 01086 CPPUNIT_ASSERT( !face ); 01087 CPPUNIT_ASSERT( !vol ); 01088 01089 test_vol_elem( PRISM, num_nodes, 6, 9, 5 ); 01090 } 01091 01092 void TopologyInfoTest::test_poly( EntityTopology topo ) 01093 { 01094 CPPUNIT_ASSERT( TopologyInfo::adjacent( topo, 1 ) == 0 ); 01095 CPPUNIT_ASSERT( TopologyInfo::sides( topo ) == 0 ); 01096 CPPUNIT_ASSERT( TopologyInfo::corners( topo ) == 0 ); 01097 CPPUNIT_ASSERT( TopologyInfo::edges( topo ) == 0 ); 01098 CPPUNIT_ASSERT( TopologyInfo::faces( topo ) == 0 ); 01099 } 01100 01101 void TopologyInfoTest::polygon() 01102 { 01103 CPPUNIT_ASSERT( TopologyInfo::dimension( POLYGON ) == 2 ); 01104 test_poly( POLYGON ); 01105 } 01106 01107 void TopologyInfoTest::polyhedron() 01108 { 01109 CPPUNIT_ASSERT( TopologyInfo::dimension( POLYHEDRON ) == 3 ); 01110 test_poly( POLYHEDRON ); 01111 } 01112 01113 void TopologyInfoTest::bad_type() 01114 { 01115 MBMesquite::MsqError err; 01116 EntityTopology bad_types[] = { (EntityTopology)0, (EntityTopology)1, MIXED, ( EntityTopology )( MIXED + 1 ) }; 01117 01118 for( unsigned i = 0; i < ( sizeof( bad_types ) / sizeof( EntityTopology ) ); ++i ) 01119 { 01120 CPPUNIT_ASSERT( TopologyInfo::dimension( bad_types[i] ) == 0 ); 01121 CPPUNIT_ASSERT( TopologyInfo::adjacent( bad_types[i], 1 ) == 0 ); 01122 CPPUNIT_ASSERT( TopologyInfo::sides( bad_types[i] ) == 0 ); 01123 CPPUNIT_ASSERT( TopologyInfo::corners( bad_types[i] ) == 0 ); 01124 CPPUNIT_ASSERT( TopologyInfo::edges( bad_types[i] ) == 0 ); 01125 CPPUNIT_ASSERT( TopologyInfo::faces( bad_types[i] ) == 0 ); 01126 01127 bool a, b, c; 01128 TopologyInfo::higher_order( bad_types[i], 20, a, b, c, err ); 01129 CPPUNIT_ASSERT( err ); 01130 01131 const unsigned* ptr; 01132 ptr = TopologyInfo::edge_vertices( bad_types[i], 0, err ); 01133 CPPUNIT_ASSERT( err ); 01134 01135 unsigned count; 01136 ptr = TopologyInfo::face_vertices( bad_types[i], 0, count, err ); 01137 CPPUNIT_ASSERT( err ); 01138 01139 for( unsigned j = 0; j < 4; ++j ) 01140 { 01141 ptr = TopologyInfo::side_vertices( bad_types[i], j, 0, count, err ); 01142 CPPUNIT_ASSERT( err ); 01143 } 01144 01145 unsigned dim, side; 01146 for( unsigned idx = 0; idx < 20; ++idx ) 01147 { 01148 TopologyInfo::side_number( bad_types[i], idx, idx / 2, dim, side, err ); 01149 CPPUNIT_ASSERT( err ); 01150 } 01151 } 01152 } 01153 01154 void TopologyInfoTest::tri_adj_vert() 01155 { 01156 unsigned data[][5] = { { 2, 1, 2, 0, 0 }, { 2, 2, 0, 0, 0 }, { 2, 0, 1, 0, 0 } }; 01157 test_adj( MBMesquite::TRIANGLE, data ); 01158 } 01159 01160 void TopologyInfoTest::quad_adj_vert() 01161 { 01162 unsigned data[][5] = { { 2, 1, 3, 0, 0 }, { 2, 2, 0, 0, 0 }, { 2, 3, 1, 0, 0 }, { 2, 0, 2, 0, 0 } }; 01163 test_adj( MBMesquite::QUADRILATERAL, data ); 01164 } 01165 01166 void TopologyInfoTest::tet_adj_vert() 01167 { 01168 unsigned data[][5] = { { 3, 1, 2, 3, 0 }, { 3, 2, 0, 3, 0 }, { 3, 0, 1, 3, 0 }, { 3, 2, 1, 0, 0 } }; 01169 test_adj( MBMesquite::TETRAHEDRON, data ); 01170 } 01171 01172 void TopologyInfoTest::hex_adj_vert() 01173 { 01174 unsigned data[][5] = { { 3, 1, 3, 4, 0 }, { 3, 2, 0, 5, 0 }, { 3, 3, 1, 6, 0 }, { 3, 0, 2, 7, 0 }, 01175 { 3, 7, 5, 0, 0 }, { 3, 4, 6, 1, 0 }, { 3, 5, 7, 2, 0 }, { 3, 6, 4, 3, 0 } }; 01176 test_adj( MBMesquite::HEXAHEDRON, data ); 01177 } 01178 01179 void TopologyInfoTest::pyr_adj_vert() 01180 { 01181 unsigned data[][5] = { 01182 { 3, 1, 3, 4, 0 }, { 3, 2, 0, 4, 0 }, { 3, 3, 1, 4, 0 }, { 3, 0, 2, 4, 0 }, { 4, 3, 2, 1, 0 } 01183 }; 01184 test_adj( MBMesquite::PYRAMID, data ); 01185 } 01186 01187 void TopologyInfoTest::wdg_adj_vert() 01188 { 01189 unsigned data[][5] = { { 3, 1, 2, 3, 0 }, { 3, 2, 0, 4, 0 }, { 3, 0, 1, 5, 0 }, 01190 { 3, 5, 4, 0, 0 }, { 3, 3, 5, 1, 0 }, { 3, 4, 3, 2, 0 } }; 01191 test_adj( MBMesquite::PRISM, data ); 01192 } 01193 01194 void TopologyInfoTest::test_adj( MBMesquite::EntityTopology type, const unsigned data[][5] ) 01195 { 01196 // Get num vertices from type 01197 unsigned n = TopologyInfo::corners( type ); 01198 CPPUNIT_ASSERT( n > 0 ); 01199 01200 // The first index into data is the vertex. 01201 // Each column of "data", indexed by vertex, is a 01202 // vector containing the number of adjacent vertices 01203 // followed by the list if adjacent vertex indices. 01204 01205 // for each vertex 01206 for( unsigned i = 0; i < n; ++i ) 01207 { 01208 // Get the data corresponding to this vertex of the element 01209 unsigned const* corner = data[i]; 01210 unsigned expected_count = corner[0]; 01211 // Query TopologyInfo for the same data 01212 unsigned actual_count; 01213 unsigned const* actual_adj = TopologyInfo::adjacent_vertices( type, i, actual_count ); 01214 // Check result is valid and counts match 01215 CPPUNIT_ASSERT( actual_adj != NULL ); 01216 CPPUNIT_ASSERT( expected_count == actual_count ); 01217 01218 // For 3-D elements, returned vertices are expected to be oriented 01219 // such that a face bounded by the vertices in the counter-clockwise 01220 // order will have a normal pointing away from the input vertex. 01221 // So the vertices must be in a certain order, but may begin with 01222 // any of the adjacent vertices. 01223 01224 // Find the location in the result list at which the first 01225 // vertex in the expected list occurs. 01226 unsigned j; 01227 for( j = 0; j < actual_count; ++j ) 01228 if( corner[1] == actual_adj[j] ) break; 01229 // Asssert that the first expected vertex was somewhere in 01230 // the result list. 01231 CPPUNIT_ASSERT( j < actual_count ); 01232 // Compare the remaining vertices, enforcing the order. 01233 for( unsigned k = 1; k < actual_count; ++k ) 01234 CPPUNIT_ASSERT( corner[k + 1] == actual_adj[( k + j ) % actual_count] ); 01235 } 01236 } 01237 01238 void TopologyInfoTest::test_rev_adj( MBMesquite::EntityTopology type ) 01239 { 01240 // Get num vertices from type 01241 unsigned n = TopologyInfo::corners( type ); 01242 CPPUNIT_ASSERT( n > 0 ); 01243 01244 // for each vertex 01245 for( unsigned i = 0; i < n; ++i ) 01246 { 01247 // get adjacent vertex list 01248 unsigned num_adj_idx; 01249 unsigned const* adj_idx = TopologyInfo::adjacent_vertices( type, i, num_adj_idx ); 01250 CPPUNIT_ASSERT( adj_idx != NULL ); 01251 CPPUNIT_ASSERT( num_adj_idx > 1 ); 01252 01253 // make sure adjacent vertex list is unique 01254 std::vector< unsigned > adj_idx_copy( num_adj_idx ); 01255 std::copy( adj_idx, adj_idx + num_adj_idx, adj_idx_copy.begin() ); 01256 std::sort( adj_idx_copy.begin(), adj_idx_copy.end() ); 01257 std::vector< unsigned >::iterator iter; 01258 iter = std::unique( adj_idx_copy.begin(), adj_idx_copy.end() ); 01259 CPPUNIT_ASSERT( iter == adj_idx_copy.end() ); 01260 01261 // Get reverse mapping indices 01262 unsigned num_rev_idx; 01263 unsigned const* rev_idx = TopologyInfo::reverse_vertex_adjacency_offsets( type, i, num_rev_idx ); 01264 CPPUNIT_ASSERT( rev_idx != NULL ); 01265 CPPUNIT_ASSERT( num_rev_idx == num_adj_idx ); 01266 01267 // for each adjacent vertex, test reverse mapping 01268 for( unsigned j = 0; j < num_adj_idx; ++j ) 01269 { 01270 unsigned num_adj_adj_idx; 01271 unsigned const* adj_adj_idx = TopologyInfo::adjacent_vertices( type, adj_idx[j], num_adj_adj_idx ); 01272 01273 CPPUNIT_ASSERT( rev_idx[j] < num_adj_adj_idx ); 01274 CPPUNIT_ASSERT( adj_adj_idx[rev_idx[j]] == i ); 01275 } 01276 } 01277 } 01278 01279 struct ho_result 01280 { 01281 unsigned dim; 01282 unsigned num; 01283 unsigned idx; 01284 }; 01285 01286 const ho_result HEX27[] = { { 1, 0, 8 }, { 1, 1, 9 }, { 1, 2, 10 }, { 1, 3, 11 }, { 1, 4, 12 }, 01287 { 1, 5, 13 }, { 1, 6, 14 }, { 1, 7, 15 }, { 1, 8, 16 }, { 1, 9, 17 }, 01288 { 1, 10, 18 }, { 1, 11, 19 }, { 2, 0, 20 }, { 2, 1, 21 }, { 2, 2, 22 }, 01289 { 2, 3, 23 }, { 2, 4, 24 }, { 2, 5, 25 }, { 3, 0, 26 } }; 01290 01291 const ho_result* const HEX20 = HEX27; 01292 const ho_result* const HEX26 = HEX27; 01293 01294 const ho_result HEX15[] = { { 2, 0, 8 }, { 2, 1, 9 }, { 2, 2, 10 }, { 2, 3, 11 }, 01295 { 2, 4, 12 }, { 2, 5, 13 }, { 3, 0, 14 } }; 01296 01297 const ho_result* const HEX14 = HEX15; 01298 01299 const ho_result HEX9[] = { { 3, 0, 8 } }; 01300 01301 void TopologyInfoTest::higher_order_from_side() 01302 { 01303 MsqPrintError err( std::cerr ); 01304 // HEX-27 01305 for( unsigned i = 0; i < 19; ++i ) 01306 { 01307 unsigned result = TopologyInfo::higher_order_from_side( HEXAHEDRON, 27, HEX27[i].dim, HEX27[i].num, err ); 01308 CPPUNIT_ASSERT( !err ); 01309 CPPUNIT_ASSERT_EQUAL( HEX27[i].idx, result ); 01310 } 01311 // HEX-26 01312 for( unsigned i = 0; i < 18; ++i ) 01313 { 01314 unsigned result = TopologyInfo::higher_order_from_side( HEXAHEDRON, 26, HEX26[i].dim, HEX26[i].num, err ); 01315 CPPUNIT_ASSERT( !err ); 01316 CPPUNIT_ASSERT_EQUAL( HEX26[i].idx, result ); 01317 } 01318 // HEX-20 01319 for( unsigned i = 0; i < 12; ++i ) 01320 { 01321 unsigned result = TopologyInfo::higher_order_from_side( HEXAHEDRON, 20, HEX20[i].dim, HEX20[i].num, err ); 01322 CPPUNIT_ASSERT( !err ); 01323 CPPUNIT_ASSERT_EQUAL( HEX20[i].idx, result ); 01324 } 01325 // HEX-15 01326 for( unsigned i = 0; i < 7; ++i ) 01327 { 01328 unsigned result = TopologyInfo::higher_order_from_side( HEXAHEDRON, 15, HEX15[i].dim, HEX15[i].num, err ); 01329 CPPUNIT_ASSERT( !err ); 01330 CPPUNIT_ASSERT_EQUAL( HEX15[i].idx, result ); 01331 } 01332 // HEX-14 01333 for( unsigned i = 0; i < 6; ++i ) 01334 { 01335 unsigned result = TopologyInfo::higher_order_from_side( HEXAHEDRON, 14, HEX14[i].dim, HEX14[i].num, err ); 01336 CPPUNIT_ASSERT( !err ); 01337 CPPUNIT_ASSERT_EQUAL( HEX14[i].idx, result ); 01338 } 01339 // HEX-9 01340 for( unsigned i = 0; i < 1; ++i ) 01341 { 01342 unsigned result = TopologyInfo::higher_order_from_side( HEXAHEDRON, 9, HEX9[i].dim, HEX9[i].num, err ); 01343 CPPUNIT_ASSERT( !err ); 01344 CPPUNIT_ASSERT_EQUAL( HEX9[i].idx, result ); 01345 } 01346 } 01347 01348 void TopologyInfoTest::side_from_higher_order() 01349 { 01350 MsqPrintError err( std::cerr ); 01351 unsigned dim, num; 01352 // HEX-27 01353 for( unsigned i = 0; i < 19; ++i ) 01354 { 01355 TopologyInfo::side_from_higher_order( HEXAHEDRON, 27, HEX27[i].idx, dim, num, err ); 01356 CPPUNIT_ASSERT( !err ); 01357 CPPUNIT_ASSERT_EQUAL( HEX27[i].dim, dim ); 01358 CPPUNIT_ASSERT_EQUAL( HEX27[i].num, num ); 01359 } 01360 // HEX-26 01361 for( unsigned i = 0; i < 18; ++i ) 01362 { 01363 TopologyInfo::side_from_higher_order( HEXAHEDRON, 26, HEX26[i].idx, dim, num, err ); 01364 CPPUNIT_ASSERT( !err ); 01365 CPPUNIT_ASSERT_EQUAL( HEX26[i].dim, dim ); 01366 CPPUNIT_ASSERT_EQUAL( HEX26[i].num, num ); 01367 } 01368 // HEX-20 01369 for( unsigned i = 0; i < 12; ++i ) 01370 { 01371 TopologyInfo::side_from_higher_order( HEXAHEDRON, 20, HEX20[i].idx, dim, num, err ); 01372 CPPUNIT_ASSERT( !err ); 01373 CPPUNIT_ASSERT_EQUAL( HEX20[i].dim, dim ); 01374 CPPUNIT_ASSERT_EQUAL( HEX20[i].num, num ); 01375 } 01376 // HEX-15 01377 for( unsigned i = 0; i < 7; ++i ) 01378 { 01379 TopologyInfo::side_from_higher_order( HEXAHEDRON, 15, HEX15[i].idx, dim, num, err ); 01380 CPPUNIT_ASSERT( !err ); 01381 CPPUNIT_ASSERT_EQUAL( HEX15[i].dim, dim ); 01382 CPPUNIT_ASSERT_EQUAL( HEX15[i].num, num ); 01383 } 01384 // HEX-14 01385 for( unsigned i = 0; i < 6; ++i ) 01386 { 01387 TopologyInfo::side_from_higher_order( HEXAHEDRON, 14, HEX14[i].idx, dim, num, err ); 01388 CPPUNIT_ASSERT( !err ); 01389 CPPUNIT_ASSERT_EQUAL( HEX14[i].dim, dim ); 01390 CPPUNIT_ASSERT_EQUAL( HEX14[i].num, num ); 01391 } 01392 // HEX-9 01393 for( unsigned i = 0; i < 1; ++i ) 01394 { 01395 TopologyInfo::side_from_higher_order( HEXAHEDRON, 9, HEX9[i].idx, dim, num, err ); 01396 CPPUNIT_ASSERT( !err ); 01397 CPPUNIT_ASSERT_EQUAL( HEX9[i].dim, dim ); 01398 CPPUNIT_ASSERT_EQUAL( HEX9[i].num, num ); 01399 } 01400 } 01401 01402 void TopologyInfoTest::find_edge() 01403 { 01404 MsqPrintError err( std::cerr ); 01405 bool reversed; 01406 01407 EntityTopology types[] = { TRIANGLE, QUADRILATERAL, TETRAHEDRON, HEXAHEDRON, PRISM, PYRAMID }; 01408 const unsigned num_types = sizeof( types ) / sizeof( types[0] ); 01409 unsigned idx; 01410 for( unsigned t = 0; t < num_types; ++t ) 01411 { 01412 const EntityTopology type = types[t]; 01413 01414 for( unsigned e = 0; e < TopologyInfo::edges( type ); ++e ) 01415 { 01416 01417 const unsigned* const v = TopologyInfo::edge_vertices( type, e, err ); 01418 CPPUNIT_ASSERT( !err ); 01419 idx = TopologyInfo::find_edge( type, v, reversed, err ); 01420 CPPUNIT_ASSERT( !err ); 01421 CPPUNIT_ASSERT_EQUAL( e, idx ); 01422 CPPUNIT_ASSERT( !reversed ); 01423 01424 const unsigned switched[2] = { v[1], v[0] }; 01425 idx = TopologyInfo::find_edge( type, switched, reversed, err ); 01426 CPPUNIT_ASSERT( !err ); 01427 CPPUNIT_ASSERT_EQUAL( e, idx ); 01428 CPPUNIT_ASSERT( reversed ); 01429 } 01430 } 01431 } 01432 01433 static void shift( const unsigned* in, unsigned* out, unsigned size, unsigned offset ) 01434 { 01435 for( unsigned i = 0; i < size; ++i ) 01436 out[i] = in[( i + offset ) % size]; 01437 } 01438 01439 static void reverse( const unsigned* in, unsigned* out, unsigned size, unsigned offset ) 01440 { 01441 for( unsigned i = 0; i < size; ++i ) 01442 out[i] = in[( offset + size - i - 1 ) % size]; 01443 } 01444 01445 void TopologyInfoTest::find_face() 01446 { 01447 MsqPrintError err( std::cerr ); 01448 bool reversed; 01449 unsigned switched[4], idx; 01450 01451 EntityTopology types[] = { TETRAHEDRON, HEXAHEDRON, PRISM, PYRAMID }; 01452 const unsigned num_types = sizeof( types ) / sizeof( types[0] ); 01453 for( unsigned t = 0; t < num_types; ++t ) 01454 { 01455 const EntityTopology type = types[t]; 01456 01457 for( unsigned f = 0; f < TopologyInfo::faces( type ); ++f ) 01458 { 01459 01460 unsigned n; 01461 const unsigned* const v = TopologyInfo::face_vertices( type, f, n, err ); 01462 CPPUNIT_ASSERT( !err ); 01463 CPPUNIT_ASSERT( n == 3 || n == 4 ); 01464 01465 idx = TopologyInfo::find_face( type, v, n, reversed, err ); 01466 CPPUNIT_ASSERT( !err ); 01467 CPPUNIT_ASSERT_EQUAL( f, idx ); 01468 CPPUNIT_ASSERT( !reversed ); 01469 01470 // advance by 1 and try again 01471 shift( v, switched, n, 1 ); 01472 idx = TopologyInfo::find_face( type, switched, n, reversed, err ); 01473 CPPUNIT_ASSERT( !err ); 01474 CPPUNIT_ASSERT_EQUAL( f, idx ); 01475 CPPUNIT_ASSERT( !reversed ); 01476 01477 // advance by 2 and try again 01478 shift( v, switched, n, 2 ); 01479 idx = TopologyInfo::find_face( type, switched, n, reversed, err ); 01480 CPPUNIT_ASSERT( !err ); 01481 CPPUNIT_ASSERT_EQUAL( f, idx ); 01482 CPPUNIT_ASSERT( !reversed ); 01483 01484 // advance by 3 and try again 01485 shift( v, switched, n, 3 ); 01486 idx = TopologyInfo::find_face( type, switched, n, reversed, err ); 01487 CPPUNIT_ASSERT( !err ); 01488 CPPUNIT_ASSERT_EQUAL( f, idx ); 01489 CPPUNIT_ASSERT( !reversed ); 01490 01491 // reverse and try again 01492 reverse( v, switched, n, 0 ); 01493 idx = TopologyInfo::find_face( type, switched, n, reversed, err ); 01494 CPPUNIT_ASSERT( !err ); 01495 CPPUNIT_ASSERT_EQUAL( f, idx ); 01496 CPPUNIT_ASSERT( reversed ); 01497 01498 // reverse, advance by 1 and try again 01499 reverse( v, switched, n, 1 ); 01500 idx = TopologyInfo::find_face( type, switched, n, reversed, err ); 01501 CPPUNIT_ASSERT( !err ); 01502 CPPUNIT_ASSERT_EQUAL( f, idx ); 01503 CPPUNIT_ASSERT( reversed ); 01504 01505 // reverse, advance by 2 and try again 01506 reverse( v, switched, n, 2 ); 01507 idx = TopologyInfo::find_face( type, switched, n, reversed, err ); 01508 CPPUNIT_ASSERT( !err ); 01509 CPPUNIT_ASSERT_EQUAL( f, idx ); 01510 CPPUNIT_ASSERT( reversed ); 01511 01512 // reverse, advance by 3 and try again 01513 reverse( v, switched, n, 3 ); 01514 idx = TopologyInfo::find_face( type, switched, n, reversed, err ); 01515 CPPUNIT_ASSERT( !err ); 01516 CPPUNIT_ASSERT_EQUAL( f, idx ); 01517 CPPUNIT_ASSERT( reversed ); 01518 } 01519 } 01520 } 01521 01522 void TopologyInfoTest::find_side() 01523 { 01524 MsqPrintError err( std::cerr ); 01525 bool reversed; 01526 unsigned i, dim, switched[4]; 01527 01528 EntityTopology types[] = { TRIANGLE, QUADRILATERAL, TETRAHEDRON, HEXAHEDRON, PRISM, PYRAMID }; 01529 const unsigned num_types = sizeof( types ) / sizeof( types[0] ); 01530 for( unsigned t = 0; t < num_types; ++t ) 01531 { 01532 const EntityTopology type = types[t]; 01533 01534 for( unsigned e = 0; e < TopologyInfo::edges( type ); ++e ) 01535 { 01536 01537 const unsigned* const v = TopologyInfo::edge_vertices( type, e, err ); 01538 CPPUNIT_ASSERT( !err ); 01539 TopologyInfo::find_side( type, v, 2, dim, i, reversed, err ); 01540 CPPUNIT_ASSERT( !err ); 01541 CPPUNIT_ASSERT_EQUAL( e, i ); 01542 CPPUNIT_ASSERT_EQUAL( 1u, dim ); 01543 CPPUNIT_ASSERT( !reversed ); 01544 01545 switched[0] = v[1]; 01546 switched[1] = v[0]; 01547 TopologyInfo::find_side( type, switched, 2, dim, i, reversed, err ); 01548 CPPUNIT_ASSERT( !err ); 01549 CPPUNIT_ASSERT_EQUAL( e, i ); 01550 CPPUNIT_ASSERT_EQUAL( 1u, dim ); 01551 CPPUNIT_ASSERT( reversed ); 01552 } 01553 } 01554 01555 for( unsigned t = 2; t < num_types; ++t ) 01556 { 01557 const EntityTopology type = types[t]; 01558 01559 for( unsigned f = 0; f < TopologyInfo::faces( type ); ++f ) 01560 { 01561 01562 unsigned n; 01563 const unsigned* const v = TopologyInfo::face_vertices( type, f, n, err ); 01564 CPPUNIT_ASSERT( !err ); 01565 CPPUNIT_ASSERT( n == 3 || n == 4 ); 01566 01567 TopologyInfo::find_side( type, v, n, dim, i, reversed, err ); 01568 CPPUNIT_ASSERT( !err ); 01569 CPPUNIT_ASSERT_EQUAL( f, i ); 01570 CPPUNIT_ASSERT_EQUAL( 2u, dim ); 01571 CPPUNIT_ASSERT( !reversed ); 01572 01573 // reverse and try again 01574 reverse( v, switched, n, 0 ); 01575 TopologyInfo::find_side( type, switched, n, dim, i, reversed, err ); 01576 CPPUNIT_ASSERT( !err ); 01577 CPPUNIT_ASSERT_EQUAL( f, i ); 01578 CPPUNIT_ASSERT_EQUAL( 2u, dim ); 01579 CPPUNIT_ASSERT( reversed ); 01580 } 01581 } 01582 } 01583 01584 void TopologyInfoTest::compare_sides() 01585 { 01586 // define two hexes sharing a face: 01587 // 6-------7-------8 01588 // /| /| /| 01589 // 0-------1-------2 | 01590 // | | | | | | 01591 // | 9-----|-10----|-11 01592 // |/ |/ |/ 01593 // 3-------4-------5 01594 01595 const size_t hex1[] = { 3, 4, 10, 9, 0, 1, 7, 6 }; 01596 const size_t hex2[] = { 4, 5, 11, 10, 1, 2, 8, 7 }; 01597 // shared edges: { hex1_edge, hex2_edge } 01598 const unsigned edges[][2] = { { 1, 3 }, { 5, 4 }, { 6, 7 }, { 9, 11 } }; 01599 const unsigned num_edges = sizeof( edges ) / sizeof( edges[0] ); 01600 // shared faces: { hex1_face, hex2_face } 01601 const unsigned faces[][2] = { { 1, 3 } }; 01602 const unsigned num_faces = sizeof( faces ) / sizeof( faces[0] ); 01603 01604 MsqPrintError err( std::cerr ); 01605 01606 // try every possible edge combination 01607 for( unsigned e1 = 0; e1 < 12; ++e1 ) 01608 { 01609 unsigned match; 01610 for( match = 0; match < num_edges; ++match ) 01611 if( edges[match][0] == e1 ) break; 01612 01613 for( unsigned e2 = 0; e2 < 12; ++e2 ) 01614 { 01615 const bool expected = ( match < num_edges ) && ( edges[match][1] == e2 ); 01616 01617 const bool result = TopologyInfo::compare_sides( hex1, HEXAHEDRON, e1, hex2, HEXAHEDRON, e2, 1, err ); 01618 01619 CPPUNIT_ASSERT( !err ); 01620 CPPUNIT_ASSERT_EQUAL( expected, result ); 01621 } 01622 } 01623 01624 // try every possible face combination 01625 for( unsigned f1 = 0; f1 < 6; ++f1 ) 01626 { 01627 unsigned match; 01628 for( match = 0; match < num_faces; ++match ) 01629 if( faces[match][0] == f1 ) break; 01630 01631 for( unsigned f2 = 0; f2 < 6; ++f2 ) 01632 { 01633 const bool expected = ( match < num_faces ) && ( faces[match][1] == f2 ); 01634 01635 const bool result = TopologyInfo::compare_sides( hex1, HEXAHEDRON, f1, hex2, HEXAHEDRON, f2, 2, err ); 01636 01637 CPPUNIT_ASSERT( !err ); 01638 CPPUNIT_ASSERT_EQUAL( expected, result ); 01639 } 01640 } 01641 }