Changeset 2625
- Timestamp:
- Mar 29, 2006, 9:41:58 AM (19 years ago)
- Location:
- inundation/parallel
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/parallel/build_commun.py
r2130 r2625 59 59 tagmap[bkey] = counter 60 60 counter = counter+1 61 for b in submesh["ghost_boundary"][p]: 62 bkey = submesh["ghost_boundary"][p][b] 63 if not tagmap.has_key(bkey): 64 tagmap[bkey] = counter 65 counter = counter+1 61 66 pypar.send(tagmap, p) 62 67 … … 79 84 # send the array sizes so memory can be allocated 80 85 81 setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]86 setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 82 87 setup_array[0] = len(submesh["full_nodes"][p]) 83 88 setup_array[1] = len(submesh["ghost_nodes"][p]) … … 85 90 setup_array[3] = len(submesh["ghost_triangles"][p]) 86 91 setup_array[4] = len(submesh["full_boundary"][p]) 87 setup_array[5] = len(submesh["ghost_commun"][p]) 88 setup_array[6] = len(flat_full_commun) 92 setup_array[5] = len(submesh["ghost_boundary"][p]) 93 setup_array[6] = len(submesh["ghost_commun"][p]) 94 setup_array[7] = len(flat_full_commun) 89 95 90 96 pypar.send(setup_array, p) … … 105 111 for b in submesh["full_boundary"][p]: 106 112 bc.append([b[0], b[1], tagmap[submesh["full_boundary"][p][b]]]) 113 pypar.send(bc, p, use_buffer=True) 114 bc = [] 115 for b in submesh["ghost_boundary"][p]: 116 bc.append([b[0], b[1], tagmap[submesh["ghost_boundary"][p][b]]]) 107 117 pypar.send(bc, p, use_buffer=True) 108 118 … … 150 160 151 161 tagmap = pypar.receive(p) 162 itagmap = {} 163 for t in tagmap: 164 itagmap[tagmap[t]]=t 152 165 153 166 # receive the quantities key information … … 165 178 # recieve information about the array sizes 166 179 167 setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]180 setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 168 181 setup_array = pypar.receive(p, setup_array) 169 182 … … 201 214 bnd_c = pypar.receive(p, bc) 202 215 203 itagmap = {}204 for t in tagmap:205 itagmap[tagmap[t]]=t206 207 216 submesh_cell["full_boundary"] = {} 208 217 for b in bnd_c: 209 218 submesh_cell["full_boundary"][b[0],b[1]]=itagmap[b[2]] 210 219 220 # receive the ghost boundary 221 222 no_ghost_boundary = setup_array[5] 223 bc = [] 224 for i in range(no_ghost_boundary): 225 bc.append([0.0, 0.0, 0.0]) 226 bnd_c = pypar.receive(p, bc) 227 228 submesh_cell["ghost_boundary"] = {} 229 for b in bnd_c: 230 submesh_cell["ghost_boundary"][b[0],b[1]]=itagmap[b[2]] 231 211 232 # receive the ghost communication pattern 212 233 213 no_ghost_commun = setup_array[ 5]234 no_ghost_commun = setup_array[6] 214 235 ghost_commun = zeros((no_ghost_commun, 2), Int) 215 236 submesh_cell["ghost_commun"] = pypar.receive(p, ghost_commun) … … 217 238 # receive the full communication pattern 218 239 219 no_full_commun = setup_array[ 6]240 no_full_commun = setup_array[7] 220 241 full_commun = [] 221 242 for i in range(no_full_commun): -
inundation/parallel/build_local.py
r2130 r2625 40 40 ######################################################### 41 41 42 def build_local_GA(nodes, triangles ):42 def build_local_GA(nodes, triangles, boundaries, tri_index): 43 43 44 44 Nnodes =len(nodes) … … 65 65 GAtriangles[:,1] = take(index, triangles[:,1]) 66 66 GAtriangles[:,2] = take(index, triangles[:,2]) 67 67 68 # Change the triangle numbering in the boundaries 69 70 GAboundaries = {} 71 for b in boundaries: 72 GAboundaries[tri_index[b[0]], b[1]] = boundaries[b] 73 68 74 del (index) 69 70 return GAnodes, GAtriangles 75 76 return GAnodes, GAtriangles, GAboundaries 71 77 72 78 … … 171 177 triangles = concatenate((submesh["full_triangles"], gtri)) 172 178 173 # Renumber the boundary edges to correspond to the new 174 # triangle numbering 175 176 GAboundary = {} 177 for b in submesh["full_boundary"]: 178 GAboundary[b[0]-lower_t,b[1]] = submesh["full_boundary"][b] 179 # Combine the full boundaries and ghost boundaries 180 181 boundaries = submesh["full_boundary"] 182 for b in submesh["ghost_boundary"]: 183 boundaries[b]=submesh["ghost_boundary"][b] 179 184 180 185 # Make note of the new triangle numbers, including the ghost … … 190 195 for i in range(len(submesh["ghost_triangles"])): 191 196 index[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t 192 197 193 198 # Change the node numbering (and update the numbering in the 194 199 # triangles) 195 200 196 [GAnodes, GAtriangles ] = build_local_GA(nodes, triangles)201 [GAnodes, GAtriangles, GAboundary] = build_local_GA(nodes, triangles, boundaries, index) 197 202 198 203 # Extract the local quantities -
inundation/parallel/build_submesh.py
r2130 r2625 113 113 # be added to the node list for the current processor 114 114 # 115 # *) The boundary edges for the ghost triangles are116 # ignored.117 115 # 118 116 # ------------------------------------------------------- … … 206 204 return subnodes, subtriangles 207 205 206 ######################################################### 207 # 208 # Find the edges of the ghost trianlges that do not 209 # have a neighbour in the current cell. These are 210 # treated as a special type of boundary edge. 211 # 212 # *) Given the ghost triangles in a particular 213 # triangle, use the mesh to find its neigbours. If 214 # the neighbour is not in the processor set it to 215 # be a boundary edge 216 # 217 # *) The vertices in the ghost triangles must also 218 # be added to the node list for the current processor 219 # 220 # *) The boundary edges for the ghost triangles are 221 # ignored. 222 # 223 # ------------------------------------------------------- 224 # 225 # *) The type assigned to the ghost boundary edges is 'ghost' 226 # 227 # *) The boundary information is returned as a directorier 228 # with the key = (triangle id, edge no) and the values 229 # assigned to the key is 'ghost' 230 # 231 # 232 ######################################################### 233 def is_in_processor(ghost_list, tlower, tupper, n): 234 return (n in ghost_list) or (tlower <= n and tupper >= n) 235 236 def ghost_bnd_layer(ghosttri, tlower, tupper, mesh, p): 237 238 ghost_list = [] 239 subboundary = {} 240 241 for t in ghosttri: 242 ghost_list.append(t[0]) 243 244 for t in ghosttri: 245 n = mesh.neighbours[t[0], 0] 246 if not is_in_processor(ghost_list, tlower, tupper, n): 247 subboundary[t[0], 0] = 'ghost' 248 249 n = mesh.neighbours[t[0], 1] 250 if not is_in_processor(ghost_list, tlower, tupper, n): 251 subboundary[t[0], 1] = 'ghost' 252 253 n = mesh.neighbours[t[0], 2] 254 if not is_in_processor(ghost_list, tlower, tupper, n): 255 subboundary[t[0], 2] = 'ghost' 256 257 return subboundary 208 258 209 259 ######################################################### … … 318 368 # updates must also be built. 319 369 # 370 # *) Assumes that full triangles, nodes etc have already 371 # been found and stored in submesh 372 # 320 373 # *) See the documentation for ghost_layer, 321 374 # ghost_commun_pattern and full_commun_pattern … … 327 380 # ghost_commun_pattern and full_commun_pattern 328 381 # 329 # *) The ghost_triangles, ghost_nodes, ghost_ commun and330 # full_commun is added to submesh382 # *) The ghost_triangles, ghost_nodes, ghost_boundary, 383 # ghost_commun and full_commun is added to submesh 331 384 ######################################################### 332 385 … … 338 391 ghost_nodes = [] 339 392 ghost_commun = [] 393 ghost_bnd = [] 340 394 341 395 # Loop over the processors … … 354 408 ghost_nodes.append(subnodes) 355 409 410 # Find the boundary layer formed by the ghost triangles 411 412 subbnd = ghost_bnd_layer(subtri, tupper, tlower, mesh, p) 413 ghost_bnd.append(subbnd) 414 356 415 # Build the communication pattern for the ghost nodes 357 416 … … 369 428 submesh["ghost_triangles"] = ghost_triangles 370 429 submesh["ghost_commun"] = ghost_commun 371 430 submesh["ghost_boundary"] = ghost_bnd 431 372 432 # Build the communication pattern for the full triangles 373 433 … … 449 509 # *) A dictionary containing the full_triangles, 450 510 # full_nodes, full_boundary, ghost_triangles, ghost_nodes, 451 # ghost_ commun and full_commun is returned.511 # ghost_boundary, ghost_commun and full_commun is returned. 452 512 # 453 513 ######################################################### … … 489 549 # *) A dictionary containing the full_triangles, 490 550 # full_nodes, full_boundary, ghost_triangles, ghost_nodes, 491 # ghost_ commun and full_commun belonging to processor zero492 # are returned.551 # ghost_boundary, ghost_commun and full_commun belonging 552 # to processor zero are returned. 493 553 # 494 554 ######################################################### … … 501 561 submesh_cell["ghost_triangles"] = submesh["ghost_triangles"][0] 502 562 submesh_cell["full_boundary"] = submesh["full_boundary"][0] 563 submesh_cell["ghost_boundary"] = submesh["ghost_boundary"][0] 503 564 submesh_cell["ghost_commun"] = submesh["ghost_commun"][0] 504 565 submesh_cell["full_commun"] = submesh["full_commun"][0] -
inundation/parallel/parallel_meshes.py
r1607 r2625 12 12 Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou 13 13 Geoscience Australia, 2005 14 15 Modified by Linda Stals, March 2006, to include ghost boundaries 16 14 17 """ 15 18 … … 124 127 125 128 if i == m-1: 126 boundary[nt, 2] = 'right' 129 if processor == numproc-1: 130 boundary[nt, 2] = 'right' 131 else: 132 boundary[nt, 2] = 'ghost' 133 127 134 if j == 0: 128 135 boundary[nt, 1] = 'bottom' … … 144 151 145 152 if i == 0: 146 boundary[nt, 2] = 'left' 153 if processor == 0: 154 boundary[nt, 2] = 'left' 155 else: 156 boundary[nt, 2] = 'ghost' 147 157 if j == n-1: 148 158 boundary[nt, 1] = 'top' … … 263 273 264 274 if i == m-1: 265 boundary[nt, 2] = 'right' 275 if processor == numproc-1: 276 boundary[nt, 2] = 'right' 277 else: 278 boundary[nt, 2] = 'ghost' 266 279 if j == 0: 267 280 boundary[nt, 1] = 'bottom' … … 282 295 283 296 if i == 0: 284 boundary[nt, 2] = 'left' 297 if processor == 0: 298 boundary[nt, 2] = 'left' 299 else: 300 boundary[nt, 2] = 'ghost' 285 301 if j == n-1: 286 302 boundary[nt, 1] = 'top' … … 391 407 392 408 if i == m-1: 393 boundary[nt, 2] = 'right' 409 if processor == numproc-1: 410 boundary[nt, 2] = 'right' 411 else: 412 boundary[nt, 2] = 'ghost' 394 413 if j == 0: 395 414 boundary[nt, 1] = 'bottom' … … 404 423 405 424 if i == 0: 406 boundary[nt, 2] = 'left' 425 if processor == 0: 426 boundary[nt, 2] = 'left' 427 else: 428 boundary[nt, 2] = 'ghost' 407 429 if j == n-1: 408 430 boundary[nt, 1] = 'top' -
inundation/parallel/run_parallel_advection.py
r2090 r2625 5 5 sys.path.append('..'+sep+'pyvolution') 6 6 7 7 8 #======================================================================== 9 10 import pypar 11 8 12 from config import g, epsilon 9 13 from Numeric import allclose, array, zeros, ones, Float … … 14 18 from parallel_advection import Transmissive_boundary, Dirichlet_boundary 15 19 16 import pypar17 18 20 numprocs = pypar.size() 19 21 myid = pypar.rank() 20 22 processor_name = pypar.Get_processor_name() 21 22 23 23 24 … … 41 42 #Boundaries 42 43 T = Transmissive_boundary(domain) 43 D = Dirichlet_boundary(array([1.0])) 44 D = Dirichlet_boundary(array([1.0])) 44 45 45 46 domain.default_order = 2 46 47 47 48 domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T} ) 48 domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T, 'ghost': None} ) 49 49 domain.check_integrity() 50 50 -
inundation/parallel/run_parallel_merimbula.py
r2152 r2625 87 87 # read in the test files 88 88 89 filename = 'test-100.tsh'90 #filename = 'merimbula_10785.tsh'89 # filename = 'test-100.tsh' 90 filename = 'merimbula_10785.tsh' 91 91 nx = numprocs 92 92 ny = 1 … … 95 95 96 96 domain_full = pmesh_to_domain_instance(filename, Advection_Domain) 97 domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))98 # domain.set_quantity('stage', Set_Stage(756000.0,756500.0,4.0))97 # domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0)) 98 domain_full.set_quantity('stage', Set_Stage(756000.0,756500.0,4.0)) 99 99 100 100 nodes, triangles, boundary, triangles_per_proc, quantities =\ 101 101 pmesh_divide(domain_full, nx, ny) 102 102 103 103 # subdivide the mesh 104 104 rect = array(domain_full.xy_extent, Float) 105 106 print rect107 105 108 106 rect = array(rect, Float) … … 128 126 rec_submesh(0) 129 127 130 #if myid == 0:131 # print 'ghost'132 # print ghost_recv_dict133 #134 #if myid == 0:135 # print 'full'136 # print full_send_dict137 138 139 128 pypar.broadcast(rect,0) 140 print rect141 129 142 130 domain = Parallel_Domain(points, vertices, boundary, … … 150 138 151 139 T = Transmissive_boundary(domain) 152 R = Reflective_boundary(domain)153 domain.set_boundary( {'outflow': R, 'inflow': R, 'inner':R, 'exterior': R, 'open':R} )140 #R = Reflective_boundary(domain) 141 domain.set_boundary( {'outflow': T, 'inflow': T, 'inner':T, 'exterior': T, 'open':T, 'ghost':None} ) 154 142 155 143 … … 170 158 171 159 160 from norms import linf_norm 172 161 173 162 #yieldstep = 1 163 #finaltime = 4000 164 174 165 yieldstep = 1000 175 166 finaltime = 50000 176 # finaltime = 4000 167 177 168 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 178 169 if myid == 0: 179 170 domain.write_time() 171 ## Stage = domain.quantities['stage'] 172 ## max_stage = max(max(Stage.edge_values)) 173 ## print max_stage 174 ## if max_stage > 4.0: 175 ## print "######################", max_stage 180 176 181 177 if myid == 0: -
inundation/parallel/run_parallel_sw_rectangle.py
r2198 r2625 46 46 N = M*numprocs 47 47 48 #N = M = 25049 50 48 if myid == 0: 51 49 print 'N == %d' %N 52 50 53 51 points, vertices, boundary, full_send_dict, ghost_recv_dict = \ 54 parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g =1.0)52 parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g = 1.0) 55 53 56 54 … … 84 82 85 83 86 domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R } )84 domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R, 'ghost': None} ) 87 85 domain.check_integrity() 88 86
Note: See TracChangeset
for help on using the changeset viewer.