Changeset 7391


Ignore:
Timestamp:
Aug 20, 2009, 11:53:27 AM (14 years ago)
Author:
steve
Message:
 
File:
1 edited

Legend:

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

    r7388 r7391  
    1313from anuga_parallel.pmesh_divide import pmesh_divide_metis
    1414from anuga_parallel.build_submesh import build_submesh
     15from anuga_parallel.build_submesh import submesh_full, submesh_ghost, submesh_quantities
    1516from anuga_parallel.build_commun import extract_hostmesh, rec_submesh, send_submesh
    1617
    17 import numpy as num
     18#import numpy as num
     19import Numeric as num
    1820
    1921def topography(x,y):
     
    366368
    367369
    368         boundary = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
     370        edges = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
    369371
    370372        triangles_per_proc = [5, 6, 5]
     
    453455        # Test build_submesh
    454456        #----------------------------------------------------------------------------------
    455         submesh = build_submesh(nodes, triangles, boundary, quantities, triangles_per_proc)
    456 
     457        #submesh = build_submesh(nodes, triangles, edges, quantities, triangles_per_proc)
     458
     459        # Temporarily build the mesh to find the neighbouring
     460        # 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
     473
     474        true_submeshf = {'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_nodes': [num.array([[  3.  ,   0.5 ,   0.  ],
     475       [  4.  ,   0.5 ,   0.5 ],
     476       [  5.  ,   0.5 ,   1.  ],
     477       [  7.  ,   1.  ,   0.5 ],
     478       [  8.  ,   1.  ,   1.  ],
     479       [  9.  ,   0.25,   0.25],
     480       [ 12.  ,   0.75,   0.75]]), num.array([[  0.  ,   0.  ,   0.  ],
     481       [  1.  ,   0.  ,   0.5 ],
     482       [  2.  ,   0.  ,   1.  ],
     483       [  4.  ,   0.5 ,   0.5 ],
     484       [  5.  ,   0.5 ,   1.  ],
     485       [  9.  ,   0.25,   0.25],
     486       [ 10.  ,   0.25,   0.75]]), num.array([[  0.  ,   0.  ,   0.  ],
     487       [  3.  ,   0.5 ,   0.  ],
     488       [  4.  ,   0.5 ,   0.5 ],
     489       [  6.  ,   1.  ,   0.  ],
     490       [  7.  ,   1.  ,   0.5 ],
     491       [  9.  ,   0.25,   0.25],
     492       [ 11.  ,   0.75,   0.25]])], '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'}]}
     493
     494
     495
     496        for key, item in submeshf.iteritems():
     497            assert submeshf[key] == true_submeshf[key]
     498           
     499        # Add any extra ghost boundary layer information
     500
     501        submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc)
     502
     503        # Order the quantities information to be the same as the triangle
     504        # information
     505
     506        submesh = submesh_quantities(submeshg, quantities, \
     507                                 triangles_per_proc)
     508
     509        submesh["boundary_polygon"] = boundary_polygon
     510
     511
     512        #--------------------------------------------------------
     513        # Results we expect from build_submesh
     514        #--------------------------------------------------------
    457515
    458516        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]])
Note: See TracChangeset for help on using the changeset viewer.