environment/share/doc/ipython/examples/parallel/wave2D/RectPartitioner.py
def update_internal_boundary_x_y (self, solution_array):
        """update the inner boundary with the same send/recv pattern as the MPIPartitioner"""
        nsd_ = self.nsd
        dtype = solution_array.dtype
        if nsd_!=len(self.in_lower_buffers) | nsd_!=len(self.out_lower_buffers):
            print("Buffers for communicating with lower neighbors not ready")
            return
        if nsd_!=len(self.in_upper_buffers) | nsd_!=len(self.out_upper_buffers):
            print("Buffers for communicating with upper neighbors not ready")
            return

        loc_nx = self.subd_hi_ix[0]-self.subd_lo_ix[0]
        loc_ny = self.subd_hi_ix[1]-self.subd_lo_ix[1]

        lower_x_neigh = self.lower_neighbors[0]
        upper_x_neigh = self.upper_neighbors[0]
        lower_y_neigh = self.lower_neighbors[1]
        upper_y_neigh = self.upper_neighbors[1]
        trackers = []
        flags = dict(copy=False, track=False)
        # communicate in the x-direction first
        if lower_x_neigh>-1:
            if self.slice_copy:
                self.out_lower_buffers[0] = ascontiguousarray(solution_array[1,:])
            else:
                for i in xrange(0,loc_ny+1):
                    self.out_lower_buffers[0][i] = solution_array[1,i]
            t = self.comm.west.send(self.out_lower_buffers[0], **flags)
            trackers.append(t)
            
        if upper_x_neigh>-1:
            msg = self.comm.east.recv(copy=False)
            self.in_upper_buffers[0] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[loc_nx,:] = self.in_upper_buffers[0]
                self.out_upper_buffers[0] = ascontiguousarray(solution_array[loc_nx-1,:])
            else:
                for i in xrange(0,loc_ny+1):
                    solution_array[loc_nx,i] = self.in_upper_buffers[0][i]
                    self.out_upper_buffers[0][i] = solution_array[loc_nx-1,i]
            t = self.comm.east.send(self.out_upper_buffers[0], **flags)
            trackers.append(t)
            

        if lower_x_neigh>-1:
            msg = self.comm.west.recv(copy=False)
            self.in_lower_buffers[0] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[0,:] = self.in_lower_buffers[0]
            else:
                for i in xrange(0,loc_ny+1):
                    solution_array[0,i] = self.in_lower_buffers[0][i]
        
        # communicate in the y-direction afterwards
        if lower_y_neigh>-1:
            if self.slice_copy:
                self.out_lower_buffers[1] = ascontiguousarray(solution_array[:,1])
            else:
                for i in xrange(0,loc_nx+1):
                    self.out_lower_buffers[1][i] = solution_array[i,1]
            t = self.comm.south.send(self.out_lower_buffers[1], **flags)
            trackers.append(t)
            
            
        if upper_y_neigh>-1:
            msg = self.comm.north.recv(copy=False)
            self.in_upper_buffers[1] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[:,loc_ny] = self.in_upper_buffers[1]
                self.out_upper_buffers[1] = ascontiguousarray(solution_array[:,loc_ny-1])
            else:
                for i in xrange(0,loc_nx+1):
                    solution_array[i,loc_ny] = self.in_upper_buffers[1][i]
                    self.out_upper_buffers[1][i] = solution_array[i,loc_ny-1]
            t = self.comm.north.send(self.out_upper_buffers[1], **flags)
            trackers.append(t)
            
        if lower_y_neigh>-1:
            msg = self.comm.south.recv(copy=False)
            self.in_lower_buffers[1] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[:,0] = self.in_lower_buffers[1]
            else:
                for i in xrange(0,loc_nx+1):
                    solution_array[i,0] = self.in_lower_buffers[1][i]
        
        # wait for sends to complete:
        if flags['track']:
            for t in trackers:
                t.wait()
