Ignore:
Timestamp:
Dec 8, 2005, 8:29:24 AM (19 years ago)
Author:
linda
Message:

Modified the parallel code to agree with the python style files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/parallel/build_local.py

    r2091 r2130  
    1818#########################################################
    1919
    20 from mesh import *
    21 from Numeric import *
     20from Numeric import  zeros, Float, Int, concatenate, \
     21     take, arrayrange, put, sort, compress, equal
     22
    2223
    2324#########################################################
     
    4445    Ntriangles = len(triangles)
    4546   
    46     # extract the nodes (using the local ID)
     47    # Extract the nodes (using the local ID)
    4748   
    4849    GAnodes = take(nodes, (1, 2), 1)
    4950
    50     # build a global ID to local ID mapping
     51    # Build a global ID to local ID mapping
    5152
    5253    NGlobal = 0
     
    5556            NGlobal = nodes[i][0]
    5657    index = zeros(int(NGlobal)+1, Int)
    57     put(index, take(nodes, (0,), 1).astype(Int), arrayrange(Nnodes))
     58    put(index, take(nodes, (0,), 1).astype(Int), \
     59        arrayrange(Nnodes))
    5860       
    59     # change the global IDs in the triangles to the local IDs
     61    # Change the global IDs in the triangles to the local IDs
    6062
    6163    GAtriangles = zeros((Ntriangles, 3), Int)
     
    9496def build_local_commun(index, ghostc, fullc, nproc):
    9597
    96     # initialise
     98    # Initialise
    9799
    98100    full_send = {}
    99101    ghost_recv = {}
    100102
    101     # build the ghost_recv dictionary (sort the
     103    # Build the ghost_recv dictionary (sort the
    102104    # information by the global numbering)
    103105   
     
    112114            ghost_recv[c][0] = take(index, d)
    113115           
    114     # build a temporary copy of the full_send dictionary
     116    # Build a temporary copy of the full_send dictionary
    115117    # (this version allows the information to be stored
    116118    # by the global numbering)
     
    122124            if not tmp_send.has_key(neigh):
    123125                tmp_send[neigh] = []
    124             tmp_send[neigh].append([global_id, index[global_id]])
    125 
    126     # extract the full send information and put it in the form
     126            tmp_send[neigh].append([global_id, \
     127                                    index[global_id]])
     128
     129    # Extract the full send information and put it in the form
    127130    # required for the full_send dictionary
    128131
     
    158161def build_local_mesh(submesh, lower_t, upper_t, nproc):
    159162
    160     # combine the full nodes and ghost nodes
    161 
    162     nodes = concatenate((submesh["full_nodes"], submesh["ghost_nodes"]))
    163    
    164     # combine the full triangles and ghost triangles
     163    # Combine the full nodes and ghost nodes
     164
     165    nodes = concatenate((submesh["full_nodes"], \
     166                         submesh["ghost_nodes"]))
     167   
     168    # Combine the full triangles and ghost triangles
    165169
    166170    gtri =  take(submesh["ghost_triangles"],(1, 2, 3),1)
    167171    triangles = concatenate((submesh["full_triangles"], gtri))
    168172
    169     # renumber the boundary edges to correspond to the new
     173    # Renumber the boundary edges to correspond to the new
    170174    # triangle numbering
    171175
    172176    GAboundary = {}
    173177    for b in submesh["full_boundary"]:
    174         GAboundary[b[0]-lower_t,b[1]]=submesh["full_boundary"][b]
    175 
    176     # make note of the new triangle numbers, including the ghost
     178        GAboundary[b[0]-lower_t,b[1]] = submesh["full_boundary"][b]
     179
     180    # Make note of the new triangle numbers, including the ghost
    177181    # triangles
    178182
     
    187191        index[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t
    188192
    189     # change the node numbering (and update the numbering in the
     193    # Change the node numbering (and update the numbering in the
    190194    # triangles)
    191195
    192196    [GAnodes, GAtriangles] = build_local_GA(nodes, triangles)
    193197
    194     # extract the local quantities
     198    # Extract the local quantities
    195199   
    196200    quantities ={}
     
    202206        quantities[k][Nf:Nf+Ng] = submesh["ghost_quan"][k]
    203207                             
    204     # change the communication pattern into a form needed by
    205     # the parallel_advection.py file
     208    # Change the communication pattern into a form needed by
     209    # the parallel_adv
    206210
    207211    gcommun = submesh["ghost_commun"]
    208212    fcommun = submesh["full_commun"]
    209     [ghost_rec, full_send] = build_local_commun(index, gcommun, fcommun, nproc)
    210 
    211     # clean up before exiting
     213    [ghost_rec, full_send] = \
     214                build_local_commun(index, gcommun, fcommun, nproc)
     215
     216    # Clean up before exiting
    212217
    213218    del(index)
    214219
    215     return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, full_send
     220    return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \
     221           full_send
Note: See TracChangeset for help on using the changeset viewer.