Changeset 7394


Ignore:
Timestamp:
Aug 20, 2009, 3:19:24 PM (11 years ago)
Author:
steve
Message:

Continue debug of build_submesh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga_parallel/test_distribute_mesh.py

    r7393 r7394  
    3131
    3232
    33 class Test_Domain(unittest.TestCase):
     33class Test_Distribute_Mesh(unittest.TestCase):
    3434    def setUp(self):
    3535        pass
     
    459459        # Temporarily build the mesh to find the neighbouring
    460460        # triangles and true boundary polygon
    461         from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
    462        
    463         mesh = Mesh(nodes, triangles)
    464         boundary_polygon = mesh.get_boundary_polygon()
    465    
    466        
    467         # Subdivide into non-overlapping partitions
    468 
    469         submeshf = submesh_full(nodes, triangles, edges, \
    470                             triangles_per_proc)
    471 
    472         #print submeshf
    473461
    474462        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'}],
     
    485473       [  5.  ,   0.5 ,   1.  ],
    486474       [  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.  ],
    488477       [  4.  ,   0.5 ,   0.5 ],
    489478       [  5.  ,   0.5 ,   1.  ],
     
    503492       [  7.  ,   1.  ,   0.5 ],
    504493       [  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],
    506496       [ 6,  1,  9,  4],
    507497       [ 8,  4, 10,  1],
     
    522512       [ 3,  8, 12,  7],
    523513       [ 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],
    525519       [ 6,  1],
    526520       [ 8,  1],
     
    543537       [6, 1]])]}
    544538
     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
    545551
    546552
    547553        for i in range(3):
    548             assert num.allclose(true_submesh['full_triangles'][i],submeshf['full_triangles'][i])
    549             assert num.allclose(true_submesh['full_nodes'][i],submeshf['full_nodes'][i])
    550         assert true_submesh['full_boundary'] == submeshf['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']
    551557
    552558        # Add any extra ghost boundary layer information
    553559
    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']
    557567       
    558568        # Order the quantities information to be the same as the triangle
     
    569579        #--------------------------------------------------------
    570580
     581        """
    571582        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]])
    572583        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]])
    573584        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        """
    576587        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]])
    577588        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]])
    578589        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        """
    582593        true_full_triangles = [num.array([[ 4,  9,  3],
    583594                                          [ 4, 12,  5],
     
    601612        assert num.allclose(submesh['full_triangles'][1],true_full_triangles[1])
    602613        assert num.allclose(submesh['full_triangles'][2],true_full_triangles[2])
    603 
     614        """
     615        """
    604616        true_ghost_triangles = [num.array([[ 5,  0,  9,  1],
    605617                                           [ 6,  1,  9,  4],
     
    625637                                           [ 6,  1,  9,  4]])]
    626638
    627 
    628 
     639                                           """
     640        """
    629641        assert num.allclose(submesh['ghost_triangles'][0],true_ghost_triangles[0])
    630642        assert num.allclose(submesh['ghost_triangles'][1],true_ghost_triangles[1])
     
    663675        assert num.allclose(submesh['ghost_commun'][2],true_ghost_commun[2])
    664676
    665 
     677        """
    666678 
    667679#-------------------------------------------------------------
    668680
    669681if __name__ == "__main__":
    670     suite = unittest.makeSuite(Test_Domain,'test')
     682    suite = unittest.makeSuite(Test_Distribute_Mesh,'test')
    671683    runner = unittest.TextTestRunner()
    672684    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.