Changeset 8538
- Timestamp:
- Aug 28, 2012, 4:06:09 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/documentation/user_manual/demos/cairns/runcairns.py
r8427 r8538 69 69 tide = 0.0 70 70 domain.set_quantity('stage', tide) 71 domain.set_quantity('friction', 0.0) 71 domain.set_quantity('friction', 0.0) 72 73 72 74 domain.set_quantity('elevation', 73 75 filename=project.name_stem + '.pts', -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r8486 r8538 35 35 Evaluate boundary condition at edges of a domain in a list 36 36 defined by segment_edges 37 38 segment_edges are a sublist of the list of edges definded by the 39 arrays domain.boundary_cells and domain.boundary_edges 37 40 38 41 Go through list of boundary objects and update boundary values -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8505 r8538 53 53 numproc=1, 54 54 number_of_full_nodes=None, 55 number_of_full_triangles=None): 55 number_of_full_triangles=None, 56 ghost_layer_width=2): 56 57 57 58 """Instantiate generic computational Domain. … … 204 205 self.processor = processor 205 206 self.numproc = numproc 207 self.ghost_layer_width = ghost_layer_width 206 208 207 209 # Setup Communication Buffers … … 1532 1534 #self.update_special_conditions() 1533 1535 1534 # Update ghosts1535 self.update_ghosts()1536 1537 1536 # Update time 1538 1537 self.set_time(self.get_time() + self.timestep) 1538 1539 # Update ghosts 1540 if self.ghost_layer_width < 4: 1541 self.update_ghosts() 1539 1542 1540 1543 # Update vertex and edge values … … 1605 1608 #self.update_special_conditions() 1606 1609 1610 # Update time 1611 self.set_time(self.time + self.timestep) 1612 1607 1613 # Update ghosts 1608 1614 self.update_ghosts() 1609 1610 # Update time1611 self.set_time(self.time + self.timestep)1612 1615 1613 1616 # Update vertex and edge values … … 1641 1644 self.saxpy_conserved_quantities(0.25, 0.75) 1642 1645 1643 1644 1646 # Update special conditions 1645 1647 #self.update_special_conditions() 1646 1648 1649 # Set substep time 1650 self.set_time(initial_time + self.timestep*0.5) 1651 1647 1652 # Update ghosts 1648 1653 self.update_ghosts() 1649 1650 # Set substep time1651 self.set_time(initial_time + self.timestep*0.5)1652 1654 1653 1655 # Update vertex and edge values -
trunk/anuga_core/source/anuga/config.py
r8418 r8538 95 95 96 96 # Option to setup compute_fluxes_method 97 # Currently "original' and 'wb_1' to 'wb_3' 97 # Currently "original' and 'wb_1' to 'wb_3' and 'tsunami' 98 98 compute_fluxes_method = 'wb_2' 99 100 # Option to setup distribute_to_vertices_and_edges_method 101 # Currently "original' and 'tsunami' 102 distribute_to_vertices_and_edges_method = 'original' 99 103 100 104 ################################################################################ -
trunk/anuga_core/source/anuga/shallow_water/boundaries.py
r8487 r8538 89 89 90 90 def evaluate_segment(self, domain, segment_edges): 91 """Apply reflective BC on the boundary edges defined by 92 segment_edges 93 """ 91 94 92 95 if segment_edges is None: … … 120 123 n2 = Normals[vol_ids,2*edge_ids+1] 121 124 122 # Transfer these quantities 125 # Transfer these quantities to the boundary array 123 126 Stage.boundary_values[ids] = Stage.edge_values[vol_ids,edge_ids] 124 127 Elev.boundary_values[ids] = Elev.edge_values[vol_ids,edge_ids] … … 128 131 q1 = Xmom.edge_values[vol_ids,edge_ids] 129 132 q2 = Ymom.edge_values[vol_ids,edge_ids] 130 131 # Rotate132 #q[1] = n1 * q1 - n2*q2;133 #q[2] = n2 * q1 + n1*q2;134 133 135 134 r1 = -q1*n1 - q2*n2 -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8500 r8538 109 109 numproc=1, 110 110 number_of_full_nodes=None, 111 number_of_full_triangles=None): 111 number_of_full_triangles=None, 112 ghost_layer_width=2): 112 113 """ 113 114 Instantiate a shallow water domain. … … 163 164 numproc, 164 165 number_of_full_nodes=number_of_full_nodes, 165 number_of_full_triangles=number_of_full_triangles) 166 number_of_full_triangles=number_of_full_triangles, 167 ghost_layer_width=ghost_layer_width) 166 168 167 169 self.set_defaults() … … 226 228 from anuga.config import use_centroid_velocities 227 229 from anuga.config import compute_fluxes_method 230 from anuga.config import distribute_to_vertices_and_edges_method 228 231 from anuga.config import sloped_mannings_function 229 232 from anuga.config import flow_algorithm … … 255 258 256 259 def get_algorithm_parameters(self): 257 """Get the standard parameter that are curently set (as a dictionary)260 """Get the standard parameter that are currently set (as a dictionary) 258 261 """ 259 262 … … 271 274 parameters['use_sloped_mannings'] = self.use_sloped_mannings 272 275 parameters['compute_fluxes_method'] = self.get_compute_fluxes_method() 276 parameters['distribute_to_vertices_and_edges_method'] = \ 277 self.get_distribute_to_vertices_and_edges_method() 273 278 parameters['flow_algorithm'] = self.get_flow_algorithm() 274 279 parameters['CFL'] = self.get_CFL() … … 352 357 wb_2 353 358 wb_3 354 """ 355 compute_fluxes_methods = ['original', 'wb_1', 'wb_2', 'wb_3'] 359 tsunami 360 """ 361 compute_fluxes_methods = ['original', 'wb_1', 'wb_2', 'wb_3', 'tsunami'] 356 362 357 363 if flag in compute_fluxes_methods: … … 375 381 376 382 383 384 def set_distribute_to_vertices_and_edges_method(self, flag='original'): 385 """Set method for computing fluxes. 386 387 Currently 388 original 389 tsunami 390 """ 391 distribute_to_vertices_and_edges_methods = ['original', 'tsunami'] 392 393 if flag in distribute_to_vertices_and_edges_methods: 394 self.distribute_to_vertices_and_edges_method = flag 395 else: 396 msg = 'Unknown distribute_to_vertices_and_edges_method. \nPossible choices are:\n'+ \ 397 ', '.join(distribute_to_vertices_and_edges_methods)+'.' 398 raise Exception(msg) 399 400 401 402 403 404 def get_distribute_to_vertices_and_edges_method(self): 405 """Get method for distribute_to_vertices_and_edges. 406 407 See set_distribute_to_vertices_and_edges_method for possible choices. 408 """ 409 410 return self.distribute_to_vertices_and_edges_method 411 412 413 377 414 def set_flow_algorithm(self, flag=1.5): 378 415 """Set combination of slope limiting and time stepping … … 383 420 2 384 421 2.5 422 tsunami 385 423 """ 386 424 … … 390 428 flag = str(float(str(flag))).replace(".","_") 391 429 392 flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_5' ]430 flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_5', 'tsunami'] 393 431 394 432 if flag in flow_algorithms: … … 404 442 self.set_default_order(1) 405 443 self.set_CFL(1.0) 444 445 406 446 407 447 if self.flow_algorithm == '1_5': … … 416 456 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 417 457 self.set_CFL(1.0) 458 self.set_compute_fluxes_method('wb_2') 459 self.set_extrapolate_velocity() 460 418 461 419 462 … … 429 472 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 430 473 self.set_CFL(0.75) 474 self.set_compute_fluxes_method('wb_2') 475 self.set_extrapolate_velocity() 431 476 432 477 … … 442 487 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 443 488 self.set_CFL(1.0) 489 self.set_compute_fluxes_method('wb_2') 490 self.set_extrapolate_velocity() 491 492 493 if self.flow_algorithm == 'tsunami': 494 self.set_timestepping_method(2) 495 self.set_default_order(2) 496 beta_w = 1.9 497 beta_w_dry = 0.2 498 beta_uh = 1.9 499 beta_uh_dry = 0.2 500 beta_vh = 1.9 501 beta_vh_dry = 0.2 502 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 503 self.set_CFL(1.0) 504 self.set_compute_fluxes_method('wb_2') 505 self.set_extrapolate_velocity() 506 self.set_distribute_to_vertices_and_edges_method('tsunami') 507 508 444 509 445 510 if self.flow_algorithm == '2_5': … … 454 519 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 455 520 self.set_CFL(1.0) 456 521 self.set_compute_fluxes_method('wb_2') 522 self.set_extrapolate_velocity() 457 523 458 524 … … 469 535 def set_gravity_method(self): 470 536 """Gravity method is determined by the compute_fluxes_method 537 This is now not used, as gravity is combine in the compute_fluxes method 471 538 """ 472 539 … … 513 580 elif flag is False: 514 581 self.optimise_dry_cells = int(False) 515 516 582 517 583 -
trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
r8537 r8538 266 266 ######################################################### 267 267 268 def submesh_full( nodes, triangles, boundary, triangles_per_proc):268 def submesh_full(mesh, triangles_per_proc): 269 269 270 270 # Initialise 271 272 273 nodes = mesh.nodes 274 triangles = mesh.triangles 275 boundary = mesh.boundary 271 276 272 277 tlower = 0 … … 353 358 ######################################################### 354 359 355 def ghost_layer(submesh, mesh, p, tupper, tlower ):360 def ghost_layer(submesh, mesh, p, tupper, tlower, parameters = None): 356 361 357 362 ncoord = mesh.number_of_nodes 358 363 ntriangles = mesh.number_of_triangles 359 364 360 361 layer_width = config.ghost_layer_width 362 363 print layer_width 365 if parameters is None: 366 layer_width = 2 367 else: 368 layer_width = parameters['ghost_layer_width'] 369 364 370 365 371 trianglemap = num.zeros(ntriangles, 'i') … … 443 449 # Return the triangles and vertices sitting on the boundary layer 444 450 445 return subnodes, subtriangles 451 return subnodes, subtriangles, layer_width 446 452 447 453 ######################################################### … … 479 485 def ghost_bnd_layer(ghosttri, tlower, tupper, mesh, p): 480 486 487 488 boundary = mesh.boundary 489 481 490 ghost_list = [] 482 491 subboundary = {} 483 492 484 493 494 # FIXME SR: For larger layers need to pass through the correct 495 # boundary tag! 496 485 497 for t in ghosttri: 486 498 ghost_list.append(t[0]) … … 490 502 n = mesh.neighbours[t[0], 0] 491 503 if not is_in_processor(ghost_list, tlower, tupper, n): 492 subboundary[t[0], 0] = 'ghost' 504 if boundary.has_key( (t[0], 0) ): 505 subboundary[t[0], 0] = boundary[t[0],0] 506 else: 507 subboundary[t[0], 0] = 'ghost' 508 493 509 494 510 n = mesh.neighbours[t[0], 1] 495 511 if not is_in_processor(ghost_list, tlower, tupper, n): 496 subboundary[t[0], 1] = 'ghost' 512 if boundary.has_key( (t[0], 1) ): 513 subboundary[t[0], 1] = boundary[t[0],1] 514 else: 515 subboundary[t[0], 1] = 'ghost' 516 497 517 498 518 n = mesh.neighbours[t[0], 2] 499 519 if not is_in_processor(ghost_list, tlower, tupper, n): 500 subboundary[t[0], 2] = 'ghost' 520 if boundary.has_key( (t[0], 2) ): 521 subboundary[t[0], 2] = boundary[t[0],2] 522 else: 523 subboundary[t[0], 2] = 'ghost' 501 524 502 525 return subboundary … … 629 652 ######################################################### 630 653 631 def submesh_ghost(submesh, mesh, triangles_per_proc ):654 def submesh_ghost(submesh, mesh, triangles_per_proc, parameters = None): 632 655 633 656 nproc = len(triangles_per_proc) … … 637 660 ghost_commun = [] 638 661 ghost_bnd = [] 662 ghost_layer_width = [] 639 663 640 664 # Loop over the processors … … 648 672 # Build the ghost boundary layer 649 673 650 [subnodes, subtri] = \ 651 ghost_layer(submesh, mesh, p, tupper, tlower) 674 [subnodes, subtri, layer_width] = \ 675 ghost_layer(submesh, mesh, p, tupper, tlower, parameters) 676 ghost_layer_width.append(layer_width) 652 677 ghost_triangles.append(subtri) 653 678 ghost_nodes.append(subnodes) … … 671 696 672 697 # Record the ghost layer and communication pattern 673 698 submesh["ghost_layer_width"] = ghost_layer_width 674 699 submesh["ghost_nodes"] = ghost_nodes 675 700 submesh["ghost_triangles"] = ghost_triangles … … 760 785 ######################################################### 761 786 762 def build_submesh(nodes, triangles, edges, quantities,763 triangles_per_proc ):787 def build_submesh(nodes, triangles, boundary, quantities, 788 triangles_per_proc, parameters = None): 764 789 765 790 # Temporarily build the mesh to find the neighbouring 766 791 # triangles and true boundary polygon 767 792 768 mesh = Mesh(nodes, triangles )793 mesh = Mesh(nodes, triangles, boundary) 769 794 boundary_polygon = mesh.get_boundary_polygon() 770 795 … … 772 797 # Subdivide into non-overlapping partitions 773 798 774 submeshf = submesh_full(nodes, triangles, edges, \ 775 triangles_per_proc) 799 submeshf = submesh_full(mesh, triangles_per_proc) 776 800 777 801 # Add any extra ghost boundary layer information 778 802 779 submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc )803 submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc, parameters) 780 804 781 805 # Order the quantities information to be the same as the triangle … … 957 981 nodes = num.concatenate((submesh["full_nodes"], \ 958 982 submesh["ghost_nodes"])) 983 984 ghost_layer_width = submesh["ghost_layer_width"] 959 985 960 986 # Combine the full triangles and ghost triangles … … 1009 1035 1010 1036 return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \ 1011 full_send, tri_map, node_map 1037 full_send, tri_map, node_map, ghost_layer_width 1012 1038 1013 1039 … … 1051 1077 myid = pypar.rank() 1052 1078 1053 if verbose: print ' process %d sending submesh to process%d' %(myid, p)1079 if verbose: print 'P%d: Sending submesh to P%d' %(myid, p) 1054 1080 1055 1081 # build and send the tagmap for the boundary conditions … … 1078 1104 pypar.send(triangles_per_proc, p) 1079 1105 1106 # ghost layer width 1107 1108 pypar.send(submesh["ghost_layer_width"][p], p) 1109 1080 1110 # compress full_commun 1081 1111 … … 1185 1215 triangles_per_proc = pypar.receive(p) 1186 1216 1217 # ghost layer width 1218 1219 submesh_cell["ghost_layer_width"] = pypar.receive(p) 1220 1187 1221 # recieve information about the array sizes 1188 1222 … … 1303 1337 1304 1338 [GAnodes, GAtriangles, boundary, quantities, \ 1305 ghost_rec, full_send, tri_map, node_map ] = \1339 ghost_rec, full_send, tri_map, node_map, ghost_layer_width] = \ 1306 1340 build_local_mesh(submesh_cell, lower_t, upper_t, \ 1307 1341 numproc) … … 1309 1343 return GAnodes, GAtriangles, boundary, quantities,\ 1310 1344 ghost_rec, full_send,\ 1311 number_of_full_nodes, number_of_full_triangles, tri_map, node_map 1345 number_of_full_nodes, number_of_full_triangles, tri_map, node_map,\ 1346 ghost_layer_width 1312 1347 1313 1348 … … 1332 1367 1333 1368 submesh_cell = {} 1369 submesh_cell["ghost_layer_width"] = submesh["ghost_layer_width"][0] 1334 1370 submesh_cell["full_nodes"] = submesh["full_nodes"][0] 1335 1371 submesh_cell["ghost_nodes"] = submesh["ghost_nodes"][0] … … 1348 1384 numprocs = len(triangles_per_proc) 1349 1385 points, vertices, boundary, quantities, ghost_recv_dict, \ 1350 full_send_dict, tri_map, node_map = \1386 full_send_dict, tri_map, node_map, ghost_layer_width = \ 1351 1387 build_local_mesh(submesh_cell, 0, triangles_per_proc[0], numprocs) 1352 1388 1353 1389 1354 1390 return points, vertices, boundary, quantities, ghost_recv_dict, \ 1355 full_send_dict, tri_map, node_map 1391 full_send_dict, tri_map, node_map, ghost_layer_width 1356 1392 1357 1393 -
trunk/anuga_core/source/anuga_parallel/parallel_api.py
r8518 r8538 36 36 37 37 38 def distribute(domain, verbose=False, debug=False ):38 def distribute(domain, verbose=False, debug=False, parameters = None): 39 39 """ Distribute the domain to all processes 40 40 """ … … 112 112 ghost_recv_dict, full_send_dict,\ 113 113 number_of_full_nodes, number_of_full_triangles,\ 114 s2p_map, p2s_map, tri_map, node_map =\ 115 distribute_mesh(domain, verbose=verbose, debug=debug) 116 117 118 119 114 s2p_map, p2s_map, tri_map, node_map, ghost_layer_width =\ 115 distribute_mesh(domain, verbose=verbose, debug=debug, parameters=parameters) 120 116 121 117 # Extract l2g maps … … 146 142 ghost_recv_dict, full_send_dict,\ 147 143 number_of_full_nodes, number_of_full_triangles, \ 148 tri_map, node_map =\144 tri_map, node_map, ghost_layer_width =\ 149 145 rec_submesh(0, verbose) 150 146 … … 178 174 p2s_map = p2s_map, ## jj added this 179 175 tri_l2g = tri_l2g, ## SR added this 180 node_l2g = node_l2g) 176 node_l2g = node_l2g, 177 ghost_layer_width = ghost_layer_width) 181 178 182 179 #------------------------------------------------------------------------ … … 213 210 214 211 215 def distribute_mesh(domain, verbose=False, debug=False ):212 def distribute_mesh(domain, verbose=False, debug=False, parameters=None): 216 213 217 214 … … 236 233 if verbose: print 'Build submeshes' 237 234 submesh = build_submesh(nodes, triangles, boundary,\ 238 quantities, triangles_per_proc )235 quantities, triangles_per_proc, parameters) 239 236 240 237 if verbose: … … 257 254 # Build the local mesh for processor 0 258 255 points, vertices, boundary, quantities, \ 259 ghost_recv_dict, full_send_dict, tri_map, node_map =\256 ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\ 260 257 extract_hostmesh(submesh, triangles_per_proc) 261 258 … … 294 291 ghost_recv_dict, full_send_dict,\ 295 292 number_of_full_nodes, number_of_full_triangles, \ 296 s2p_map, p2s_map, tri_map, node_map 293 s2p_map, p2s_map, tri_map, node_map, ghost_layer_width 297 294 298 295 -
trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py
r8513 r8538 41 41 p2s_map=None, #jj added this 42 42 tri_l2g = None, ## SR added this 43 node_l2g = None): ## SR added this 43 node_l2g = None, #): ## SR added this 44 ghost_layer_width = 2): 44 45 45 46 Domain.__init__(self, … … 53 54 number_of_full_nodes=number_of_full_nodes, 54 55 number_of_full_triangles=number_of_full_triangles, 55 geo_reference=geo_reference) #jj added this 56 geo_reference=geo_reference, #) #jj added this 57 ghost_layer_width = ghost_layer_width) 56 58 57 58 59 59 60 self.parallel = True … … 89 90 self.node_l2g = node_l2g 90 91 92 self.ghost_counter = 0 93 91 94 92 95 def set_name(self, name): … … 122 125 receive the information for the ghost cells 123 126 """ 124 127 125 128 generic_comms.communicate_ghosts_asynchronous(self) 126 129 #generic_comms.communicate_ghosts_blocking(self) -
trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py
r8531 r8538 52 52 53 53 54 if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN' 55 domain = distribute(domain,verbose=verbose) 54 if myid == 0 and verbose: 55 print 'DISTRIBUTING DOMAIN' 56 sys.stdout.flush() 57 58 barrier() 56 59 57 print 'after parallel domain' 60 # setup parameters to test using different ghost_layer_widths 61 parameters = dict(ghost_layer_width = 4) 62 domain = distribute(domain,verbose=verbose, parameters=parameters) 63 64 if myid == 0 : print 'after parallel domain' 58 65 59 66 … … 69 76 70 77 71 print 'after set_boundary'78 if myid == 0 : print 'after set_boundary' 72 79 73 80 74 81 75 82 domain.check_integrity() 76 print 'after check_integrity' 83 84 if myid == 0 : print 'after check_integrity' 77 85 78 86 class Set_Stage: … … 96 104 97 105 98 print 'after set quantity'106 if myid == 0 : print 'after set quantity' 99 107 100 108 # Set Evolve parameters … … 142 150 143 151 144 152 domain.dump_triangulation(filename="rectangular_cross_%g.png"% numprocs) 145 153 146 154 finalize() -
trunk/anuga_core/source/anuga_parallel/test_distribute_mesh.py
r8011 r8538 47 47 48 48 49 true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 50 51 true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]] 49 true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], \ 50 [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], \ 51 [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 52 53 true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], \ 54 [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], 55 [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]] 52 56 53 57 … … 70 74 71 75 72 true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 73 74 true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]] 76 true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \ 77 [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 78 79 true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], \ 80 [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], \ 81 [7, 12, 4], [8, 12, 7], [5, 12, 8]] 75 82 76 83 … … 90 97 91 98 92 true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 93 94 true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]] 99 true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \ 100 [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 101 102 true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], \ 103 [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], \ 104 [7, 12, 4], [8, 12, 7], [5, 12, 8]] 95 105 96 106 … … 113 123 114 124 115 true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 116 117 118 true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [4, 10, 1], [3, 11, 4], [4, 11, 7], [4, 12, 5], [1, 10, 2], [5, 10, 4], [2, 10, 5], [6, 11, 3], [7, 11, 6], [7, 12, 4], [8, 12, 7], [5, 12, 8]] 125 true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \ 126 [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 127 128 129 true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [4, 10, 1], [3, 11, 4], \ 130 [4, 11, 7], [4, 12, 5], [1, 10, 2], [5, 10, 4], [2, 10, 5], [6, 11, 3], [7, 11, 6], \ 131 [7, 12, 4], [8, 12, 7], [5, 12, 8]] 119 132 120 133 … … 132 145 """ 133 146 134 nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 135 136 137 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]] 138 139 140 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'} 147 nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], \ 148 [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 149 150 151 triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], \ 152 [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], \ 153 [6, 11, 3], [7, 11, 6], [4, 11, 7]] 154 155 156 boundary = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', \ 157 (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'} 141 158 142 159 triangles_per_proc = [5, 6, 5] … … 222 239 223 240 224 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'}], 241 true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'},\ 242 {(5, 1): 'left', (10, 1): 'top', (7, 1): 'left'}, \ 243 {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}], 225 244 'ghost_nodes': [num.array([[ 0. , 0. , 0. ], 226 245 [ 1. , 0. , 0.5 ], … … 275 294 [ 5, 0, 9, 1], 276 295 [ 6, 1, 9, 4]])], 277 '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'}], 278 '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]]], 279 '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]}], 296 'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', (14, 1): 'ghost', \ 297 (11, 1): 'ghost', (10, 1): 'ghost', (5, 1): 'ghost', (10, 2): 'ghost'}, \ 298 {(12, 2): 'ghost', (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost',\ 299 (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, {(3, 2): 'ghost', \ 300 (6, 1): 'ghost', (3, 1): 'ghost', (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}], 301 'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]], \ 302 [[0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5]], \ 303 [[3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]], 304 'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, \ 305 {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, \ 306 {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}], 280 307 'ghost_commun': [num.array([[ 5, 1], 281 308 [ 6, 1], … … 462 489 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh 463 490 464 mesh = Mesh(nodes, triangles )491 mesh = Mesh(nodes, triangles, boundary) 465 492 boundary_polygon = mesh.get_boundary_polygon() 466 493 … … 468 495 # Subdivide into non-overlapping partitions 469 496 470 submesh = submesh_full(nodes, triangles, edges, \ 471 triangles_per_proc) 497 submesh = submesh_full(mesh, triangles_per_proc) 472 498 473 499 #print submesh … … 509 535 510 536 511 #print submesh 537 538 def test_build_submesh_3_layer_4(self): 539 """ 540 Test 3 Layer 4 way build_submesh with ghost_layer_width = 4 541 """ 542 543 nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \ 544 [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] 545 546 547 triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], \ 548 [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], \ 549 [6, 11, 3], [7, 11, 6], [4, 11, 7]] 550 551 552 boundary = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', \ 553 (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'} 554 555 """ 556 top 557 (10,1) (4,1) 558 2 ---------- 5 ---------- 8 559 | \ 10 / | \ 04 / | 560 | \ / | \ / | 561 (7,1) | 07 10 09 | 01 12 03 | (3,1) 562 | / \ | / \ | 563 | / 08 \ | / 02 \ | 564 left 1 ---------- 4 ---------- 7 right 565 | \ 06 / | \ 15 / | 566 | \ / | \ / | 567 (5,1) | 05 09 00 | 12 11 14 | (14,1) 568 | / \ | / \ | 569 | / 11 \ | / 13 \ | 570 0 ---------- 3 ---------- 6 571 (11,1) (13,1) 572 bottom 573 574 575 Processor 0 Full Triangles 00,01,02,03,04 576 Processor 1 Full Triangles 05,06,07,08,09,10 577 Processor 2 Full Triangles 11,12,13,14,15 578 """ 579 580 581 triangles_per_proc = [5, 6, 5] 582 583 584 585 586 true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'}, {(5, 1): 'left', \ 587 (10, 1): 'top', (7, 1): 'left'}, {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}], 588 'ghost_nodes': [num.array([[ 0. , 0. , 0. ], 589 [ 1. , 0. , 0.5 ], 590 [ 2. , 0. , 1. ], 591 [ 6. , 1. , 0. ], 592 [ 10. , 0.25, 0.75], 593 [ 11. , 0.75, 0.25]]), num.array([[ 3. , 0.5 , 0. ], 594 [ 7. , 1. , 0.5 ], 595 [ 8. , 1. , 1. ], 596 [ 11. , 0.75, 0.25], 597 [ 12. , 0.75, 0.75]]), num.array([[ 1. , 0. , 0.5 ], 598 [ 5. , 0.5 , 1. ], 599 [ 8. , 1. , 1. ], 600 [ 12. , 0.75, 0.75]])], 601 'full_nodes': [num.array([[ 3. , 0.5 , 0. ], 602 [ 4. , 0.5 , 0.5 ], 603 [ 5. , 0.5 , 1. ], 604 [ 7. , 1. , 0.5 ], 605 [ 8. , 1. , 1. ], 606 [ 9. , 0.25, 0.25], 607 [ 12. , 0.75, 0.75]]), num.array([[ 0. , 0. , 0. ], 608 [ 1. , 0. , 0.5 ], 609 [ 2. , 0. , 1. ], 610 [ 4. , 0.5 , 0.5 ], 611 [ 5. , 0.5 , 1. ], 612 [ 9. , 0.25, 0.25], 613 [ 10. , 0.25, 0.75]]), num.array([[ 0. , 0. , 0. ], 614 [ 3. , 0.5 , 0. ], 615 [ 4. , 0.5 , 0.5 ], 616 [ 6. , 1. , 0. ], 617 [ 7. , 1. , 0.5 ], 618 [ 9. , 0.25, 0.25], 619 [ 11. , 0.75, 0.25]])], 620 'ghost_triangles': [num.array([[ 5, 0, 9, 1], 621 [ 6, 1, 9, 4], 622 [ 8, 4, 10, 1], 623 [ 9, 5, 10, 4], 624 [10, 2, 10, 5], 625 [11, 3, 9, 0], 626 [12, 3, 11, 4], 627 [13, 6, 11, 3], 628 [14, 7, 11, 6], 629 [15, 4, 11, 7]]), num.array([[ 0, 4, 9, 3], 630 [ 1, 4, 12, 5], 631 [ 2, 7, 12, 4], 632 [ 4, 5, 12, 8], 633 [11, 3, 9, 0], 634 [12, 3, 11, 4]]), num.array([[ 0, 4, 9, 3], 635 [ 1, 4, 12, 5], 636 [ 2, 7, 12, 4], 637 [ 3, 8, 12, 7], 638 [ 5, 0, 9, 1], 639 [ 6, 1, 9, 4]])], 640 'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', \ 641 (14, 1): 'ghost', (11, 1): 'ghost', (10, 1): 'ghost', \ 642 (5, 1): 'ghost', (10, 2): 'ghost'}, {(12, 2): 'ghost', \ 643 (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost', \ 644 (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, \ 645 {(3, 2): 'ghost', (6, 1): 'ghost', (3, 1): 'ghost', \ 646 (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}], 647 'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], \ 648 [8, 12, 7], [5, 12, 8]], [[0, 9, 1], [1, 9, 4], [1, 10, 2], \ 649 [4, 10, 1], [5, 10, 4], [2, 10, 5]], [[3, 9, 0], [3, 11, 4], \ 650 [6, 11, 3], [7, 11, 6], [4, 11, 7]]], 651 'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, \ 652 {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, \ 653 {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}], 654 'ghost_commun': [num.array([[ 5, 1], 655 [ 6, 1], 656 [ 8, 1], 657 [ 9, 1], 658 [10, 1], 659 [11, 2], 660 [12, 2], 661 [13, 2], 662 [14, 2], 663 [15, 2]]), num.array([[ 0, 0], 664 [ 1, 0], 665 [ 2, 0], 666 [ 4, 0], 667 [11, 2], 668 [12, 2]]), num.array([[0, 0], 669 [1, 0], 670 [2, 0], 671 [3, 0], 672 [5, 1], 673 [6, 1]])], 'ghost_quan': {'stage': [num.array([[-0. , -0.125, -0. ], 674 [-0. , -0.125, -0.25 ], 675 [-0.25 , -0.125, -0. ], 676 [-0.25 , -0.125, -0.25 ], 677 [-0. , -0.125, -0.25 ], 678 [-0.25 , -0.125, -0. ], 679 [-0.25 , -0.375, -0.25 ], 680 [-0.5 , -0.375, -0.25 ], 681 [-0.5 , -0.375, -0.5 ], 682 [-0.25 , -0.375, -0.5 ]]), num.array([[-0.25 , -0.125, -0.25 ], 683 [-0.25 , -0.375, -0.25 ], 684 [-0.5 , -0.375, -0.25 ], 685 [-0.25 , -0.375, -0.5 ], 686 [-0.25 , -0.125, -0. ], 687 [-0.25 , -0.375, -0.25 ]]), num.array([[-0.25 , -0.125, -0.25 ], 688 [-0.25 , -0.375, -0.25 ], 689 [-0.5 , -0.375, -0.25 ], 690 [-0.5 , -0.375, -0.5 ], 691 [-0. , -0.125, -0. ], 692 [-0. , -0.125, -0.25 ]])], 'elevation': [num.array([[-0. , -0.125, -0. ], 693 [-0. , -0.125, -0.25 ], 694 [-0.25 , -0.125, -0. ], 695 [-0.25 , -0.125, -0.25 ], 696 [-0. , -0.125, -0.25 ], 697 [-0.25 , -0.125, -0. ], 698 [-0.25 , -0.375, -0.25 ], 699 [-0.5 , -0.375, -0.25 ], 700 [-0.5 , -0.375, -0.5 ], 701 [-0.25 , -0.375, -0.5 ]]), num.array([[-0.25 , -0.125, -0.25 ], 702 [-0.25 , -0.375, -0.25 ], 703 [-0.5 , -0.375, -0.25 ], 704 [-0.25 , -0.375, -0.5 ], 705 [-0.25 , -0.125, -0. ], 706 [-0.25 , -0.375, -0.25 ]]), num.array([[-0.25 , -0.125, -0.25 ], 707 [-0.25 , -0.375, -0.25 ], 708 [-0.5 , -0.375, -0.25 ], 709 [-0.5 , -0.375, -0.5 ], 710 [-0. , -0.125, -0. ], 711 [-0. , -0.125, -0.25 ]])], 'ymomentum': [num.array([[ 0. , 0.25, 0.5 ], 712 [ 0.5 , 0.25, 0.5 ], 713 [ 0.5 , 0.75, 0.5 ], 714 [ 1. , 0.75, 0.5 ], 715 [ 1. , 0.75, 1. ], 716 [ 0. , 0.25, 0. ], 717 [ 0. , 0.25, 0.5 ], 718 [ 0. , 0.25, 0. ], 719 [ 0.5 , 0.25, 0. ], 720 [ 0.5 , 0.25, 0.5 ]]), num.array([[ 0.5 , 0.25, 0. ], 721 [ 0.5 , 0.75, 1. ], 722 [ 0.5 , 0.75, 0.5 ], 723 [ 1. , 0.75, 1. ], 724 [ 0. , 0.25, 0. ], 725 [ 0. , 0.25, 0.5 ]]), num.array([[ 0.5 , 0.25, 0. ], 726 [ 0.5 , 0.75, 1. ], 727 [ 0.5 , 0.75, 0.5 ], 728 [ 1. , 0.75, 0.5 ], 729 [ 0. , 0.25, 0.5 ], 730 [ 0.5 , 0.25, 0.5 ]])], 'friction': [num.array([[ 0., 0., 0.], 731 [ 0., 0., 0.], 732 [ 0., 0., 0.], 733 [ 0., 0., 0.], 734 [ 0., 0., 0.], 735 [ 0., 0., 0.], 736 [ 0., 0., 0.], 737 [ 0., 0., 0.], 738 [ 0., 0., 0.], 739 [ 0., 0., 0.]]), num.array([[ 0., 0., 0.], 740 [ 0., 0., 0.], 741 [ 0., 0., 0.], 742 [ 0., 0., 0.], 743 [ 0., 0., 0.], 744 [ 0., 0., 0.]]), num.array([[ 0., 0., 0.], 745 [ 0., 0., 0.], 746 [ 0., 0., 0.], 747 [ 0., 0., 0.], 748 [ 0., 0., 0.], 749 [ 0., 0., 0.]])], 'xmomentum': [num.array([[ 2., 2., 2.], 750 [ 2., 2., 2.], 751 [ 2., 2., 2.], 752 [ 2., 2., 2.], 753 [ 2., 2., 2.], 754 [ 2., 2., 2.], 755 [ 2., 2., 2.], 756 [ 2., 2., 2.], 757 [ 2., 2., 2.], 758 [ 2., 2., 2.]]), num.array([[ 2., 2., 2.], 759 [ 2., 2., 2.], 760 [ 2., 2., 2.], 761 [ 2., 2., 2.], 762 [ 2., 2., 2.], 763 [ 2., 2., 2.]]), num.array([[ 2., 2., 2.], 764 [ 2., 2., 2.], 765 [ 2., 2., 2.], 766 [ 2., 2., 2.], 767 [ 2., 2., 2.], 768 [ 2., 2., 2.]])]}, 'full_quan': {'stage': [num.array([[-0.25 , -0.125, -0.25 ], 769 [-0.25 , -0.375, -0.25 ], 770 [-0.5 , -0.375, -0.25 ], 771 [-0.5 , -0.375, -0.5 ], 772 [-0.25 , -0.375, -0.5 ]]), num.array([[-0. , -0.125, -0. ], 773 [-0. , -0.125, -0.25 ], 774 [-0. , -0.125, -0. ], 775 [-0.25 , -0.125, -0. ], 776 [-0.25 , -0.125, -0.25 ], 777 [-0. , -0.125, -0.25 ]]), num.array([[-0.25 , -0.125, -0. ], 778 [-0.25 , -0.375, -0.25 ], 779 [-0.5 , -0.375, -0.25 ], 780 [-0.5 , -0.375, -0.5 ], 781 [-0.25 , -0.375, -0.5 ]])], 'elevation': [num.array([[-0.25 , -0.125, -0.25 ], 782 [-0.25 , -0.375, -0.25 ], 783 [-0.5 , -0.375, -0.25 ], 784 [-0.5 , -0.375, -0.5 ], 785 [-0.25 , -0.375, -0.5 ]]), num.array([[-0. , -0.125, -0. ], 786 [-0. , -0.125, -0.25 ], 787 [-0. , -0.125, -0. ], 788 [-0.25 , -0.125, -0. ], 789 [-0.25 , -0.125, -0.25 ], 790 [-0. , -0.125, -0.25 ]]), num.array([[-0.25 , -0.125, -0. ], 791 [-0.25 , -0.375, -0.25 ], 792 [-0.5 , -0.375, -0.25 ], 793 [-0.5 , -0.375, -0.5 ], 794 [-0.25 , -0.375, -0.5 ]])], 'ymomentum': [num.array([[ 0.5 , 0.25, 0. ], 795 [ 0.5 , 0.75, 1. ], 796 [ 0.5 , 0.75, 0.5 ], 797 [ 1. , 0.75, 0.5 ], 798 [ 1. , 0.75, 1. ]]), num.array([[ 0. , 0.25, 0.5 ], 799 [ 0.5 , 0.25, 0.5 ], 800 [ 0.5 , 0.75, 1. ], 801 [ 0.5 , 0.75, 0.5 ], 802 [ 1. , 0.75, 0.5 ], 803 [ 1. , 0.75, 1. ]]), num.array([[ 0. , 0.25, 0. ], 804 [ 0. , 0.25, 0.5 ], 805 [ 0. , 0.25, 0. ], 806 [ 0.5 , 0.25, 0. ], 807 [ 0.5 , 0.25, 0.5 ]])], 'friction': [num.array([[ 0., 0., 0.], 808 [ 0., 0., 0.], 809 [ 0., 0., 0.], 810 [ 0., 0., 0.], 811 [ 0., 0., 0.]]), num.array([[ 0., 0., 0.], 812 [ 0., 0., 0.], 813 [ 0., 0., 0.], 814 [ 0., 0., 0.], 815 [ 0., 0., 0.], 816 [ 0., 0., 0.]]), num.array([[ 0., 0., 0.], 817 [ 0., 0., 0.], 818 [ 0., 0., 0.], 819 [ 0., 0., 0.], 820 [ 0., 0., 0.]])], 'xmomentum': [num.array([[ 2., 2., 2.], 821 [ 2., 2., 2.], 822 [ 2., 2., 2.], 823 [ 2., 2., 2.], 824 [ 2., 2., 2.]]), num.array([[ 2., 2., 2.], 825 [ 2., 2., 2.], 826 [ 2., 2., 2.], 827 [ 2., 2., 2.], 828 [ 2., 2., 2.], 829 [ 2., 2., 2.]]), num.array([[ 2., 2., 2.], 830 [ 2., 2., 2.], 831 [ 2., 2., 2.], 832 [ 2., 2., 2.], 833 [ 2., 2., 2.]])]}} 834 835 836 # setup parameters to test using different ghost_layer_widths 837 parameters = dict(ghost_layer_width = 1) 838 839 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh 840 841 mesh = Mesh(nodes, triangles, boundary) 842 boundary_polygon = mesh.get_boundary_polygon() 843 844 845 # Subdivide into non-overlapping partitions 846 847 submesh = submesh_full(mesh, triangles_per_proc) 848 849 850 851 for i in range(3): 852 assert num.allclose(true_submesh['full_triangles'][i],submesh['full_triangles'][i]) 853 assert num.allclose(true_submesh['full_nodes'][i],submesh['full_nodes'][i]) 854 assert true_submesh['full_boundary'] == submesh['full_boundary'] 855 856 # Add any extra ghost boundary layer information 857 858 submesh = submesh_ghost(submesh, mesh, triangles_per_proc, parameters) 859 860 print submesh 861 862 print 'ghost_triangles', submesh['ghost_triangles'] 863 print 'ghost_boundary[0]', submesh['ghost_boundary'][0] 864 print 'ghost_boundary[1]', submesh['ghost_boundary'][1] 865 print 'ghost_boundary[2]', submesh['ghost_boundary'][2] 866 print 'ghost_nodes', submesh['ghost_nodes'] 867 print 'ghost_commun', submesh['ghost_commun'] 868 869 for i in range(3): 870 assert num.allclose(true_submesh['ghost_triangles'][i],submesh['ghost_triangles'][i]) 871 assert num.allclose(true_submesh['ghost_nodes'][i],submesh['ghost_nodes'][i]) 872 assert num.allclose(true_submesh['ghost_commun'][i],submesh['ghost_commun'][i]) 873 874 assert true_submesh['full_commun'] == submesh['full_commun'] 875 876 877 # Order the quantities information to be the same as the triangle 878 # information 879 880 881 submesh = submesh_quantities(submesh, quantities, \ 882 triangles_per_proc) 883 884 885 886 for key, value in true_submesh['ghost_quan'].iteritems(): 887 for i in range(3): 888 assert num.allclose(true_submesh['ghost_quan'][key][i],submesh['ghost_quan'][key][i]) 889 assert num.allclose(true_submesh['full_quan'][key][i],submesh['full_quan'][key][i]) 890 891 892 submesh["boundary_polygon"] = boundary_polygon 893 894 895 896 512 897 513 898 #------------------------------------------------------------- -
trunk/anuga_work/development/parallel/build_commun.py
r3460 r8538 17 17 ######################################################### 18 18 19 from Numeric import array, Int, Float, zeros 20 import logging, logging.config 19 20 21 import numpy as num 22 from anuga import indent 23 24 from numpy import array, zeros 25 import logging 26 import logging.config 21 27 logger = logging.getLogger('parallel') 22 28 logger.setLevel(logging.WARNING) … … 104 110 # send the triangles 105 111 106 pypar.send(array(submesh["full_triangles"][p], Int), p, use_buffer=True)112 pypar.send(array(submesh["full_triangles"][p], num.int), p, use_buffer=True) 107 113 pypar.send(submesh["ghost_triangles"][p], p, use_buffer=True) 108 114 … … 156 162 submesh_cell = {} 157 163 158 print ' process %d receiving submesh from process%d' %(myid, p)164 print 'P%d: Receiving submesh from P%d' %(myid, p) 159 165 160 166 # receive the tagmap for the boundary conditions … … 185 191 186 192 no_full_nodes = setup_array[0] 187 full_nodes = zeros((no_full_nodes, 3), Float)193 full_nodes = zeros((no_full_nodes, 3), num.float) 188 194 submesh_cell["full_nodes"] = pypar.receive(p, full_nodes) 189 195 … … 191 197 192 198 no_ghost_nodes = setup_array[1] 193 ghost_nodes = zeros((no_ghost_nodes, 3), Float)199 ghost_nodes = zeros((no_ghost_nodes, 3), num.float) 194 200 submesh_cell["ghost_nodes"] = pypar.receive(p, ghost_nodes) 195 201 … … 255 261 256 262 no_quantities = len(qkeys) 257 new_quan = zeros((no_full_triangles, 3), Float)263 new_quan = zeros((no_full_triangles, 3), num.float) 258 264 submesh_cell["full_quan"]={} 259 265 260 266 for i in range(no_quantities): 261 267 tmp = pypar.receive(p, new_quan) 262 submesh_cell["full_quan"][qkeys[i]]=zeros((no_full_triangles,3), Float)268 submesh_cell["full_quan"][qkeys[i]]=zeros((no_full_triangles,3), num.float) 263 269 submesh_cell["full_quan"][qkeys[i]][:] = tmp[:] 264 270 265 new_quan = zeros((no_ghost_triangles, 3), Float)271 new_quan = zeros((no_ghost_triangles, 3), num.float) 266 272 submesh_cell["ghost_quan"]={} 267 273 for i in range(no_quantities): 268 274 tmp = pypar.receive(p, new_quan) 269 submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), Float)275 submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), num.float) 270 276 submesh_cell["ghost_quan"][qkeys[i]][:] = tmp[:] 271 277
Note: See TracChangeset
for help on using the changeset viewer.