def __init__(self, partition, rank=0):
        """

        :param partition:
        :param rank:
        """

        self.__partition = partition
        self.__rank = rank
        self.__data = dict()

        for key in self.partition.domains.keys():
            self.__data[key] = SerialArray(self.partition.domains[key], rank)

        self.__d = dict()
        for key in self.__data.keys():
            self.__d[key] = self.__data[key].d

        bounds_handler_shape = list(self.partition.mesh.shape)

        for _ in range(rank):
            bounds_handler_shape.insert(0, len(self.partition.mesh.shape))

        self.__bounds_handler = IndexBoundsHandler(bounds_handler_shape)

        self.__recv_halos = dict()
        self.__send_halos = dict()

        halo_counter = 0

        for key in self.__data.keys():

            self.__recv_halos[key] = dict()
            self.__send_halos[key] = dict()
            for i in range(len(key)):
                self.__recv_halos[key][i] = []
                self.__send_halos[key][i] = []

            sender = compute_sender(key, self.__partition.domains[key].halos)

            for i in range(len(key)):
                for el in sender[i]:
                    halo_counter += 1
                    dom = self.__partition.domains[key]
                    receiver_location = compute_receiver_halo_location(dom.mesh, dom.halos, key, el)
                    self.__recv_halos[key][i].append(ReceiveHalo(self.__data[key].d, el, receiver_location, [dom.mesh.nearest_node(receiver_location[0])[0], dom.mesh.nearest_node(receiver_location[1])[0]]))

        recv_buffer = context.comm.gather([context.rank, halo_counter], root=context.master_rank)

        requests = list()

        for key in self.__data.keys():
            for k in range(len(key)):
                for halo in self.__recv_halos[key][k]:
                    requests.append(context.comm.isend([partition.rank_map[halo.sender], context.rank], dest=context.master_rank, tag=0))

        # root weiß wie viele halos jeder prozess hat
        tmp = dict()

        if context.master:
            # Send vorbereiten für data

            for j in range(context.size):
                tmp[j] = list()

            for el in recv_buffer:
                for i in range(el[1]):
                    #sender, rank
                    data = context.comm.recv(source=el[0], tag=0)
                    tmp[data[0]].append(data[1])

        MPI.Request.waitall(requests)

        mreqs = list()

        if context.master:
            for j in range(context.size):
                mreqs.append(context.comm.isend(tmp[j], dest=j, tag=1))

        MPI.Request.waitall(mreqs)
        self.__recv_halo_sources = context.comm.recv(source=context.master_rank, tag=1)
        self.__ready_for_sync = False
def __init__ ( self , partition , rank = 0 ) : self . __partition = partition self . __rank = rank self . __data = dict ( ) for key in self . partition . domains . keys ( ) : self . __data [ key ] = SerialArray ( self . partition . domains [ key ] , rank ) self . __d = dict ( ) for key in self . __data . keys ( ) : self . __d [ key ] = self . __data [ key ] . d bounds_handler_shape = list ( self . partition . mesh . shape ) for _ in range ( rank ) : bounds_handler_shape . insert ( 0 , len ( self . partition . mesh . shape ) ) self . __bounds_handler = IndexBoundsHandler ( bounds_handler_shape ) self . __recv_halos = dict ( ) self . __send_halos = dict ( ) halo_counter = 0 for key in self . __data . keys ( ) : self . __recv_halos [ key ] = dict ( ) self . __send_halos [ key ] = dict ( ) for i in range ( len ( key ) ) : self . __recv_halos [ key ] [ i ] = [ ] self . __send_halos [ key ] [ i ] = [ ] sender = compute_sender ( key , self . __partition . domains [ key ] . halos ) for i in range ( len ( key ) ) : for el in sender [ i ] : halo_counter += 1 dom = self . __partition . domains [ key ] receiver_location = compute_receiver_halo_location ( dom . mesh , dom . halos , key , el ) self . __recv_halos [ key ] [ i ] . append ( ReceiveHalo ( self . __data [ key ] . d , el , receiver_location , [ dom . mesh . nearest_node ( receiver_location [ 0 ] ) [ 0 ] , dom . mesh . nearest_node ( receiver_location [ 1 ] ) [ 0 ] ] ) ) recv_buffer = context . comm . gather ( [ context . rank , halo_counter ] , root = context . master_rank ) requests = list ( ) for key in self . __data . keys ( ) : for k in range ( len ( key ) ) : for halo in self . __recv_halos [ key ] [ k ] : requests . append ( context . comm . isend ( [ partition . rank_map [ halo . sender ] , context . rank ] , dest = context . master_rank , tag = 0 ) ) tmp = dict ( ) if context . master : for j in range ( context . size ) : tmp [ j ] = list ( ) for el in recv_buffer : for i in range ( el [ 1 ] ) : data = context . comm . recv ( source = el [ 0 ] , tag = 0 ) tmp [ data [ 0 ] ] . append ( data [ 1 ] ) MPI . Request . waitall ( requests ) mreqs = list ( ) if context . master : for j in range ( context . size ) : mreqs . append ( context . comm . isend ( tmp [ j ] , dest = j , tag = 1 ) ) MPI . Request . waitall ( mreqs ) self . __recv_halo_sources = context . comm . recv ( source = context . master_rank , tag = 1 ) self . __ready_for_sync = False
:param partition:
        :param rank: