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