def update_internal_boundary_x_y (self, solution_array):
        """update the inner boundary with the same send/recv pattern as the MPIPartitioner"""
        nsd_ = self.nsd
        dtype = solution_array.dtype
        if nsd_!=len(self.in_lower_buffers) | nsd_!=len(self.out_lower_buffers):
            print("Buffers for communicating with lower neighbors not ready")
            return
        if nsd_!=len(self.in_upper_buffers) | nsd_!=len(self.out_upper_buffers):
            print("Buffers for communicating with upper neighbors not ready")
            return

        loc_nx = self.subd_hi_ix[0]-self.subd_lo_ix[0]
        loc_ny = self.subd_hi_ix[1]-self.subd_lo_ix[1]

        lower_x_neigh = self.lower_neighbors[0]
        upper_x_neigh = self.upper_neighbors[0]
        lower_y_neigh = self.lower_neighbors[1]
        upper_y_neigh = self.upper_neighbors[1]
        trackers = []
        flags = dict(copy=False, track=False)
        # communicate in the x-direction first
        if lower_x_neigh>-1:
            if self.slice_copy:
                self.out_lower_buffers[0] = ascontiguousarray(solution_array[1,:])
            else:
                for i in xrange(0,loc_ny+1):
                    self.out_lower_buffers[0][i] = solution_array[1,i]
            t = self.comm.west.send(self.out_lower_buffers[0], **flags)
            trackers.append(t)
            
        if upper_x_neigh>-1:
            msg = self.comm.east.recv(copy=False)
            self.in_upper_buffers[0] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[loc_nx,:] = self.in_upper_buffers[0]
                self.out_upper_buffers[0] = ascontiguousarray(solution_array[loc_nx-1,:])
            else:
                for i in xrange(0,loc_ny+1):
                    solution_array[loc_nx,i] = self.in_upper_buffers[0][i]
                    self.out_upper_buffers[0][i] = solution_array[loc_nx-1,i]
            t = self.comm.east.send(self.out_upper_buffers[0], **flags)
            trackers.append(t)
            

        if lower_x_neigh>-1:
            msg = self.comm.west.recv(copy=False)
            self.in_lower_buffers[0] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[0,:] = self.in_lower_buffers[0]
            else:
                for i in xrange(0,loc_ny+1):
                    solution_array[0,i] = self.in_lower_buffers[0][i]
        
        # communicate in the y-direction afterwards
        if lower_y_neigh>-1:
            if self.slice_copy:
                self.out_lower_buffers[1] = ascontiguousarray(solution_array[:,1])
            else:
                for i in xrange(0,loc_nx+1):
                    self.out_lower_buffers[1][i] = solution_array[i,1]
            t = self.comm.south.send(self.out_lower_buffers[1], **flags)
            trackers.append(t)
            
            
        if upper_y_neigh>-1:
            msg = self.comm.north.recv(copy=False)
            self.in_upper_buffers[1] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[:,loc_ny] = self.in_upper_buffers[1]
                self.out_upper_buffers[1] = ascontiguousarray(solution_array[:,loc_ny-1])
            else:
                for i in xrange(0,loc_nx+1):
                    solution_array[i,loc_ny] = self.in_upper_buffers[1][i]
                    self.out_upper_buffers[1][i] = solution_array[i,loc_ny-1]
            t = self.comm.north.send(self.out_upper_buffers[1], **flags)
            trackers.append(t)
            
        if lower_y_neigh>-1:
            msg = self.comm.south.recv(copy=False)
            self.in_lower_buffers[1] = frombuffer(msg, dtype=dtype)
            if self.slice_copy:
                solution_array[:,0] = self.in_lower_buffers[1]
            else:
                for i in xrange(0,loc_nx+1):
                    solution_array[i,0] = self.in_lower_buffers[1][i]
        
        # wait for sends to complete:
        if flags['track']:
            for t in trackers:
                t.wait()
