Changeset 1520


Ignore:
Timestamp:
Jun 20, 2005, 4:53:05 PM (19 years ago)
Author:
steve
Message:
 
Location:
inundation/ga/storm_surge
Files:
6 edited

Legend:

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

    r1500 r1520  
    11#########################################################
    2 #   
     2#
    33# Handle the communication between the host machine
    44# (processor 0) and the processors. The host machine is
    5 # responsible for the doing the initial grid partitioning. 
     5# responsible for the doing the initial grid partitioning.
    66#
    77# The routines given below should be moved to the
     
    1818#########################################################
    1919
     20import logging, logging.config
     21logger = logging.getLogger('parallel')
     22logger.setLevel(logging.WARNING)
     23
     24try:
     25    logging.config.fileConfig('log.ini')
     26except:
     27    pass
     28
    2029
    2130import sys
     
    3847
    3948def send_submesh(submesh, triangles_per_proc, tagmap, p):
    40    
     49
    4150    # send the number of triangles per processor
    42    
    43     print "pypar send triangles per proc",p 
     51
     52    print "pypar send triangles per proc",p
    4453    pypar.send(triangles_per_proc, p, use_buffer=True)
    4554
     
    4756
    4857    flat_full_commun = []
     58
    4959
    5060    for c in submesh["full_commun"][p]:
    5161        for i in range(len(submesh["full_commun"][p][c])):
    52             flat_full_commun.append([c,submesh["full_commun"][p][c][i]]) 
    53    
     62            flat_full_commun.append([c,submesh["full_commun"][p][c][i]])
     63
    5464    # send the array sizes so memory can be allocated
    55    
     65
    5666    setup_array = [0, 0, 0, 0, 0, 0, 0]
    5767    setup_array[0] = len(submesh["full_nodes"][p])
     
    6474    print "pypar send setup_array", p
    6575    pypar.send(setup_array, p)
    66    
     76
    6777    # send the nodes
    68    
     78
    6979    print "pypar send full_nodes", p
    7080    pypar.send(submesh["full_nodes"][p], p, use_buffer=True)
     
    7282    print "pypar send ghost_nodes", p
    7383    pypar.send(submesh["ghost_nodes"][p], p, use_buffer=True)
    74    
     84
    7585    # send the triangles
    76    
     86
    7787    print "pypar send full_triangles", p
    7888    pypar.send(submesh["full_triangles"][p], p, use_buffer=True)
     
    8292
    8393    # send the boundary (is it quicker to send as an array?)
    84    
     94
    8595    print "pypar send full_boundary", p
    8696    bc = []
     
    93103    print "pypar send ghost_commun", p, len(submesh["ghost_commun"][p])
    94104    pypar.send(submesh["ghost_commun"][p], p, use_buffer=True)
    95    
     105
    96106    print "pypar send full_commun", p, len(flat_full_commun)
    97107    pypar.send(flat_full_commun, p, use_buffer=True)
     
    117127
    118128def rec_submesh(tagmap, p):
    119    
     129
    120130    from Numeric import zeros, Float, Int
    121131
     
    124134
    125135    submesh_cell = {}
    126    
     136
    127137    # receive the number of triangles per processor
    128    
     138
    129139    triangles_per_proc = []
    130140    for i in range(numproc):
     
    133143    print "pypar rec triangles_per_proc", p
    134144    triangles_per_proc = pypar.receive(p, triangles_per_proc)
    135    
     145
    136146    # recieve information about the array sizes
    137    
     147
    138148    setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    139149    print "pypar rec setup_array", p
     
    141151
    142152    # receive the full nodes
    143    
     153
    144154    no_full_nodes = setup_array[0]
    145155    full_nodes = []
     
    150160
    151161    # receive the ghost nodes
    152    
     162
    153163    no_ghost_nodes = setup_array[1]
    154164    ghost_nodes = []
     
    157167    print "pypar rec ghost_nodes ", p
    158168    submesh_cell["ghost_nodes"] = pypar.receive(p, ghost_nodes)
    159  
     169
    160170    # receive the full triangles
    161    
     171
    162172    no_full_triangles = setup_array[2]
    163173    full_triangles = []
     
    168178
    169179    # receive the ghost triangles
    170    
     180
    171181    no_ghost_triangles = setup_array[3]
    172182    ghost_triangles = []
     
    175185    print "pypar rec ghost_triangles", p
    176186    submesh_cell["ghost_triangles"] = pypar.receive(p, ghost_triangles)
    177    
     187
    178188    # receive the full boundary
    179    
     189
    180190    print "pypar rec full_boundary", p
    181191    no_full_boundary = setup_array[4]
     
    188198    for t in tagmap:
    189199        itagmap[tagmap[t]]=t
    190        
     200
    191201    submesh_cell["full_boundary"] = {}
    192202    for b in bnd_c:
     
    194204
    195205    # receive the ghost communication pattern
    196    
     206
    197207    no_ghost_commun = setup_array[5]
    198208    ghost_commun = []
     
    204214
    205215    # receive the full communication pattern
    206    
     216
    207217    no_full_commun = setup_array[6]
    208218    full_commun = []
     
    211221    print "pypar rec full_commun", p
    212222    full_commun = pypar.receive(p, full_commun)
    213    
     223
    214224    submesh_cell["full_commun"] = {}
    215225    for c in full_commun:
     
    219229
    220230    # find the full triangles assigned to this processor
    221    
     231
    222232    lower_t = 0
    223233    for i in range(myid):
     
    227237    # convert the information into a form needed by the GA
    228238    # datastructure
    229    
     239
    230240    [GAnodes, GAtriangles, boundary, ghost_rec, full_send] = build_local_mesh(submesh_cell, lower_t, upper_t, numproc)
    231  
     241
    232242    return GAnodes, GAtriangles, boundary, ghost_rec, full_send
    233243
    234244
    235 
  • inundation/ga/storm_surge/parallel/parallel_meshes.py

    r1510 r1520  
    1717
    1818
    19 def parallel_rectangular(m, n, len1=1.0, len2=1.0, origin = (0.0, 0.0)):
     19def parallel_rectangular(m_g, n_g, len1_g=1.0, len2_g=1.0, origin_g = (0.0, 0.0)):
    2020
    2121
     
    3737    numproc   = pypar.size()
    3838
    39 
    40 
    41     delta1 = float(len1)/m
    42     delta2 = float(len2)/n
     39    m_low, m_high = pypar.balance(m_g, numproc, processor)
     40
     41    n = n_g
     42    m_low  = m_low-1
     43    m_high = m_high+1
     44    m = m_high - m_low
     45
     46    delta1 = float(len1_g)/m_g
     47    delta2 = float(len2_g)/n_g
     48
     49    len1 = len1_g*float(m)/float(m_g)
     50    len2 = len2_g
     51    origin = ( origin_g[0]+float(m_low)/float(m_g)*len1_g, origin_g[1] )
     52
    4353
    4454    #Calculate number of points
     
    151161        Xf   = zeros(Idfl.shape,Float)
    152162        Xg   = zeros(Idgr.shape,Float)
    153         full_send_dict[processor]  = [Idfl, Xf]
    154         ghost_recv_dict[processor] = [Idgr, Xg]
     163        full_send_dict[processor]  = [Idfl, Idfl, Xf]
     164        ghost_recv_dict[processor] = [Idgr, Idgr, Xg]
    155165    elif numproc == 2:
    156166        Idfl.extend(Idfr)
     
    161171        Xf   = zeros(Idfl.shape,Float)
    162172        Xg   = zeros(Idgr.shape,Float)
    163         full_send_dict[(processor-1)%numproc]  = [Idfl, Xf]
    164         ghost_recv_dict[(processor-1)%numproc] = [Idgr, Xg]
     173        full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl, Xf]
     174        ghost_recv_dict[(processor-1)%numproc] = [Idgr, Idgr, Xg]
    165175    else:
    166176        Idfl = array(Idfl,Int)
  • inundation/ga/storm_surge/parallel/run_advection.py

    r1472 r1520  
     1import pdb
     2pdb.set_trace()
     3
    14import sys
    25from os import sep
     
    811from advection import *
    912from Numeric import array
     13
    1014
    1115from mesh_factory import rectangular
     
    2731D = Dirichlet_boundary(array([1.0]))
    2832
     33#turn on the visualisation
     34rect = [0.0, 0.0, 1.0, 1.0]
     35domain.initialise_visualiser(rect=rect)
     36
     37
    2938domain.default_order = 2
    3039
     
    3746for t in domain.evolve(yieldstep = 0.1, finaltime = 1.5):
    3847    domain.write_time()
     48    pdb.set_trace()
     49
  • inundation/ga/storm_surge/parallel/run_parallel_advection.py

    r1471 r1520  
    2222M = 50
    2323
    24 points, vertices, boundary, full_send_dict, ghost_recv_dict = parallel_rectangular(N, M, len1=1.0)
     24points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
     25    parallel_rectangular(N, M, len1_g=1.0)
    2526
    2627#Create advection domain with direction (1,-1)
     
    3132
    3233#turn on the visualisation
    33 domain.initialise_visualiser()
     34rect = [0.0, 0.0, 1.0, 1.0]
     35domain.initialise_visualiser(rect=rect)
    3436
    3537#Boundaries
     
    5557        return self.h*((x>self.x0)&(x<self.x1))
    5658
     59domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
     60
    5761if myid == 0:
    58     domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
    5962    import time
    6063    t0 = time.time()
    6164
    6265#Check that the boundary value gets propagated to all elements
    63 for t in domain.evolve(yieldstep = 0.5, finaltime = 3.0):
     66for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
    6467    if myid == 0:
    6568        domain.write_time()
  • inundation/ga/storm_surge/parallel/run_parallel_mesh.py

    r1510 r1520  
    6565from build_local import *
    6666from build_commun import *
     67import pdb
    6768
    6869# define the initial time step
     
    9697# if this is the host processor
    9798
     99print 'trace'
     100pdb.set_trace()
     101print 'after trace'
     102
    98103if myid == 0:
    99104
     
    115120# processor (note that the information is in the
    116121# correct form for the GA data structure
     122
    117123
    118124[points, vertices, boundary, ghost_recv_dict, full_send_dict] = rec_submesh(tagmap, 0)
  • inundation/ga/storm_surge/pyvolution-parallel/run_advection.py

    r1231 r1520  
    44from Numeric import array
    55
     6import pdb
    67from mesh_factory import rectangular
    78
     
    2627#Check that the boundary value gets propagated to all elements
    2728for t in domain.evolve(yieldstep = 0.01, finaltime = 1.5):
     29    pdb.set_trace()
    2830    domain.write_time()
Note: See TracChangeset for help on using the changeset viewer.