Changeset 7394
- Timestamp:
- Aug 20, 2009, 3:19:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga_parallel/test_distribute_mesh.py
r7393 r7394 31 31 32 32 33 class Test_D omain(unittest.TestCase):33 class Test_Distribute_Mesh(unittest.TestCase): 34 34 def setUp(self): 35 35 pass … … 459 459 # Temporarily build the mesh to find the neighbouring 460 460 # triangles and true boundary polygon 461 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh462 463 mesh = Mesh(nodes, triangles)464 boundary_polygon = mesh.get_boundary_polygon()465 466 467 # Subdivide into non-overlapping partitions468 469 submeshf = submesh_full(nodes, triangles, edges, \470 triangles_per_proc)471 472 #print submeshf473 461 474 462 true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'}, {(5, 1): 'left', (10, 1): 'top', (7, 1): 'left'}, {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}], … … 485 473 [ 5. , 0.5 , 1. ], 486 474 [ 8. , 1. , 1. ], 487 [ 12. , 0.75, 0.75]])], 'full_nodes': [num.array([[ 3. , 0.5 , 0. ], 475 [ 12. , 0.75, 0.75]])], 476 'full_nodes': [num.array([[ 3. , 0.5 , 0. ], 488 477 [ 4. , 0.5 , 0.5 ], 489 478 [ 5. , 0.5 , 1. ], … … 503 492 [ 7. , 1. , 0.5 ], 504 493 [ 9. , 0.25, 0.25], 505 [ 11. , 0.75, 0.25]])], 'ghost_triangles': [num.array([[ 5, 0, 9, 1], 494 [ 11. , 0.75, 0.25]])], 495 'ghost_triangles': [num.array([[ 5, 0, 9, 1], 506 496 [ 6, 1, 9, 4], 507 497 [ 8, 4, 10, 1], … … 522 512 [ 3, 8, 12, 7], 523 513 [ 5, 0, 9, 1], 524 [ 6, 1, 9, 4]])], 'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', (14, 1): 'ghost', (11, 1): 'ghost', (10, 1): 'ghost', (5, 1): 'ghost', (10, 2): 'ghost'}, {(12, 2): 'ghost', (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost', (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, {(3, 2): 'ghost', (6, 1): 'ghost', (3, 1): 'ghost', (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}], 'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]], [[0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5]], [[3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]], 'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}], 'ghost_commun': [num.array([[ 5, 1], 514 [ 6, 1, 9, 4]])], 515 'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', (14, 1): 'ghost', (11, 1): 'ghost', (10, 1): 'ghost', (5, 1): 'ghost', (10, 2): 'ghost'}, {(12, 2): 'ghost', (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost', (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, {(3, 2): 'ghost', (6, 1): 'ghost', (3, 1): 'ghost', (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}], 516 'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]], [[0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5]], [[3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]], 517 'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}], 518 'ghost_commun': [num.array([[ 5, 1], 525 519 [ 6, 1], 526 520 [ 8, 1], … … 543 537 [6, 1]])]} 544 538 539 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh 540 541 mesh = Mesh(nodes, triangles) 542 boundary_polygon = mesh.get_boundary_polygon() 543 544 545 # Subdivide into non-overlapping partitions 546 547 submesh = submesh_full(nodes, triangles, edges, \ 548 triangles_per_proc) 549 550 #print submesh 545 551 546 552 547 553 for i in range(3): 548 assert num.allclose(true_submesh['full_triangles'][i],submesh f['full_triangles'][i])549 assert num.allclose(true_submesh['full_nodes'][i],submesh f['full_nodes'][i])550 assert true_submesh['full_boundary'] == submesh f['full_boundary']554 assert num.allclose(true_submesh['full_triangles'][i],submesh['full_triangles'][i]) 555 assert num.allclose(true_submesh['full_nodes'][i],submesh['full_nodes'][i]) 556 assert true_submesh['full_boundary'] == submesh['full_boundary'] 551 557 552 558 # Add any extra ghost boundary layer information 553 559 554 submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc) 555 556 560 submesh = submesh_ghost(submesh, mesh, triangles_per_proc) 561 562 for i in range(3): 563 assert num.allclose(true_submesh['ghost_triangles'][i],submesh['ghost_triangles'][i]) 564 assert num.allclose(true_submesh['ghost_nodes'][i],submesh['ghost_nodes'][i]) 565 assert true_submesh['full_commun'] == submesh['full_commun'] 566 assert true_submesh['ghost_commun'] == submesh['ghost_commun'] 557 567 558 568 # Order the quantities information to be the same as the triangle … … 569 579 #-------------------------------------------------------- 570 580 581 """ 571 582 assert num.allclose(submesh['full_nodes'][0],[[3.0, 0.5, 0.0], [4.0, 0.5, 0.5], [5.0, 0.5, 1.0], [7.0, 1.0, 0.5], [8.0, 1.0, 1.0], [9.0, 0.25, 0.25], [12.0, 0.75, 0.75]]) 572 583 assert num.allclose(submesh['full_nodes'][1],[[0.0, 0.0, 0.0], [1.0, 0.0, 0.5], [2.0, 0.0, 1.0], [4.0, 0.5, 0.5], [5.0, 0.5, 1.0], [9.0, 0.25, 0.25], [10.0, 0.25, 0.75]]) 573 584 assert num.allclose(submesh['full_nodes'][2],[[0.0, 0.0, 0.0], [3.0, 0.5, 0.0], [4.0, 0.5, 0.5], [6.0, 1.0, 0.0], [7.0, 1.0, 0.5], [9.0, 0.25, 0.25], [11.0, 0.75, 0.25]]) 574 575 585 """ 586 """ 576 587 assert num.allclose(submesh['ghost_nodes'][0],[[0.0, 0.0, 0.0], [1.0, 0.0, 0.5], [2.0, 0.0, 1.0], [6.0, 1.0, 0.0], [10.0, 0.25, 0.75], [11.0, 0.75, 0.25]]) 577 588 assert num.allclose(submesh['ghost_nodes'][1],[[3.0, 0.5, 0.0], [7.0, 1.0, 0.5], [8.0, 1.0, 1.0], [11.0, 0.75, 0.25], [12.0, 0.75, 0.75]]) 578 589 assert num.allclose(submesh['ghost_nodes'][2],[[1.0, 0.0, 0.5], [5.0, 0.5, 1.0], [8.0, 1.0, 1.0], [12.0, 0.75, 0.75]]) 579 580 581 590 """ 591 592 """ 582 593 true_full_triangles = [num.array([[ 4, 9, 3], 583 594 [ 4, 12, 5], … … 601 612 assert num.allclose(submesh['full_triangles'][1],true_full_triangles[1]) 602 613 assert num.allclose(submesh['full_triangles'][2],true_full_triangles[2]) 603 614 """ 615 """ 604 616 true_ghost_triangles = [num.array([[ 5, 0, 9, 1], 605 617 [ 6, 1, 9, 4], … … 625 637 [ 6, 1, 9, 4]])] 626 638 627 628 639 """ 640 """ 629 641 assert num.allclose(submesh['ghost_triangles'][0],true_ghost_triangles[0]) 630 642 assert num.allclose(submesh['ghost_triangles'][1],true_ghost_triangles[1]) … … 663 675 assert num.allclose(submesh['ghost_commun'][2],true_ghost_commun[2]) 664 676 665 677 """ 666 678 667 679 #------------------------------------------------------------- 668 680 669 681 if __name__ == "__main__": 670 suite = unittest.makeSuite(Test_D omain,'test')682 suite = unittest.makeSuite(Test_Distribute_Mesh,'test') 671 683 runner = unittest.TextTestRunner() 672 684 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.