Ejemplo n.º 1
0
    def update(self):
        """Update particles.  This method simply partitions the particles
        equally among the processors.
        """
        logger.debug("SimpleParallelManager.update()")
        comm = self.comm
        rank = self.rank
        size = self.size
        
        local_data = self.particles.arrays

        # Remove remotes from the local.
        for arr in local_data:
            remove = arange_long(arr.num_real_particles, arr.get_number_of_particles())
            arr.remove_particles(remove)

            # everybody sets the pid for their local arrays
            arr.set_pid(rank)

        comm.Barrier()

        # Collect all the local arrays and then broadcast them.
        data = comm.gather(local_data, root=0)
        data = comm.bcast(data, root=0)

        # Now set the remote data's tags to Dummy and add the arrays to
        # the local.
        for i in range(size):
            if i != rank:
                for j, arr in enumerate(data[i]):
                    tag = arr.get_carray('tag')
                    tag.get_npy_array()[:] = Dummy
                    #local = arr.get_carray('local')
                    #local.get_npy_array()[:] = 0

                    local_data[j].append_parray(arr)

        return
Ejemplo n.º 2
0
 def _remove_remote_particles(self):
     """Remove all remote particles."""
     for array in self.arrays:
         to_remove = arange_long(array.num_real_particles,
                                 array.get_number_of_particles())
         array.remove_particles(to_remove)