Ignore:
Timestamp:
Sep 24, 2010, 5:56:21 PM (14 years ago)
Author:
steve
Message:

fixed up pypar_available

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga_parallel/parallel_meshes.py

    r8022 r8026  
    1717import numpy as num
    1818
    19 from anuga_parallel.parallel_abstraction import pypar_available
    20 import pypar
    21 
    2219from anuga.config import epsilon
    2320
    2421
    25 if pypar_available
     22from parallel_api import distribute
     23from parallel_api import myid, numprocs, get_processor_name
     24from parallel_api import send, receive
     25from parallel_api import pypar_available, barrier, finalize
     26
    2627
    2728
     
    4041    """
    4142
    42     processor = pypar.rank()
    43     numproc   = pypar.size()
    44 
    45     #print 'numproc',numproc
    46     #print 'processor ',processor
    47 
    48     m_low, m_high = pypar.balance(m_g, numproc, processor)
     43
     44
     45    m_low, m_high = pypar.balance(m_g, numprocs, myid)
    4946   
    5047    n = n_g
     
    132129
    133130            if i == m-1:
    134                 if processor == numproc-1:
     131                if myid == numprocs-1:
    135132                    boundary[nt, 2] = 'right'
    136133                else:
     
    156153
    157154            if i == 0:
    158                 if processor == 0:
     155                if myid == 0:
    159156                    boundary[nt, 2] = 'left'
    160157                else:
     
    164161            elements[nt,:] = [i1,i2,i3]
    165162
    166     if numproc==1:
     163    if numprocs==1:
    167164        Idfl.extend(Idfr)
    168165        Idgr.extend(Idgl)
     
    177174        #print Idgr
    178175       
    179         full_send_dict[processor]  = [Idfl, Idfl]
    180         ghost_recv_dict[processor] = [Idgr, Idgr]
    181 
    182         #print  full_send_dict[processor]
    183         #print ghost_recv_dict[processor]
    184     elif numproc == 2:
     176        full_send_dict[myid]  = [Idfl, Idfl]
     177        ghost_recv_dict[myid] = [Idgr, Idgr]
     178
     179
     180    elif numprocs == 2:
    185181        Idfl.extend(Idfr)
    186182        Idgr.extend(Idgl)
    187183        Idfl = num.array(Idfl,num.int)
    188184        Idgr = num.array(Idgr,num.int)
    189         full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl]
    190         ghost_recv_dict[(processor-1)%numproc] = [Idgr, Idgr]
     185        full_send_dict[(myid-1)%numprocs]  = [Idfl, Idfl]
     186        ghost_recv_dict[(myid-1)%numprocs] = [Idgr, Idgr]
    191187    else:
    192188        Idfl = num.array(Idfl,num.int)
     
    196192        Idgr = num.array(Idgr,num.int)
    197193
    198         full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl]
    199         ghost_recv_dict[(processor-1)%numproc] = [Idgl, Idgl]
    200         full_send_dict[(processor+1)%numproc]  = [Idfr, Idfr]
    201         ghost_recv_dict[(processor+1)%numproc] = [Idgr, Idgr]
     194        full_send_dict[(myid-1)%numprocs]  = [Idfl, Idfl]
     195        ghost_recv_dict[(myid-1)%numprocs] = [Idgl, Idgl]
     196        full_send_dict[(myid+1)%numprocs]  = [Idfr, Idfr]
     197        ghost_recv_dict[(myid+1)%numprocs] = [Idgr, Idgr]
    202198
    203199
     
    291287
    292288            if i == m-1:
    293                 if processor == numproc-1:
     289                if myid == numprocs-1:
    294290                    boundary[nt, 2] = 'right'
    295291                else:
     
    313309
    314310            if i == 0:
    315                 if processor == 0:
     311                if myid == 0:
    316312                    boundary[nt, 2] = 'left'
    317313                else:
     
    422418
    423419            if i == m-1:
    424                 if processor == numproc-1:
     420                if myid == numprocs-1:
    425421                    boundary[nt, 2] = 'right'
    426422                else:
     
    438434
    439435            if i == 0:
    440                 if processor == 0:
     436                if myid == 0:
    441437                    boundary[nt, 2] = 'left'
    442438                else:
Note: See TracChangeset for help on using the changeset viewer.