Changeset 1409
- Timestamp:
- May 17, 2005, 4:38:26 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/parallel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/parallel/linda_dummy.py
r1399 r1409 2 2 from os import sep 3 3 sys.path.append('..'+sep+'pyvolution') 4 5 6 7 4 from mg2ga import * 8 from parallel_advection import *9 10 5 # open file 11 12 f=open('test_3l_2c.out', 'r') 6 f=open('test_3l_2cc.out', 'r') 13 7 print f 14 15 8 # read in nodes and triangles 16 17 [nodes, triangles, nodes_per_proc] = mg2ga(f) 18 9 [nodes, triangles, triangles_per_proc] = mg2ga(f) 10 f.close 19 11 # find whole mesh on host 20 21 #mesh = Parallel_Domain(nodes, triangles)22 12 mesh = Mesh(nodes, triangles) 23 24 13 # find sub domains (i.e. full triangles) 25 26 14 submesh = [] 27 nlower = 028 nproc = len( nodes_per_proc)15 tlower = 0 16 nproc = len(triangles_per_proc) 29 17 nnodes = len(nodes) 30 31 18 # loop over processors 32 19 for p in range(nproc): 33 # find triangles in processor p 34 35 nupper = nodes_per_proc[p]+nlower 36 subtriangles = filter(lambda t: nlower<=max(t)<nupper, triangles) 37 20 # find triangles on processor p 21 tupper = triangles_per_proc[p]+tlower 22 subtriangles = triangles[tlower:tupper] 38 23 # find nodes in processor p 39 40 24 nodemap = map(lambda n: 0, nodes) 41 25 for t in subtriangles: … … 43 27 nodemap[t[1]]=1 44 28 nodemap[t[2]]=1 45 subnodes = [] 29 subnodes = [] 46 30 for i in range(nnodes): 47 31 if nodemap[i] == 1: 48 32 subnodes.append([i,nodes[i][0],nodes[i][1]]) 49 50 33 # renumber nodes (have to change to store local/global map) 51 52 34 [GAnodes, GAtriangles] = restructure(subnodes, subtriangles) 53 54 35 # build GA data structure (maybe not needed, maybe can just remember 55 36 # GAnodes, GAtriangles and build mesh on processors) 56 57 37 submesh.append(Mesh(GAnodes, GAtriangles)) 58 nlower = nupper 59 38 tlower = tupper 60 39 # check results 61 40 #write a data file for use by scilab script 41 #START160505 VISUALISE MESH IN SCILAB 42 #write triangles as (x0,y0,x1,y1,x2,y2,processor), for use in a scilab visualisation script. 43 fp=open("visualise_mesh","w"); 44 tlower=0 45 for p in range(len(triangles_per_proc)): 46 nodes=submesh[p].coordinates 47 triangles=submesh[p].triangles 48 for t in range(shape(triangles)[0]): 49 x=[] 50 y=[] 51 string=repr(t)+ ' ' 52 for i in range(3): 53 x.append(nodes[triangles[t][i]][0]) 54 y.append(nodes[triangles[t][i]][1]) 55 string=string+repr(x[i])+' '+repr(y[i])+' ' 56 string=string+repr(p)+'\n' 57 fp.write(string) 58 if ((x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0])<=0): 59 string='Error: Triangle '+repr(t)+' on processor '+repr(p)+' is oriented clockwise or degenerate' 60 print(string) 61 fp.close() 62 #END160505 VISUALISE MESH IN SCILAB 62 63 mesh 63 64 mesh.vertex_coordinates 64 65 mesh.triangles 65 66 66 submesh -
inundation/ga/storm_surge/parallel/mg2ga.py
r1403 r1409 1 1 from string import atoi 2 2 from string import atof 3 from general_mesh import General_mesh as Mesh 3 import os 4 from mesh import Mesh 4 5 from Numeric import shape 5 6 ################################################################################## … … 35 36 # know first nodes_per_proc[0] belong to cell 0, next 36 37 # nodes_per_proc[1] belong to cell 1 etc. 37 nodes_per_proc = []38 triangles_per_proc = [] 38 #nodes_per_proc = [] This is worked out later 39 triangles_per_proc = [] #each triangle belongs to a unique processor 39 40 # loop over the processors 40 41 for q in range(no_proc): … … 42 43 # read the nodes 43 44 no_nodes = str2array(f.readline(), atoi)[1] 44 nodes_per_proc.append(no_nodes)45 #nodes_per_proc.append(no_nodes) 45 46 f.readline() 46 47 for i in range(no_nodes): … … 89 90 f.readline() 90 91 f.readline() 91 return nodes, triangles, nodes_per_proc92 return nodes, triangles, triangles_per_proc 92 93 ################################################################################## 93 94 # Convert the format of the data to that used by pyvolution … … 121 122 return GAnodes, triangles 122 123 def mg2ga(f): 123 [nodes, triangles, nodes_per_proc] = readmg(f)124 [nodes, triangles, triangles_per_proc] = readmg(f) 124 125 [nodes, triangles] = restructure(nodes, triangles) 125 return nodes, triangles, nodes_per_proc126 return nodes, triangles, triangles_per_proc
Note: See TracChangeset
for help on using the changeset viewer.