Example #1
0
    def _get_nearest_particles_nocahe(self, i, output_array, exclude_index=-1):
        """ Use the linked list to get nearest neighbors.

        The functions defined in `linked_list_functions.pyx` are used to
        find the nearest neighbors.

        Parameters:
        -----------

        i : (in) int
            The destination particle index

        output_array : (in/out) LongArray
            Neighbor indices are stored in this array.

        exclude_index : int
            Optional index to exclude from the neighbor list
            NOTIMPLEMENTED!

        """
        manager = self.manager
        src = self.source
        dst = self.dest
        
        # Enqueue a copy if the binning is done with OpenCL
        manager.enqueue_copy()

        # get the bin structure parameters
        ncx = manager.ncx
        ncy = manager.ncy
        ncells = manager.ncells
#CHANGE
        # cell_counts and indices for the source
        cellc = manager.cell_counts[ src.name ]
        s_indices = manager.indices[ src.name ]

        # destination indices
        d_indices = manager.indices[ dst.name ]
        
        # cellid for the destination particle
        cellid  = manager.cellids[dst.name][i]
        
        # get all neighbors from the 27 neighboring cells
        nbrs = util.rs_get_neighbors(cellid, ncx, ncy, ncells, cellc, s_indices)
        
        xs = src.x.astype(numpy.float32)
        ys = src.y.astype(numpy.float32)
        zs = src.z.astype(numpy.float32)

        xi = numpy.float32( dst.x[d_indices[i]] )
        yi = numpy.float32( dst.y[d_indices[i]] )
        zi = numpy.float32( dst.z[d_indices[i]] )
        
        radius = numpy.float32( self.scale_fac * dst.h[d_indices[i]] )

        # filter the neighbors to within a cutoff radius
        nbrs = util.filter_neighbors(xi, yi, zi, radius, xs, ys, zs, nbrs)
        
        output_array.resize( len(nbrs) )
        output_array.set_data( nbrs )
Example #2
0
    def _get_nearest_particles_nocahe(self, i, output_array, exclude_index=-1):
        """ Use the linked list to get nearest neighbors.

        The functions defined in `linked_list_functions.pyx` are used to
        find the nearest neighbors.

        Parameters:
        -----------

        i : (in) int
            The destination particle index

        output_array : (in/out) LongArray
            Neighbor indices are stored in this array.

        exclude_index : int
            Optional index to exclude from the neighbor list
            NOTIMPLEMENTED!

        """
        manager = self.manager
        src = self.source
        dst = self.dest
        
        # Enqueue a copy if the binning is done with OpenCL
        manager.enqueue_copy()

        # get the bin structure parameters
        ncx = manager.ncx
        ncy = manager.ncy
        ncells = manager.ncells

        # linked list for the source
        head = manager.head[src.name]
        next = manager.Next[src.name]
        
        # cellid for the destination
        cellid  = manager.cellids[dst.name][i]
        ix = manager.ix[dst.name][i]
        iy = manager.iy[dst.name][i]
        iz = manager.iz[dst.name][i]
        
        # get all neighbors from the 27 neighboring cells
        nbrs =  util.ll_get_neighbors(cellid, ix, iy, iz,
                                      ncx, ncy, ncells, head, next)
        
        x = src.x.astype(numpy.float32)
        y = src.y.astype(numpy.float32)
        z = src.z.astype(numpy.float32)

        xi = numpy.float32( dst.x[i] )
        yi = numpy.float32( dst.y[i] )
        zi = numpy.float32( dst.z[i] )

        h = dst.h.astype(numpy.float32)
        radius = self.scale_fac * h[i]

        # filter the neighbors to within a cutoff radius
        nbrs = util.filter_neighbors(xi, yi, zi, radius, x, y, z, nbrs)
        
        output_array.resize( len(nbrs) )
        output_array.set_data( nbrs )