Changeset 2625


Ignore:
Timestamp:
Mar 29, 2006, 9:41:58 AM (18 years ago)
Author:
linda
Message:

Added ghost boundary layers

Location:
inundation/parallel
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • inundation/parallel/build_commun.py

    r2130 r2625  
    5959             tagmap[bkey] = counter
    6060             counter = counter+1
     61    for b in submesh["ghost_boundary"][p]:
     62         bkey = submesh["ghost_boundary"][p][b]
     63         if not tagmap.has_key(bkey):
     64             tagmap[bkey] = counter
     65             counter = counter+1
    6166    pypar.send(tagmap, p)
    6267
     
    7984    # send the array sizes so memory can be allocated
    8085
    81     setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
     86    setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    8287    setup_array[0] = len(submesh["full_nodes"][p])
    8388    setup_array[1] = len(submesh["ghost_nodes"][p])
     
    8590    setup_array[3] = len(submesh["ghost_triangles"][p])
    8691    setup_array[4] = len(submesh["full_boundary"][p])
    87     setup_array[5] = len(submesh["ghost_commun"][p])
    88     setup_array[6] = len(flat_full_commun)
     92    setup_array[5] = len(submesh["ghost_boundary"][p])
     93    setup_array[6] = len(submesh["ghost_commun"][p])
     94    setup_array[7] = len(flat_full_commun)
    8995
    9096    pypar.send(setup_array, p)
     
    105111    for b in submesh["full_boundary"][p]:
    106112        bc.append([b[0], b[1], tagmap[submesh["full_boundary"][p][b]]])
     113    pypar.send(bc, p, use_buffer=True)
     114    bc = []
     115    for b in submesh["ghost_boundary"][p]:
     116        bc.append([b[0], b[1], tagmap[submesh["ghost_boundary"][p][b]]])
    107117    pypar.send(bc, p, use_buffer=True)
    108118
     
    150160   
    151161    tagmap = pypar.receive(p)
     162    itagmap = {}
     163    for t in tagmap:
     164        itagmap[tagmap[t]]=t
    152165
    153166    # receive the quantities key information
     
    165178    # recieve information about the array sizes
    166179
    167     setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
     180    setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    168181    setup_array = pypar.receive(p, setup_array)
    169182
     
    201214    bnd_c = pypar.receive(p, bc)
    202215
    203     itagmap = {}
    204     for t in tagmap:
    205         itagmap[tagmap[t]]=t
    206 
    207216    submesh_cell["full_boundary"] = {}
    208217    for b in bnd_c:
    209218        submesh_cell["full_boundary"][b[0],b[1]]=itagmap[b[2]]
    210219
     220    # receive the ghost boundary
     221
     222    no_ghost_boundary = setup_array[5]
     223    bc = []
     224    for i in range(no_ghost_boundary):
     225        bc.append([0.0, 0.0, 0.0])
     226    bnd_c = pypar.receive(p, bc)
     227
     228    submesh_cell["ghost_boundary"] = {}
     229    for b in bnd_c:
     230        submesh_cell["ghost_boundary"][b[0],b[1]]=itagmap[b[2]]
     231
    211232    # receive the ghost communication pattern
    212233
    213     no_ghost_commun = setup_array[5]
     234    no_ghost_commun = setup_array[6]
    214235    ghost_commun = zeros((no_ghost_commun, 2), Int)
    215236    submesh_cell["ghost_commun"] = pypar.receive(p, ghost_commun)
     
    217238    # receive the full communication pattern
    218239
    219     no_full_commun = setup_array[6]
     240    no_full_commun = setup_array[7]
    220241    full_commun = []
    221242    for i in range(no_full_commun):
  • inundation/parallel/build_local.py

    r2130 r2625  
    4040#########################################################
    4141
    42 def build_local_GA(nodes, triangles):
     42def build_local_GA(nodes, triangles, boundaries, tri_index):
    4343
    4444    Nnodes =len(nodes)
     
    6565    GAtriangles[:,1] = take(index, triangles[:,1])
    6666    GAtriangles[:,2] = take(index, triangles[:,2])
    67    
     67
     68    # Change the triangle numbering in the boundaries
     69
     70    GAboundaries = {}
     71    for b in boundaries:
     72        GAboundaries[tri_index[b[0]], b[1]] = boundaries[b]
     73       
    6874    del (index)
    69 
    70     return GAnodes, GAtriangles
     75   
     76    return GAnodes, GAtriangles, GAboundaries
    7177
    7278
     
    171177    triangles = concatenate((submesh["full_triangles"], gtri))
    172178
    173     # Renumber the boundary edges to correspond to the new
    174     # triangle numbering
    175 
    176     GAboundary = {}
    177     for b in submesh["full_boundary"]:
    178         GAboundary[b[0]-lower_t,b[1]] = submesh["full_boundary"][b]
     179    # Combine the full boundaries and ghost boundaries
     180
     181    boundaries = submesh["full_boundary"]
     182    for b in submesh["ghost_boundary"]:
     183        boundaries[b]=submesh["ghost_boundary"][b]
    179184
    180185    # Make note of the new triangle numbers, including the ghost
     
    190195    for i in range(len(submesh["ghost_triangles"])):
    191196        index[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t
    192 
     197   
    193198    # Change the node numbering (and update the numbering in the
    194199    # triangles)
    195200
    196     [GAnodes, GAtriangles] = build_local_GA(nodes, triangles)
     201    [GAnodes, GAtriangles, GAboundary] = build_local_GA(nodes, triangles, boundaries, index)
    197202
    198203    # Extract the local quantities
  • inundation/parallel/build_submesh.py

    r2130 r2625  
    113113# be added to the node list for the current processor
    114114#
    115 #  *) The boundary edges for the ghost triangles are
    116 # ignored.
    117115#
    118116# -------------------------------------------------------
     
    206204    return subnodes, subtriangles
    207205
     206#########################################################
     207#
     208# Find the edges of the ghost trianlges that do not
     209# have a neighbour in the current cell. These are
     210# treated as a special type of boundary edge.
     211#
     212#  *) Given the ghost triangles in a particular
     213# triangle, use the mesh to find its neigbours. If
     214# the neighbour is not in the processor set it to
     215# be a boundary edge
     216#
     217#  *) The vertices in the ghost triangles must also
     218# be added to the node list for the current processor
     219#
     220#  *) The boundary edges for the ghost triangles are
     221# ignored.
     222#
     223# -------------------------------------------------------
     224#
     225#  *) The type assigned to the ghost boundary edges is 'ghost'
     226#
     227#  *)  The boundary information is returned as a directorier
     228# with the key = (triangle id, edge no) and the values
     229# assigned to the key is 'ghost'
     230#
     231#
     232#########################################################
     233def is_in_processor(ghost_list, tlower, tupper, n):
     234    return (n in ghost_list) or (tlower <= n and tupper >= n)
     235
     236def ghost_bnd_layer(ghosttri, tlower, tupper, mesh, p):
     237
     238    ghost_list = []
     239    subboundary = {}
     240       
     241    for t in ghosttri:
     242        ghost_list.append(t[0])
     243
     244    for t in ghosttri:
     245        n = mesh.neighbours[t[0], 0]
     246        if not is_in_processor(ghost_list, tlower, tupper, n):
     247            subboundary[t[0], 0] = 'ghost'
     248
     249        n = mesh.neighbours[t[0], 1]
     250        if not is_in_processor(ghost_list, tlower, tupper, n):
     251            subboundary[t[0], 1] = 'ghost'
     252
     253        n = mesh.neighbours[t[0], 2]
     254        if not is_in_processor(ghost_list, tlower, tupper, n):
     255            subboundary[t[0], 2] = 'ghost'
     256   
     257    return subboundary
    208258
    209259#########################################################
     
    318368# updates must also be built.
    319369#
     370#  *) Assumes that full triangles, nodes etc have already
     371# been found and stored in submesh
     372#
    320373#  *) See the documentation for ghost_layer,
    321374# ghost_commun_pattern and full_commun_pattern
     
    327380# ghost_commun_pattern and full_commun_pattern
    328381#
    329 #  *) The ghost_triangles, ghost_nodes, ghost_commun and
    330 # full_commun is added to submesh
     382#  *) The ghost_triangles, ghost_nodes, ghost_boundary,
     383# ghost_commun and full_commun is added to submesh
    331384#########################################################
    332385
     
    338391    ghost_nodes = []
    339392    ghost_commun = []
     393    ghost_bnd = []
    340394
    341395    # Loop over the processors
     
    354408        ghost_nodes.append(subnodes)
    355409
     410        # Find the boundary layer formed by the ghost triangles
     411       
     412        subbnd = ghost_bnd_layer(subtri, tupper, tlower, mesh, p)
     413        ghost_bnd.append(subbnd)
     414       
    356415        # Build the communication pattern for the ghost nodes
    357416
     
    369428    submesh["ghost_triangles"] = ghost_triangles
    370429    submesh["ghost_commun"] = ghost_commun
    371 
     430    submesh["ghost_boundary"] = ghost_bnd
     431   
    372432    # Build the communication pattern for the full triangles
    373433
     
    449509#  *) A dictionary containing the full_triangles,
    450510# full_nodes, full_boundary, ghost_triangles, ghost_nodes,
    451 # ghost_commun and full_commun is returned.
     511# ghost_boundary, ghost_commun and full_commun is returned.
    452512#
    453513#########################################################
     
    489549#  *) A dictionary containing the full_triangles,
    490550# full_nodes, full_boundary, ghost_triangles, ghost_nodes,
    491 # ghost_commun and full_commun belonging to processor zero
    492 # are returned.
     551# ghost_boundary, ghost_commun and full_commun belonging
     552# to processor zero are returned.
    493553#
    494554#########################################################
     
    501561    submesh_cell["ghost_triangles"] = submesh["ghost_triangles"][0]
    502562    submesh_cell["full_boundary"] = submesh["full_boundary"][0]
     563    submesh_cell["ghost_boundary"] = submesh["ghost_boundary"][0]
    503564    submesh_cell["ghost_commun"] = submesh["ghost_commun"][0]
    504565    submesh_cell["full_commun"] = submesh["full_commun"][0]
  • inundation/parallel/parallel_meshes.py

    r1607 r2625  
    1212Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou
    1313Geoscience Australia, 2005
     14
     15Modified by Linda Stals, March 2006, to include ghost boundaries
     16
    1417"""
    1518
     
    124127
    125128            if i == m-1:
    126                 boundary[nt, 2] = 'right'
     129                if processor == numproc-1:
     130                    boundary[nt, 2] = 'right'
     131                else:
     132                    boundary[nt, 2] = 'ghost'
     133       
    127134            if j == 0:
    128135                boundary[nt, 1] = 'bottom'
     
    144151
    145152            if i == 0:
    146                 boundary[nt, 2] = 'left'
     153                if processor == 0:
     154                    boundary[nt, 2] = 'left'
     155                else:
     156                    boundary[nt, 2] = 'ghost'
    147157            if j == n-1:
    148158                boundary[nt, 1] = 'top'
     
    263273
    264274            if i == m-1:
    265                 boundary[nt, 2] = 'right'
     275                if processor == numproc-1:
     276                    boundary[nt, 2] = 'right'
     277                else:
     278                    boundary[nt, 2] = 'ghost'
    266279            if j == 0:
    267280                boundary[nt, 1] = 'bottom'
     
    282295
    283296            if i == 0:
    284                 boundary[nt, 2] = 'left'
     297                if processor == 0:
     298                    boundary[nt, 2] = 'left'
     299                else:
     300                    boundary[nt, 2] = 'ghost'
    285301            if j == n-1:
    286302                boundary[nt, 1] = 'top'
     
    391407
    392408            if i == m-1:
    393                 boundary[nt, 2] = 'right'
     409                if processor == numproc-1:
     410                    boundary[nt, 2] = 'right'
     411                else:
     412                    boundary[nt, 2] = 'ghost'
    394413            if j == 0:
    395414                boundary[nt, 1] = 'bottom'
     
    404423
    405424            if i == 0:
    406                 boundary[nt, 2] = 'left'
     425                if processor == 0:
     426                    boundary[nt, 2] = 'left'
     427                else:
     428                    boundary[nt, 2] = 'ghost'
    407429            if j == n-1:
    408430                boundary[nt, 1] = 'top'
  • inundation/parallel/run_parallel_advection.py

    r2090 r2625  
    55sys.path.append('..'+sep+'pyvolution')
    66
     7
    78#========================================================================
     9
     10import pypar
     11
    812from config import g, epsilon
    913from Numeric import allclose, array, zeros, ones, Float
     
    1418from parallel_advection import Transmissive_boundary, Dirichlet_boundary
    1519
    16 import pypar
    17 
    1820numprocs = pypar.size()
    1921myid = pypar.rank()
    2022processor_name = pypar.Get_processor_name()
    21 
    2223
    2324
     
    4142#Boundaries
    4243T = Transmissive_boundary(domain)
    43 D = Dirichlet_boundary(array([1.0]))
     44D = Dirichlet_boundary(array([1.0])) 
    4445
    4546domain.default_order = 2
    4647
    47 
    48 domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T} )
     48domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T, 'ghost': None} )
    4949domain.check_integrity()
    5050
  • inundation/parallel/run_parallel_merimbula.py

    r2152 r2625  
    8787    # read in the test files
    8888
    89     filename = 'test-100.tsh'
    90 #    filename = 'merimbula_10785.tsh'
     89#    filename = 'test-100.tsh'
     90    filename = 'merimbula_10785.tsh'
    9191    nx = numprocs
    9292    ny = 1
     
    9595
    9696    domain_full = pmesh_to_domain_instance(filename, Advection_Domain)
    97     domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))
    98 #    domain.set_quantity('stage', Set_Stage(756000.0,756500.0,4.0))
     97#    domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))
     98    domain_full.set_quantity('stage', Set_Stage(756000.0,756500.0,4.0))
    9999
    100100    nodes, triangles, boundary, triangles_per_proc, quantities  =\
    101101            pmesh_divide(domain_full, nx, ny)
    102 
     102   
    103103    # subdivide the mesh
    104104    rect = array(domain_full.xy_extent, Float)
    105 
    106     print rect
    107105
    108106    rect = array(rect, Float)
     
    128126             rec_submesh(0)
    129127
    130 #if myid == 0:
    131 #    print 'ghost'
    132 #    print ghost_recv_dict
    133 #
    134 #if myid == 0:
    135 #    print 'full'
    136 #    print full_send_dict
    137 
    138 
    139128pypar.broadcast(rect,0)
    140 print rect
    141129
    142130domain = Parallel_Domain(points, vertices, boundary,
     
    150138
    151139T = Transmissive_boundary(domain)
    152 R = Reflective_boundary(domain)
    153 domain.set_boundary( {'outflow': R, 'inflow': R, 'inner':R, 'exterior': R, 'open':R} )
     140#R = Reflective_boundary(domain)
     141domain.set_boundary( {'outflow': T, 'inflow': T, 'inner':T, 'exterior': T, 'open':T, 'ghost':None} )
    154142
    155143
     
    170158
    171159
     160from norms import linf_norm
    172161
    173162#yieldstep = 1
     163#finaltime = 4000
     164
    174165yieldstep = 1000
    175166finaltime = 50000
    176 # finaltime = 4000
     167
    177168for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    178169    if myid == 0:
    179170        domain.write_time()
     171##    Stage = domain.quantities['stage']
     172##    max_stage = max(max(Stage.edge_values))
     173##    print max_stage
     174##    if max_stage > 4.0:
     175##        print "######################", max_stage
    180176
    181177if myid == 0:
  • inundation/parallel/run_parallel_sw_rectangle.py

    r2198 r2625  
    4646N = M*numprocs
    4747
    48 #N = M = 250
    49 
    5048if myid == 0:
    5149    print 'N == %d' %N
    5250
    5351points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
    54     parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g=1.0)
     52    parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g = 1.0)
    5553
    5654
     
    8482
    8583
    86 domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
     84domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R, 'ghost': None} )
    8785domain.check_integrity()
    8886
Note: See TracChangeset for help on using the changeset viewer.