Changeset 1585


Ignore:
Timestamp:
Jul 6, 2005, 9:55:40 PM (19 years ago)
Author:
steve
Message:

Better partitioning of meribula data set

Location:
inundation/ga/storm_surge
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/parallel/pmesh_divide.py

    r1580 r1585  
    130130
    131131    # find the number triangles
    132    
     132
    133133    N = len(tri_index)
    134134
     
    137137    index = zeros(N, Int)
    138138    q_reord = {}
    139    
     139
    140140    # find the new ordering of the triangles
    141    
     141
    142142    for i in range(N):
    143143        bin = tri_index[i][0]
    144         bin_off_set = tri_index[i][1]       
     144        bin_off_set = tri_index[i][1]
    145145        index[i] = proc_sum[bin]+bin_off_set
    146146
    147147    # reorder each quantity according to the new ordering
    148    
     148
    149149    for k in quantities:
    150150        q_reord[k] = zeros((N, 3), Float)
     
    153153
    154154    del index
    155    
     155
    156156    return q_reord
    157    
     157
    158158def pmesh_divide(domain, n_x = 1, n_y = 1):
    159159
     
    231231
    232232    quantities = reorder(domain.quantities, tri_index, proc_sum)
    233                          
     233
    234234    # extract the node list
    235235    nodes = domain.coordinates.copy()
     
    237237    return nodes, triangles, boundary, triangles_per_proc, quantities
    238238
     239def 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  
    5959# mesh partition routines
    6060
    61 from pmesh_divide import pmesh_divide
     61from pmesh_divide import pmesh_divide, pmesh_divide_steve
    6262from build_submesh import *
    6363from build_local import *
     
    105105
    106106    nodes, triangles, boundary, triangles_per_proc, quantities = \
    107          pmesh_divide(domain_full, nx, ny)
     107         pmesh_divide_steve(domain_full, nx, ny)
    108108
    109109    rect = array(domain_full.xy_extent, Float)
     
    146146
    147147domain.initialise_visualiser(rect=rect,scale_z =0.1)
     148#domain.initialise_visualiser(rect=rect)
    148149domain.visualise_color_stage = True
    149150domain.default_order = 1
     
    156157domain.set_boundary( {'outflow': R, 'inflow': R, 'inner':R, 'exterior': R, 'open':R} )
    157158
    158 print quantities.keys()
     159
    159160domain.set_quantity('stage', quantities['stage'])
    160161domain.set_quantity('elevation', quantities['elevation'])
     
    163164# Evolution
    164165t0 = time.time()
    165 domain.visualise = True
     166
     167print 'Processor %d No of elements %d'%(domain.processor,domain.number_of_elements)
    166168yieldstep = 10.0
    167 finaltime = 1000.0
     169finaltime = 500.0
    168170
    169171#yieldstep = 10
     
    173175    if myid == 0:
    174176        domain.write_time()
    175         print domain.quantities['stage'].centroid_values[0]
     177        print domain.quantities['stage'].get_integral()
    176178
    177179if myid == 0:
  • inundation/ga/storm_surge/pyvolution/netherlands.py

    r1510 r1585  
    99# Module imports
    1010#
     11import rpdb
     12rpdb.set_active()
     13
    1114from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
    1215     Transmissive_boundary, Constant_height, Constant_stage
     
    158161
    159162
     163
    160164for t in domain.evolve(yieldstep = 0.1, finaltime = 15.0):
    161165    domain.write_time()
     166    rpdb.set_active()
    162167    #domain.visualiser.scale_z = 1.0
    163168    #domain.visualiser.update_quantity_color('xmomentum',scale_z = 4.0)
Note: See TracChangeset for help on using the changeset viewer.