Changeset 1565
- Timestamp:
- Jul 1, 2005, 5:08:10 PM (19 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/parallel/pmesh_divide.py
r1559 r1565 18 18 ######################################################### 19 19 20 from pmesh2domain import pmesh_to_domain_instance 20 21 from math import floor 21 from pmesh2domain import pmesh_to_domain_instance22 23 #########################################################24 #25 # Find the minimum x coordinate26 #27 # *) t1 and t2 are two node coordinates28 #29 # -------------------------------------------------------30 #31 # *) The node with the minimum x coordinate is returned32 #33 #########################################################34 35 def min_x(t1, t2):36 if t1[0] < t2[0]:37 return t138 else:39 return t240 41 #########################################################42 #43 # Find the maximum x coordinate44 #45 # *) t1 and t2 are two node coordinates46 #47 # -------------------------------------------------------48 #49 # *) The node with the maximum x coordinate is returned50 #51 #########################################################52 53 def max_x(t1, t2):54 if t1[0] > t2[0]:55 return t156 else:57 return t258 59 #########################################################60 #61 # Find the minimum y coordinate62 #63 # *) t1 and t2 are two node coordinates64 #65 # -------------------------------------------------------66 #67 # *) The node with the minimum y coordinate is returned68 #69 #########################################################70 def min_y(t1, t2):71 if t1[1] < t2[1]:72 return t173 else:74 return t275 76 #########################################################77 #78 # Find the maximum y coordinate79 #80 # *) t1 and t2 are two node coordinates81 #82 # -------------------------------------------------------83 #84 # *) The node with the maximum y coordinate is returned85 #86 #########################################################87 def max_y(t1, t2):88 if t1[1] > t2[1]:89 return t190 else:91 return t292 22 93 23 ######################################################### … … 113 43 # read in the pmesh 114 44 115 domain = pmesh_to_domain_instance(f, Domain) #45 domain = pmesh_to_domain_instance(f, Domain) 116 46 117 47 # find the bounding box 118 119 x_coord_min = reduce(min_x, domain.coordinates)[0] 120 x_coord_max = reduce(max_x, domain.coordinates)[0] 121 y_coord_min = reduce(min_y, domain.coordinates)[1] 122 y_coord_max = reduce(max_y, domain.coordinates)[1] 123 124 125 rect = [x_coord_min, y_coord_min, x_coord_max, y_coord_max] 48 x_coord_min = domain.xy_extent[0] 49 x_coord_max = domain.xy_extent[2] 50 y_coord_min = domain.xy_extent[1] 51 y_coord_max = domain.xy_extent[3] 52 53 rect = domain.xy_extent 126 54 127 55 # find the size of each sub-box … … 197 125 198 126 return nodes, triangles, boundary, triangles_per_proc, rect 127 128 129 130 def pmesh_divide_steve(f, Domain, n_x = 1, n_y = 1): 131 132 # read in the pmesh 133 134 domain = pmesh_to_domain_instance(f, Domain) 135 136 137 # for key, Quantity in domain.quantities.iteritems(): 138 # print key 139 # for n in range(10): 140 # print Quantity.centroid_values[n] 141 142 # find the bounding box 143 x_coord_min = domain.xy_extent[0] 144 x_coord_max = domain.xy_extent[2] 145 y_coord_min = domain.xy_extent[1] 146 y_coord_max = domain.xy_extent[3] 147 148 rect = domain.xy_extent 149 150 # find the size of each sub-box 151 152 x_div = (x_coord_max-x_coord_min)/n_x 153 y_div = (y_coord_max-y_coord_min)/n_y 154 155 156 # initialise the lists 157 tri_list = [] 158 triangles_per_proc = [] 159 proc_sum = [] 160 for i in range(n_x*n_y): 161 tri_list.append([]) 162 triangles_per_proc.append([]) 163 proc_sum.append([]) 164 tri_list[i] = [] 165 166 # subdivide the triangles depending on which sub-box they sit 167 # in (a triangle sits in the sub-box if its first vectex sits 168 # in that sub-box) 169 170 tri_index = {} 171 N = domain.number_of_elements 172 for i in range(N): 173 t = domain.triangles[i] 174 175 x_coord = domain.centroid_coordinates[i][0] 176 bin_x = int(floor((x_coord-x_coord_min)/x_div)) 177 if (bin_x == n_x): 178 bin_x = n_x-1 179 180 y_coord = domain.centroid_coordinates[i][1] 181 bin_y = int(floor((y_coord-y_coord_min)/y_div)) 182 if (bin_y == n_y): 183 bin_y = n_y-1 184 185 bin = bin_y*n_x + bin_x 186 tri_list[bin].append(t) 187 tri_index[i] = ([bin, len(tri_list[bin])-1]) 188 189 # find the number of triangles per processor and order the 190 # triangle list so that all of the triangles belonging to 191 # processor i are listed before those belonging to processor 192 # i+1 193 194 triangles = [] 195 for i in range(n_x*n_y): 196 triangles_per_proc[i] = len(tri_list[i]) 197 for t in tri_list[i]: 198 triangles.append(t) 199 200 # the boundary labels have to changed in accoradance with the 201 # new triangle ordering, proc_sum and tri_index help with this 202 203 proc_sum[0] = 0 204 for i in range(n_x*n_y-1): 205 proc_sum[i+1]=proc_sum[i]+triangles_per_proc[i] 206 207 # relabel the boundary elements to fit in with the new triangle 208 # ordering 209 210 boundary = {} 211 for b in domain.boundary: 212 t = tri_index[b[0]] 213 boundary[proc_sum[t[0]]+t[1], b[1]] = domain.boundary[b] 214 215 # extract the node list 216 nodes = domain.coordinates.copy() 217 218 return nodes, triangles, boundary, triangles_per_proc, rect 219 220 221 -
inundation/ga/storm_surge/parallel/run_parallel_sw_merimbula.py
r1563 r1565 59 59 # mesh partition routines 60 60 61 from pmesh_divide import pmesh_divide 61 from pmesh_divide import pmesh_divide, pmesh_divide_steve 62 62 from build_submesh import * 63 63 from build_local import * … … 79 79 80 80 #filename = 'test-100.tsh' 81 filename = 'merimbula_10785 .tsh'82 nx = 281 filename = 'merimbula_10785_1.tsh' 82 nx = numprocs 83 83 ny = 1 84 84 if nx*ny != numprocs: … … 86 86 87 87 [nodes, triangles, boundary, triangles_per_proc, rect] =\ 88 pmesh_divide (filename, Shallow_Water_Domain, nx, ny)88 pmesh_divide_steve(filename, Shallow_Water_Domain, nx, ny) 89 89 90 90 # subdivide the mesh 91 91 92 print rect92 #print rect 93 93 94 94 rect = array(rect, Float) … … 123 123 124 124 pypar.broadcast(rect,0) 125 print rect125 #print rect 126 126 127 127 domain = Parallel_Shallow_Water_Domain(points, vertices, boundary, -
inundation/ga/storm_surge/pyvolution/general_mesh.py
r1387 r1565 84 84 #Register number of elements (N) 85 85 self.number_of_elements = N = self.triangles.shape[0] 86 87 self.xy_extent = [ min(self.coordinates[:,0]), min(self.coordinates[:,1]) , 88 max(self.coordinates[:,0]), max(self.coordinates[:,1]) ] 89 86 90 87 91 #Allocate space for geometric quantities … … 275 279 def get_area(self): 276 280 """Return total area of mesh 277 278 279 281 """ 282 283 return sum(self.areas) -
inundation/ga/storm_surge/pyvolution/realtime_visualisation_new.py
r1510 r1565 21 21 22 22 # models for each quantity 23 self.z_models = {} 24 keys = self.domain.quantities.keys() 23 self.vpython_z_models = {} 25 24 #print keys 26 for key in keys:27 self. z_models[key] = faces(frame= self.frame)25 for key in self.domain.quantities: 26 self.vpython_z_models[key] = faces(frame= self.frame) 28 27 29 28 #print self.z_models … … 161 160 162 161 #print 'update bed image' 163 self. z_models[qname].pos = self.pos164 self. z_models[qname].color = self.colour165 self. z_models[qname].normal = self.normals162 self.vpython_z_models[qname].pos = self.pos 163 self.vpython_z_models[qname].color = self.colour 164 self.vpython_z_models[qname].normal = self.normals 166 165 except: 167 166 print 'Visualisation: Could not update quantity '+qname … … 189 188 190 189 #print 'update bed image' 191 self. z_models[qname].pos = self.pos192 self. z_models[qname].color = self.colour193 self. z_models[qname].normal = self.normals190 self.vpython_z_models[qname].pos = self.pos 191 self.vpython_z_models[qname].color = self.colour 192 self.vpython_z_models[qname].normal = self.normals 194 193 #except: 195 194 # print 'Visualisation: Could not update quantity '+qname
Note: See TracChangeset
for help on using the changeset viewer.