コード例 #1
0
    def coarsen_poly(self, plot=True):

        node = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [2, 0], [2, 1]],
                        dtype=np.float)
        cell = np.array([[0, 1, 2], [0, 2, 3], [1, 4, 5], [2, 1, 5]],
                        dtype=np.int)
        mesh = TriangleMesh(node, cell)
        mesh = HalfEdgeMesh2d.from_mesh(mesh)
        mesh.init_level_info()

        isMarkedCell = np.array([0, 0, 0, 1, 0], dtype=np.bool_)
        mesh.refine_poly(isMarkedCell)

        NC = mesh.number_of_all_cells()
        isMarkedCell = np.zeros(NC, dtype=np.bool_)
        isMarkedCell[[1, 2, 3, 4, 5, 6]] = True
        mesh.coarsen_poly(isMarkedCell)

        fig = plt.figure()
        axes = fig.gca()
        mesh.add_plot(axes)
        mesh.find_node(axes, showindex=True)
        mesh.find_cell(axes, showindex=True)
        mesh.add_halfedge_plot(axes, showindex=True)
        plt.show()
コード例 #2
0
    def coarsen_poly(self, plot=True):

        node = np.array([[0,0],[1,0],[1,1],[0,1],[2,0],[2,1]], dtype = np.float)
        cell = np.array([[0,1,2],[0,2,3],[1,4,5],[2,1,5]],dtype = np.int)
        mesh = TriangleMesh(node, cell)
        mesh = HalfEdgeMesh2d.from_mesh(mesh)

        isMarkedCell = np.array([0,0,0,1,0], dtype=np.bool_)
        mesh.refine_poly(isMarkedCell)


        isMarkedCell = np.array([0,0,0,0,1,1,1], dtype=np.bool_)
        mesh.coarsen_poly(isMarkedCell)
        fig = plt.figure()
        axes = fig.gca()
        mesh.add_plot(axes)
        mesh.find_node(axes, showindex=True)
        mesh.find_cell(axes, showindex=True)
        plt.show()