def update_internal_boundary_x_y ( self , solution_array ) : nsd_ = self . nsd dtype = solution_array . dtype if nsd_ != len ( self . in_lower_buffers ) | nsd_ != len ( self . out_lower_buffers ) : print ( "Buffers for communicating with lower neighbors not ready" ) return if nsd_ != len ( self . in_upper_buffers ) | nsd_ != len ( self . out_upper_buffers ) : print ( "Buffers for communicating with upper neighbors not ready" ) return loc_nx = self . subd_hi_ix [ 0 ] - self . subd_lo_ix [ 0 ] loc_ny = self . subd_hi_ix [ 1 ] - self . subd_lo_ix [ 1 ] lower_x_neigh = self . lower_neighbors [ 0 ] upper_x_neigh = self . upper_neighbors [ 0 ] lower_y_neigh = self . lower_neighbors [ 1 ] upper_y_neigh = self . upper_neighbors [ 1 ] trackers = [ ] flags = dict ( copy = False , track = False ) # communicate in the x-direction first if lower_x_neigh > - 1 : if self . slice_copy : self . out_lower_buffers [ 0 ] = ascontiguousarray ( solution_array [ 1 , : ] ) else : for i in xrange ( 0 , loc_ny + 1 ) : self . out_lower_buffers [ 0 ] [ i ] = solution_array [ 1 , i ] t = self . comm . west . send ( self . out_lower_buffers [ 0 ] , * * flags ) trackers . append ( t ) if upper_x_neigh > - 1 : msg = self . comm . east . recv ( copy = False ) self . in_upper_buffers [ 0 ] = frombuffer ( msg , dtype = dtype ) if self . slice_copy : solution_array [ loc_nx , : ] = self . in_upper_buffers [ 0 ] self . out_upper_buffers [ 0 ] = ascontiguousarray ( solution_array [ loc_nx - 1 , : ] ) else : for i in xrange ( 0 , loc_ny + 1 ) : solution_array [ loc_nx , i ] = self . in_upper_buffers [ 0 ] [ i ] self . out_upper_buffers [ 0 ] [ i ] = solution_array [ loc_nx - 1 , i ] t = self . comm . east . send ( self . out_upper_buffers [ 0 ] , * * flags ) trackers . append ( t ) if lower_x_neigh > - 1 : msg = self . comm . west . recv ( copy = False ) self . in_lower_buffers [ 0 ] = frombuffer ( msg , dtype = dtype ) if self . slice_copy : solution_array [ 0 , : ] = self . in_lower_buffers [ 0 ] else : for i in xrange ( 0 , loc_ny + 1 ) : solution_array [ 0 , i ] = self . in_lower_buffers [ 0 ] [ i ] # communicate in the y-direction afterwards if lower_y_neigh > - 1 : if self . slice_copy : self . out_lower_buffers [ 1 ] = ascontiguousarray ( solution_array [ : , 1 ] ) else : for i in xrange ( 0 , loc_nx + 1 ) : self . out_lower_buffers [ 1 ] [ i ] = solution_array [ i , 1 ] t = self . comm . south . send ( self . out_lower_buffers [ 1 ] , * * flags ) trackers . append ( t ) if upper_y_neigh > - 1 : msg = self . comm . north . recv ( copy = False ) self . in_upper_buffers [ 1 ] = frombuffer ( msg , dtype = dtype ) if self . slice_copy : solution_array [ : , loc_ny ] = self . in_upper_buffers [ 1 ] self . out_upper_buffers [ 1 ] = ascontiguousarray ( solution_array [ : , loc_ny - 1 ] ) else : for i in xrange ( 0 , loc_nx + 1 ) : solution_array [ i , loc_ny ] = self . in_upper_buffers [ 1 ] [ i ] self . out_upper_buffers [ 1 ] [ i ] = solution_array [ i , loc_ny - 1 ] t = self . comm . north . send ( self . out_upper_buffers [ 1 ] , * * flags ) trackers . append ( t ) if lower_y_neigh > - 1 : msg = self . comm . south . recv ( copy = False ) self . in_lower_buffers [ 1 ] = frombuffer ( msg , dtype = dtype ) if self . slice_copy : solution_array [ : , 0 ] = self . in_lower_buffers [ 1 ] else : for i in xrange ( 0 , loc_nx + 1 ) : solution_array [ i , 0 ] = self . in_lower_buffers [ 1 ] [ i ] # wait for sends to complete: if flags [ 'track' ] : for t in trackers : t . wait ( )
update the inner boundary with the same send/recv pattern as the MPIPartitioner
update the inner boundary with the same send / recv pattern as the MPIPartitioner