Changeset 1585
- Timestamp:
- Jul 6, 2005, 9:55:40 PM (19 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/parallel/pmesh_divide.py
r1580 r1585 130 130 131 131 # find the number triangles 132 132 133 133 N = len(tri_index) 134 134 … … 137 137 index = zeros(N, Int) 138 138 q_reord = {} 139 139 140 140 # find the new ordering of the triangles 141 141 142 142 for i in range(N): 143 143 bin = tri_index[i][0] 144 bin_off_set = tri_index[i][1] 144 bin_off_set = tri_index[i][1] 145 145 index[i] = proc_sum[bin]+bin_off_set 146 146 147 147 # reorder each quantity according to the new ordering 148 148 149 149 for k in quantities: 150 150 q_reord[k] = zeros((N, 3), Float) … … 153 153 154 154 del index 155 155 156 156 return q_reord 157 157 158 158 def pmesh_divide(domain, n_x = 1, n_y = 1): 159 159 … … 231 231 232 232 quantities = reorder(domain.quantities, tri_index, proc_sum) 233 233 234 234 # extract the node list 235 235 nodes = domain.coordinates.copy() … … 237 237 return nodes, triangles, boundary, triangles_per_proc, quantities 238 238 239 def pmesh_divide_steve(domain, n_x = 1, n_y = 1): 240 241 # find the bounding box 242 x_coord_min = domain.xy_extent[0] 243 x_coord_max = domain.xy_extent[2] 244 y_coord_min = domain.xy_extent[1] 245 y_coord_max = domain.xy_extent[3] 246 247 248 # find the size of each sub-box 249 250 x_div = (x_coord_max-x_coord_min)/n_x 251 y_div = (y_coord_max-y_coord_min)/n_y 252 253 254 # initialise the lists 255 tri_list = [] 256 triangles_per_proc = [] 257 proc_sum = [] 258 for i in range(n_x*n_y): 259 tri_list.append([]) 260 triangles_per_proc.append([]) 261 proc_sum.append([]) 262 tri_list[i] = [] 263 264 # subdivide the triangles depending on which sub-box they sit 265 # in (a triangle sits in the sub-box if its first vectex sits 266 # in that sub-box) 267 268 tri_index = {} 269 N = domain.number_of_elements 270 271 #sort by x coordinate of centroid 272 from Numeric import argsort 273 sort_order = argsort(argsort(domain.centroid_coordinates[:,0])) 274 275 x_div = float(N)/n_x 276 277 for i in range(N): 278 t = domain.triangles[i] 279 280 bin = int(floor(sort_order[i]/x_div)) 281 if (bin == n_x): 282 bin = n_x-1 283 284 tri_list[bin].append(t) 285 tri_index[i] = ([bin, len(tri_list[bin])-1]) 286 287 #print tri_list 288 289 #print tri_index 290 291 # find the number of triangles per processor and order the 292 # triangle list so that all of the triangles belonging to 293 # processor i are listed before those belonging to processor 294 # i+1 295 296 triangles = [] 297 for i in range(n_x*n_y): 298 triangles_per_proc[i] = len(tri_list[i]) 299 for t in tri_list[i]: 300 triangles.append(t) 301 302 # the boundary labels have to changed in accoradance with the 303 # new triangle ordering, proc_sum and tri_index help with this 304 305 proc_sum[0] = 0 306 for i in range(n_x*n_y-1): 307 proc_sum[i+1]=proc_sum[i]+triangles_per_proc[i] 308 309 # relabel the boundary elements to fit in with the new triangle 310 # ordering 311 312 boundary = {} 313 for b in domain.boundary: 314 t = tri_index[b[0]] 315 boundary[proc_sum[t[0]]+t[1], b[1]] = domain.boundary[b] 316 317 quantities = reorder(domain.quantities, tri_index, proc_sum) 318 319 # extract the node list 320 nodes = domain.coordinates.copy() 321 322 return nodes, triangles, boundary, triangles_per_proc, quantities -
inundation/ga/storm_surge/parallel/run_parallel_sw_merimbula.py
r1583 r1585 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 * … … 105 105 106 106 nodes, triangles, boundary, triangles_per_proc, quantities = \ 107 pmesh_divide (domain_full, nx, ny)107 pmesh_divide_steve(domain_full, nx, ny) 108 108 109 109 rect = array(domain_full.xy_extent, Float) … … 146 146 147 147 domain.initialise_visualiser(rect=rect,scale_z =0.1) 148 #domain.initialise_visualiser(rect=rect) 148 149 domain.visualise_color_stage = True 149 150 domain.default_order = 1 … … 156 157 domain.set_boundary( {'outflow': R, 'inflow': R, 'inner':R, 'exterior': R, 'open':R} ) 157 158 158 print quantities.keys() 159 159 160 domain.set_quantity('stage', quantities['stage']) 160 161 domain.set_quantity('elevation', quantities['elevation']) … … 163 164 # Evolution 164 165 t0 = time.time() 165 domain.visualise = True 166 167 print 'Processor %d No of elements %d'%(domain.processor,domain.number_of_elements) 166 168 yieldstep = 10.0 167 finaltime = 1000.0169 finaltime = 500.0 168 170 169 171 #yieldstep = 10 … … 173 175 if myid == 0: 174 176 domain.write_time() 175 print domain.quantities['stage']. centroid_values[0]177 print domain.quantities['stage'].get_integral() 176 178 177 179 if myid == 0: -
inundation/ga/storm_surge/pyvolution/netherlands.py
r1510 r1585 9 9 # Module imports 10 10 # 11 import rpdb 12 rpdb.set_active() 13 11 14 from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\ 12 15 Transmissive_boundary, Constant_height, Constant_stage … … 158 161 159 162 163 160 164 for t in domain.evolve(yieldstep = 0.1, finaltime = 15.0): 161 165 domain.write_time() 166 rpdb.set_active() 162 167 #domain.visualiser.scale_z = 1.0 163 168 #domain.visualiser.update_quantity_color('xmomentum',scale_z = 4.0)
Note: See TracChangeset
for help on using the changeset viewer.