Changeset 8553
- Timestamp:
- Sep 4, 2012, 4:26:13 PM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga_parallel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
r8550 r8553 24 24 25 25 import numpy as num 26 import numpy.lib.arraysetops as numset 26 27 27 28 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh … … 498 499 ######################################################### 499 500 500 def ghost_layer (submesh, mesh, p, tupper, tlower, parameters = None):501 def ghost_layer_old(submesh, mesh, p, tupper, tlower, parameters = None): 501 502 502 503 ncoord = mesh.number_of_nodes … … 590 591 591 592 return subnodes, subtriangles, layer_width 593 594 595 596 def ghost_layer(submesh, mesh, p, tupper, tlower, parameters = None): 597 598 ncoord = mesh.number_of_nodes 599 ntriangles = mesh.number_of_triangles 600 601 if parameters is None: 602 layer_width = 2 603 else: 604 layer_width = parameters['ghost_layer_width'] 605 606 607 full_ids = num.arange(tlower, tupper) 608 609 n0 = mesh.neighbours[full_ids, :] 610 n0 = num.unique(n0.flat) 611 n0 = num.extract(n0>=0,n0) 612 n0 = num.extract(num.logical_or(n0<tlower, tupper<= n0), n0) 613 614 layer_cells = {} 615 layer_cells[0] = n0 616 617 618 # Find the subsequent layers of ghost triangles 619 for i in range(layer_width-1): 620 621 # use previous layer as a start 622 n0 = mesh.neighbours[n0, :] 623 n0 = num.unique(n0.flat) 624 n0 = num.extract(n0>=0,n0) 625 n0 = num.extract(num.logical_or(n0<tlower, tupper<= n0), n0) 626 627 for j in xrange(i+1): 628 n0 = numset.setdiff1d(n0,layer_cells[j]) 629 630 layer_cells[i+1] = n0 631 632 633 # Build the triangle list and make note of the vertices 634 new_trianglemap = layer_cells[0] 635 for i in range(layer_width-1): 636 new_trianglemap = numset.union1d(new_trianglemap,layer_cells[i+1]) 637 638 new_subtriangles = num.concatenate((num.reshape(new_trianglemap, (-1,1)), mesh.triangles[new_trianglemap]), 1) 639 640 641 642 643 fullnodes = submesh["full_nodes"][p] 644 full_nodes_ids = num.array(fullnodes[:,0],num.int) 645 646 new_nodes = num.unique(mesh.triangles[new_trianglemap].flat) 647 new_nodes = numset.setdiff1d(new_nodes,full_nodes_ids) 648 649 new_subnodes = num.concatenate((num.reshape(new_nodes, (-1,1)), mesh.nodes[new_nodes]), 1) 650 651 # Clean up before exiting 652 653 del (new_nodes) 654 del (layer_cells) 655 del (n0) 656 del (new_trianglemap) 657 658 # Return the triangles and vertices sitting on the boundary layer 659 660 return new_subnodes, new_subtriangles, layer_width 592 661 593 662 ######################################################### … … 925 994 ######################################################### 926 995 927 def build_submesh( mesh, quantities,996 def build_submesh(nodes, triangles, boundary, quantities, 928 997 triangles_per_proc, parameters = None): 929 998 930 999 # Temporarily build the mesh to find the neighbouring 931 # triangles and true boundary polygon 932 933 #mesh = Mesh(nodes, triangles, boundary)1000 # triangles and true boundary polygon\ 1001 1002 mesh = Mesh(nodes, triangles, boundary) 934 1003 boundary_polygon = mesh.get_boundary_polygon() 935 1004 -
trunk/anuga_core/source/anuga_parallel/parallel_api.py
r8550 r8553 266 266 # sp2_map (maps parallel domain triangles to domain triangles) 267 267 268 mesh = Mesh(new_nodes, new_triangles, new_boundary) 268 269 269 270 270 # Build the mesh that should be assigned to each processor, 271 271 # this includes ghost nodes and the communication pattern 272 272 if verbose: print 'Build submeshes' 273 submesh = build_submesh( mesh, quantities, triangles_per_proc, parameters)273 submesh = build_submesh(new_nodes, new_triangles, new_boundary, quantities, triangles_per_proc, parameters) 274 274 275 275 if verbose: -
trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py
r8550 r8553 42 42 width = 2.0 43 43 dx = dy = 0.005 44 dx = dy = 0.0025 44 dx = dy = 0.005 45 #dx = dy = 0.5 45 46 domain = rectangular_cross_domain(int(length/dx), int(width/dy), 46 47 len1=length, len2=width) … … 64 65 65 66 # setup parameters to test using different ghost_layer_widths 66 parameters = dict(ghost_layer_width = 2)67 parameters = dict(ghost_layer_width = 4) 67 68 domain = distribute(domain,verbose=verbose, parameters=parameters) 68 69
Note: See TracChangeset
for help on using the changeset viewer.