コード例 #1
0
ファイル: amr_kdtree.py プロジェクト: Xarthisius/yt-drone
    def rebuild_tree_from_array(self, nids, pids, lids, rids, les, res, gids,
                                splitdims, splitposs):
        del self.tree.trunk

        self.tree.trunk = Node(None, None, None, les[0], res[0], gids[0],
                               nids[0])

        N = nids.shape[0]
        for i in xrange(N):
            n = self.get_node(nids[i])
            n.set_left_edge(les[i])
            n.set_right_edge(res[i])
            if lids[i] != -1 and n.left is None:
                n.left = Node(n, None, None, np.zeros(3, dtype='float64'),
                              np.zeros(3, dtype='float64'), -1, lids[i])
            if rids[i] != -1 and n.right is None:
                n.right = Node(n, None, None, np.zeros(3, dtype='float64'),
                               np.zeros(3, dtype='float64'), -1, rids[i])
            if gids[i] != -1:
                n.grid = gids[i]

            if splitdims[i] != -1:
                n.create_split(splitdims[i], splitposs[i])

        mylog.info('AMRKDTree rebuilt, Final Volume: %e' %
                   kd_sum_volume(self.tree.trunk))
        return self.tree.trunk
コード例 #2
0
    def rebuild_tree_from_array(self, nids, pids, lids,
                               rids, les, res, gids, splitdims, splitposs):
        del self.tree.trunk

        self.tree.trunk = Node(None, 
                    None,
                    None,
                    les[0], res[0], gids[0], nids[0]) 

        N = nids.shape[0]
        for i in range(N):
            n = self.get_node(nids[i])
            n.set_left_edge(les[i])
            n.set_right_edge(res[i])
            if lids[i] != -1 and n.left is None:
                n.left = Node(n, None, None, 
                              np.zeros(3, dtype='float64'),  
                              np.zeros(3, dtype='float64'),  
                              -1, lids[i])
            if rids[i] != -1 and n.right is None:
                n.right = Node(n, None, None, 
                               np.zeros(3, dtype='float64'),  
                               np.zeros(3, dtype='float64'),  
                               -1, rids[i])
            if gids[i] != -1:
                n.grid = gids[i]

            if splitdims[i] != -1:
                n.create_split(splitdims[i], splitposs[i])

        mylog.info('AMRKDTree rebuilt, Final Volume: %e' % kd_sum_volume(self.tree.trunk))
        return self.tree.trunk
コード例 #3
0
ファイル: amr_kdtree.py プロジェクト: Xarthisius/yt-drone
    def check_tree(self):
        for node in depth_traverse(self.trunk):
            if node.grid == -1:
                continue
            grid = self.ds.index.grids[node.grid - self._id_offset]
            dds = grid.dds
            gle = grid.LeftEdge
            nle = self.ds.arr(get_left_edge(node), input_units="code_length")
            nre = self.ds.arr(get_right_edge(node), input_units="code_length")
            li = np.rint((nle - gle) / dds).astype('int32')
            ri = np.rint((nre - gle) / dds).astype('int32')
            dims = (ri - li).astype('int32')
            assert (np.all(grid.LeftEdge <= nle))
            assert (np.all(grid.RightEdge >= nre))
            assert (np.all(dims > 0))
            # print grid, dims, li, ri

        # Calculate the Volume
        vol = kd_sum_volume(self.trunk)
        mylog.debug('AMRKDTree volume = %e' % vol)
        kd_node_check(self.trunk)
コード例 #4
0
    def check_tree(self):
        for node in depth_traverse(self.trunk):
            if node.grid == -1:
                continue
            grid = self.ds.index.grids[node.grid - self._id_offset]
            dds = grid.dds
            gle = grid.LeftEdge
            nle = self.ds.arr(get_left_edge(node), input_units="code_length")
            nre = self.ds.arr(get_right_edge(node), input_units="code_length")
            li = np.rint((nle-gle)/dds).astype('int32')
            ri = np.rint((nre-gle)/dds).astype('int32')
            dims = (ri - li).astype('int32')
            assert(np.all(grid.LeftEdge <= nle))
            assert(np.all(grid.RightEdge >= nre))
            assert(np.all(dims > 0))
            # print grid, dims, li, ri

        # Calculate the Volume
        vol = kd_sum_volume(self.trunk)
        mylog.debug('AMRKDTree volume = %e' % vol)
        kd_node_check(self.trunk)
コード例 #5
0
ファイル: amr_kdtree.py プロジェクト: Xarthisius/yt-drone
 def count_volume(self):
     return kd_sum_volume(self.tree.trunk)
コード例 #6
0
ファイル: amr_kdtree.py プロジェクト: Xarthisius/yt-drone
            if gids[i] != -1:
                n.grid = gids[i]

            if splitdims[i] != -1:
                n.create_split(splitdims[i], splitposs[i])

        mylog.info('AMRKDTree rebuilt, Final Volume: %e' %
                   kd_sum_volume(self.tree.trunk))
        return self.tree.trunk

    def count_volume(self):
        return kd_sum_volume(self.tree.trunk)

    def count_cells(self):
        return self.tree.sum_cells()


if __name__ == "__main__":
    from yt.mods import *
    from time import time
    ds = load('/Users/skillman/simulations/DD1717/DD1717')
    ds.index

    t1 = time()
    hv = AMRKDTree(ds)
    t2 = time()

    print kd_sum_volume(hv.tree.trunk)
    print kd_node_check(hv.tree.trunk)
    print 'Time: %e seconds' % (t2 - t1)
コード例 #7
0
 def count_volume(self):
     return kd_sum_volume(self.tree.trunk)
コード例 #8
0
                               np.zeros(3, dtype='float64'),  
                               -1, rids[i])
            if gids[i] != -1:
                n.grid = gids[i]

            if splitdims[i] != -1:
                n.create_split(splitdims[i], splitposs[i])

        mylog.info('AMRKDTree rebuilt, Final Volume: %e' % kd_sum_volume(self.tree.trunk))
        return self.tree.trunk

    def count_volume(self):
        return kd_sum_volume(self.tree.trunk)
    
    def count_cells(self):
        return self.tree.sum_cells() 

if __name__ == "__main__":
    from yt.mods import *
    from time import time
    ds = load('/Users/skillman/simulations/DD1717/DD1717')
    ds.index

    t1 = time()
    hv = AMRKDTree(ds)
    t2 = time()

    print(kd_sum_volume(hv.tree.trunk))
    print(kd_node_check(hv.tree.trunk))
    print('Time: %e seconds' % (t2-t1))
コード例 #9
0
            if gids[i] != -1:
                n.grid = gids[i]

            if splitdims[i] != -1:
                n.create_split(splitdims[i], splitposs[i])

        mylog.info('AMRKDTree rebuilt, Final Volume: %e' %
                   kd_sum_volume(self.tree.trunk))
        return self.tree.trunk

    def count_volume(self):
        return kd_sum_volume(self.tree.trunk)

    def count_cells(self):
        return self.tree.sum_cells()


if __name__ == "__main__":
    from yt.mods import *
    from time import time
    ds = load('/Users/skillman/simulations/DD1717/DD1717')
    ds.index

    t1 = time()
    hv = AMRKDTree(ds)
    t2 = time()

    print(kd_sum_volume(hv.tree.trunk))
    print(kd_node_check(hv.tree.trunk))
    print('Time: %e seconds' % (t2 - t1))