Changeset 2095
- Timestamp:
- Nov 29, 2005, 4:53:47 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/parallel/pmesh_divide.py
r2092 r2095 322 322 # print edgecut 323 323 # print npart 324 # print epart 325 # Assign triangles to processes, according to what metis told us. 326 327 # tri_index maps triangle number -> processor, new triangle number 328 # (local to the processor) 329 tri_index = {} 330 triangles = [] 331 for i in range(n_tri): 332 triangles_per_proc[epart[i]] = triangles_per_proc[epart[i]] + 1 333 tri_list[epart[i]].append(domain.triangles[i]) 334 tri_index[i] = ([epart[i], len(tri_list[epart[i]]) - 1]) 335 336 # print tri_list 337 # print triangles_per_proc 338 339 # order the triangle list so that all of the triangles belonging 340 # to processor i are listed before those belonging to processor 341 # i+1 342 343 for i in range(n_procs): 344 for t in tri_list[i]: 345 triangles.append(t) 346 347 # the boundary labels have to changed in accoradance with the 348 # new triangle ordering, proc_sum and tri_index help with this 349 350 proc_sum[0] = 0 351 for i in range(n_procs - 1): 352 proc_sum[i+1]=proc_sum[i]+triangles_per_proc[i] 353 354 # relabel the boundary elements to fit in with the new triangle 355 # ordering 356 357 boundary = {} 358 for b in domain.boundary: 359 t = tri_index[b[0]] 360 boundary[proc_sum[t[0]]+t[1], b[1]] = domain.boundary[b] 361 362 quantities = reorder(domain.quantities, tri_index, proc_sum) 324 363 else: 325 epart = [0] * n_tri 326 327 # print epart 328 329 330 # Assign triangles to processes, according to what metis told us. 331 332 # tri_index maps triangle number -> processor, new triangle number 333 # (local to the processor) 334 tri_index = {} 335 triangles = [] 336 for i in range(n_tri): 337 triangles_per_proc[epart[i]] = triangles_per_proc[epart[i]] + 1 338 tri_list[epart[i]].append(domain.triangles[i]) 339 tri_index[i] = ([epart[i], len(tri_list[epart[i]]) - 1]) 340 341 # print tri_list 342 # print triangles_per_proc 343 344 # order the triangle list so that all of the triangles belonging 345 # to processor i are listed before those belonging to processor 346 # i+1 347 348 for i in range(n_procs): 349 for t in tri_list[i]: 350 triangles.append(t) 351 352 # the boundary labels have to changed in accoradance with the 353 # new triangle ordering, proc_sum and tri_index help with this 354 355 proc_sum[0] = 0 356 for i in range(n_procs - 1): 357 proc_sum[i+1]=proc_sum[i]+triangles_per_proc[i] 358 359 # relabel the boundary elements to fit in with the new triangle 360 # ordering 361 362 boundary = {} 363 for b in domain.boundary: 364 t = tri_index[b[0]] 365 boundary[proc_sum[t[0]]+t[1], b[1]] = domain.boundary[b] 366 367 quantities = reorder(domain.quantities, tri_index, proc_sum) 368 364 boundary = domain.boundary.copy() 365 triangles_per_proc[0] = n_tri 366 triangles = domain.triangles.copy() 367 # This is essentially the same as a chunk of code from reorder. 368 quantities = {} 369 for k in domain.quantities: 370 quantities[k] = zeros((n_tri, 3), Float) 371 for i in range(n_tri): 372 quantities[k][i] = domain.quantities[k].vertex_values[i] 373 369 374 # extract the node list 370 375 nodes = domain.coordinates.copy() 371 372 376 # convert the triangle datastructure to be an array type 373 377 # this helps with the communication
Note: See TracChangeset
for help on using the changeset viewer.