Ignore:
Timestamp:
Aug 28, 2009, 2:34:39 PM (15 years ago)
Author:
steve
Message:

Concentrating code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga_parallel/parallel_shallow_water.py

    r7400 r7447  
    2222
    2323
    24 from anuga.shallow_water.shallow_water_domain import *
     24from anuga.interface import Domain
    2525
    2626
     
    5252        N = len(self) # number_of_triangles
    5353
    54 #        self.processor = pypar.rank()
    55 #        self.numproc   = pypar.size()
    56 #
    57 #        # Setup Communication Buffers
    58 #        self.nsys = 3
    59 #        for key in full_send_dict:
    60 #            buffer_shape = full_send_dict[key][0].shape[0]
    61 #            full_send_dict[key].append(num.zeros( (buffer_shape,self.nsys) ,num.loat))
    62 #
    63 #
    64 #        for key in ghost_recv_dict:
    65 #            buffer_shape = ghost_recv_dict[key][0].shape[0]
    66 #            ghost_recv_dict[key].append(num.zeros( (buffer_shape,self.nsys) ,num.float))
    67 #
    68 #        self.full_send_dict  = full_send_dict
    69         self.ghost_recv_dict = ghost_recv_dict
    7054
    7155        # Buffers for synchronisation of timesteps
     
    7357        self.global_timestep = num.zeros(1, num.float)
    7458
    75         self.local_timesteps = num.zeros(self.numproc, num.loat)
     59        self.local_timesteps = num.zeros(self.numproc, num.float)
    7660
    7761
     
    150134
    151135        import time
     136
    152137        #Compute minimal timestep across all processes
    153138        self.local_timestep[0] = self.flux_timestep
     
    167152                for i in range(1, self.numproc):
    168153                    pypar.receive(i,
    169                                   buffer=self.local_timestep,
    170                                   bypass=True)
     154                                  buffer=self.local_timestep)
    171155
    172156                    if self.local_timestep[0] < self.global_timestep[0]:
     
    174158            else:
    175159                pypar.send(self.local_timestep, 0,
    176                            use_buffer=True, bypass=True)
     160                           use_buffer=True)
    177161
    178162
     
    187171        self.communication_broadcast_time += time.time()-t0
    188172
    189         #old_timestep = self.flux_timestep
     173        old_timestep = self.flux_timestep
    190174        self.flux_timestep = self.global_timestep[0]
    191175        #print 'Flux Timestep %15.5e %15.5e P%d_%d' %(self.flux_timestep, old_timestep, self.processor, self.numproc)
     
    209193        # the separate processors
    210194
    211 
    212         from Numeric import take,put
     195        import numpy as num
    213196        import time
    214197        t0 = time.time()
     
    227210                            #print 'Send',i,q
    228211                            Q_cv =  self.quantities[q].centroid_values
    229                             Xout[:,i] = take(Q_cv, Idf)
    230 
    231                         pypar.send(Xout, send_proc,
    232                                    use_buffer=True, bypass = True)
     212                            Xout[:,i] = num.take(Q_cv, Idf)
     213
     214                        pypar.send(Xout, int(send_proc), use_buffer=True)
    233215
    234216
     
    238220
    239221                    Idg = self.ghost_recv_dict[iproc][0]
    240                     X = self.ghost_recv_dict[iproc][2]
    241 
    242                     X = pypar.receive(iproc, buffer=X, bypass = True)
     222                    X   = self.ghost_recv_dict[iproc][2]
     223
     224                    X = pypar.receive(int(iproc), buffer=X)
    243225
    244226                    for i, q in enumerate(self.conserved_quantities):
    245227                        #print 'Receive',i,q
    246228                        Q_cv =  self.quantities[q].centroid_values
    247                         put(Q_cv, Idg, X[:,i])
     229                        num.put(Q_cv, Idg, X[:,i])
    248230
    249231        #local update of ghost cells
     
    262244                #print 'LOCAL SEND RECEIVE',i,q
    263245                Q_cv =  self.quantities[q].centroid_values
    264                 put(Q_cv,     Idg, take(Q_cv,    Idf))
     246                num.put(Q_cv, Idg, num.take(Q_cv, Idf))
    265247
    266248        self.communication_time += time.time()-t0
    267249
    268 '''
    269 This was removed due to not beening required to be redefined in parallel_shallow_water
    270 the original "write_time" is good... however might need some small edits to work properly
    271 with parallel- Nick and Ole April 2007
    272     def write_time(self):
    273         if self.min_timestep == self.max_timestep:
    274             print 'Processor %d/%d, Time = %.4f, delta t = %.8f, steps=%d (%d)'\
    275                   %(self.processor, self.numproc,
    276                     self.time, self.min_timestep, self.number_of_steps,
    277                     self.number_of_first_order_steps)
    278         elif self.min_timestep > self.max_timestep:
    279             print 'Processor %d/%d, Time = %.4f, steps=%d (%d)'\
    280                   %(self.processor, self.numproc,
    281                     self.time, self.number_of_steps,
    282                     self.number_of_first_order_steps)
    283         else:
    284             print 'Processor %d/%d, Time = %.4f, delta t in [%.8f, %.8f], steps=%d (%d)'\
    285                   %(self.processor, self.numproc,
    286                     self.time, self.min_timestep,
    287                     self.max_timestep, self.number_of_steps,
    288                     self.number_of_first_order_steps)
    289 '''
     250
     251## This was removed due to not beening required to be redefined in parallel_shallow_water
     252## the original "write_time" is good... however might need some small edits to work properly
     253## with parallel- Nick and Ole April 2007
     254##     def write_time(self):
     255##         if self.min_timestep == self.max_timestep:
     256##             print 'Processor %d/%d, Time = %.4f, delta t = %.8f, steps=%d (%d)'\
     257##                   %(self.processor, self.numproc,
     258##                     self.time, self.min_timestep, self.number_of_steps,
     259##                     self.number_of_first_order_steps)
     260##         elif self.min_timestep > self.max_timestep:
     261##             print 'Processor %d/%d, Time = %.4f, steps=%d (%d)'\
     262##                   %(self.processor, self.numproc,
     263##                     self.time, self.number_of_steps,
     264##                     self.number_of_first_order_steps)
     265##         else:
     266##             print 'Processor %d/%d, Time = %.4f, delta t in [%.8f, %.8f], steps=%d (%d)'\
     267##                   %(self.processor, self.numproc,
     268##                     self.time, self.min_timestep,
     269##                     self.max_timestep, self.number_of_steps,
     270##                     self.number_of_first_order_steps)
     271
    290272
    291273# commented out on the 7/11/06
Note: See TracChangeset for help on using the changeset viewer.