예제 #1
0
    def cell_to_node(self):
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        print('node:', node)
        print('cell:', cell)
        print('cellLocation:', cellLocation)
        mesh = PolygonMesh(node, cell, cellLocation)

        fig = plt.figure()
        axes = fig.gca()
        mesh.add_plot(axes)
        mesh.find_node(axes, showindex=True)
        mesh.find_cell(axes, showindex=True)

        mesh = HalfEdgeMesh2d.from_mesh(mesh)
        mesh.print()
        cell, cellLocation = mesh.entity('cell')
        print('cell:', cell)
        print('cellLocation:', cellLocation)
        plt.show()
예제 #2
0
    def edge_to_cell_test(self, plot=True):
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        mesh = HalfEdgePolygonMesh.from_polygonmesh(mesh)

        NE = mesh.number_of_edges()
        edge = mesh.entity('edge')
        edge2cell = mesh.ds.edge_to_cell()
        print('edge:')
        for i in range(NE):
            print(i, ":", edge[i], edge2cell[i])

        NC = mesh.number_of_cells()
        cell, cellLocation = mesh.entity('cell')
        cell2edge = mesh.ds.cell_to_edge()
        for i in range(NC):
            print(i, ":", cell[cellLocation[i]:cellLocation[i + 1]])
            print(i, ":", cell2edge[cellLocation[i]:cellLocation[i + 1]])

        if plot:
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_edge(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()
    def project_test(self, u, p=2, mtype=0, plot=True):
        from fealpy.mesh.simple_mesh_generator import triangle
        if mtype == 0:
            node = np.array([(-1, -1), (1, -1), (1, 1), (-1, 1)],
                            dtype=np.float)
            cell = np.array([0, 1, 2, 3], dtype=np.int)
            cellLocation = np.array([0, 4], dtype=np.int)
            mesh = PolygonMesh(node, cell, cellLocation)
        elif mtype == 1:
            node = np.array([(-1, -1), (1, -1), (1, 1), (-1, 1)],
                            dtype=np.float)
            cell = np.array([0, 1, 2, 3, 0, 2], dtype=np.int)
            cellLocation = np.array([0, 3, 6], dtype=np.int)
            mesh = PolygonMesh(node, cell, cellLocation)
        elif mtype == 2:
            h = 0.025
            mesh = triangle([-1, 1, -1, 1], h, meshtype='polygon')
        elif mtype == 3:
            node = np.array([(-1, -1), (1, -1), (1, 1), (-1, 1)],
                            dtype=np.float)
            cell = np.array([[0, 1, 2, 3]], dtype=np.int)
            mesh = QuadrangleMesh(node, cell)
            mesh.uniform_refine()
            mesh = PolygonMesh.from_mesh(mesh)
        elif mtype == 4:
            node = np.array([(-1, -1), (1, -1), (1, 0), (1, 1), (-1, 1),
                             (-1, 0)],
                            dtype=np.float)
            cell = np.array([0, 1, 2, 5, 2, 3, 4, 5], dtype=np.int)
            cellLocation = np.array([0, 4, 8], dtype=np.int)
            mesh = PolygonMesh(node, cell, cellLocation)

        if True:
            cell, cellLocation = mesh.entity('cell')
            edge = mesh.entity('edge')
            cell2edge = mesh.ds.cell_to_edge()
            bc = mesh.entity_barycenter('edge')
            uspace = ReducedDivFreeNonConformingVirtualElementSpace2d(mesh, p)
            up = uspace.project(u)
            up = uspace.project_to_smspace(up)
            print(up)

            integralalg = uspace.integralalg
            error = integralalg.L2_error(u, up)
            print(error)

            A = uspace.matrix_A()
            P = uspace.matrix_P()

            sio.savemat('A.mat', {"A": A.toarray(), "P": P.toarray()})

        if plot:
            mesh.print()
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_edge(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()
예제 #4
0
    def boundary_edge_to_edge_test(self, plot=True):

        node = np.array([(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)],
                        dtype=np.float)
        cell = np.array([0, 1, 2, 3], dtype=np.int)
        cellLocation = np.array([0, 4], dtype=np.int)
        mesh = PolygonMesh(node, cell, cellLocation)
        mesh.ds.boundary_edge_to_edge()
        if plot:
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_edge(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()
예제 #5
0
    def project_test(self, u, p=2, mtype=0, plot=True):
        from fealpy.mesh.simple_mesh_generator import triangle

        if mtype == 0:
            node = np.array([(-1, -1), (1, -1), (1, 1), (-1, 1)],
                            dtype=np.float)
            cell = np.array([0, 1, 2, 3], dtype=np.int)
            cellLocation = np.array([0, 4], dtype=np.int)
            mesh = PolygonMesh(node, cell, cellLocation)
        elif mtype == 1:
            node = np.array([(-1, -1), (1, -1), (1, 1), (-1, 1)],
                            dtype=np.float)
            cell = np.array([0, 1, 2, 3, 0, 2], dtype=np.int)
            cellLocation = np.array([0, 3, 6], dtype=np.int)
            mesh = PolygonMesh(node, cell, cellLocation)
        elif mtype == 2:
            h = 0.1
            mesh = triangle([-1, 1, -1, 1], h, meshtype='polygon')
        elif mtype == 3:
            node = np.array([(-1, -1), (1, -1), (1, 1), (-1, 1)],
                            dtype=np.float)
            cell = np.array([[0, 1, 2, 3]], dtype=np.int)
            mesh = QuadrangleMesh(node, cell)
            mesh.uniform_refine()
            mesh = PolygonMesh.from_mesh(mesh)

        cell, cellLocation = mesh.entity('cell')
        edge = mesh.entity('edge')
        cell2edge = mesh.ds.cell_to_edge()
        uspace = DivFreeNonConformingVirtualElementSpace2d(mesh, p)
        up = uspace.project(u)
        print(up)
        up = uspace.project_to_smspace(up)
        print(up)

        integralalg = uspace.integralalg
        error = integralalg.L2_error(u, up)
        print(error)
        if plot:
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_edge(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()
예제 #6
0
    def convexity(self):
        node = np.array([[0, 0], [2, 0], [2, 1], [1, 1], [1, 2], [1, 3],
                         [1, 4], [2, 4], [2, 5], [0, 5], [0, 2]],
                        dtype=np.float)
        cell = np.array([0, 1, 2, 3, 4, 10, 5, 6, 7, 8, 9, 10, 4],
                        dtype=np.int_)
        cellLocation = np.array([0, 6, 13], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        mesh = HalfEdgeMesh2d.from_mesh(mesh)

        mesh.print()
        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()
예제 #7
0
    def refine_test(self, plot=True):
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        mesh = HalfEdgePolygonMesh.from_polygonmesh(mesh)
        isMarkedCell = np.zeros(5, dtype=np.bool)
        isMarkedCell[-1] = True
        isMarkedCell[-2] = True
        mesh.refine(isMarkedCell)

        if True:
            NC = mesh.number_of_cells()
            isMarkedCell = np.zeros(NC, dtype=np.bool)
            isMarkedCell[2] = True
            mesh.refine(isMarkedCell)

        if True:
            NC = mesh.number_of_cells()
            isMarkedCell = np.zeros(NC, dtype=np.bool)
            isMarkedCell[1] = True
            mesh.refine(isMarkedCell)

        if True:
            NC = mesh.number_of_cells()
            isMarkedCell = np.zeros(NC, dtype=np.bool)
            isMarkedCell[13] = True
            mesh.refine(isMarkedCell)

        if plot:
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_edge(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()
예제 #8
0
    def from_polygonmesh_test(self, plot=True):
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        a = mesh.entity_measure('cell')

        mesh = HalfEdgePolygonMesh.from_polygonmesh(mesh)
        a = mesh.entity_measure('cell')
        mesh.print()

        if plot:
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_edge(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()
예제 #9
0
    def refine_with_flag_test(self, plot=True):
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        mesh = HalfEdgePolygonMesh.from_polygonmesh(mesh)

        NE = mesh.number_of_edges()
        NC = mesh.number_of_cells()

        name = 'rflag'
        val = np.zeros(2 * NE, dtype=np.int)
        mesh.set_data(name, val, 'halfedge')

        isMarkedCell = np.zeros(NC + 1, dtype=np.bool)
        isMarkedCell[2] = True
        mesh.refine_with_flag(isMarkedCell, rflag=name, dflag=False)

        NC = mesh.number_of_cells()
        isMarkedCell = np.zeros(NC + 1, dtype=np.bool)
        isMarkedCell[6] = True
        mesh.refine_with_flag(isMarkedCell, rflag=name, dflag=False)

        if True:
            NC = mesh.number_of_cells()
            isMarkedCell = np.zeros(NC + 1, dtype=np.bool)
            isMarkedCell[3] = True
            mesh.refine_with_flag(isMarkedCell, rflag=name, dflag=False)

        if True:
            NC = mesh.number_of_cells()
            isMarkedCell = np.zeros(NC + 1, dtype=np.bool)
            isMarkedCell[1] = True
            mesh.refine_with_flag(isMarkedCell, rflag=name, dflag=False)

        if True:
            NC = mesh.number_of_cells()
            isMarkedCell = np.zeros(NC + 1, dtype=np.bool)
            isMarkedCell[5] = True
            isMarkedCell[13] = True
            mesh.refine_with_flag(isMarkedCell, rflag=name, dflag=False)
        if True:
            NC = mesh.number_of_cells()
            isMarkedCell = np.zeros(NC + 1, dtype=np.bool)
            isMarkedCell[0] = True
            isMarkedCell[1] = True
            mesh.refine_with_flag(isMarkedCell, rflag=name, dflag=False)

        print("rflag:\n")
        for i, val in enumerate(mesh.halfedgedata[name]):
            print(i, ':', val, mesh.ds.halfedge[i, 0:2])

        if plot:
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            #mesh.find_edge(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()
node = np.array([ (0, 0), (1, 0), (1, 1), (0, 1)], dtype=np.float)
cell = np.array([0, 1, 2, 3], dtype=np.int)
cellLocation = np.array([0, 4], dtype=np.int)

pmesh = PolygonMesh(node, cell, cellLocation)

space = VectorScaledMonomialSpace2d(pmesh, p)

phi = space.basis(point)
print('phi', phi)
gphi = space.grad_basis(point)
print('gphi', gphi)
dphi = space.div_basis(point)
print('dphi', dphi)
gdphi = space.grad_div_basis(point)
print('gdphi', gdphi)
sphi = space.strain_basis(point)
print('sphi', sphi)
dsphi = space.div_strain_basis(point)
print('dsphi', dsphi)


fig = plt.figure()
axes = fig.gca()
pmesh.add_plot(axes)
pmesh.find_node(axes, showindex=True)
pmesh.find_edge(axes, showindex=True)
pmesh.find_cell(axes, showindex=True)
plt.show()
예제 #11
0
    def adaptive_poly_test(self, plot=True):
        """"
        initial mesh
        """
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        mesh = HalfEdgeMesh.from_mesh(mesh)

        fig = plt.figure()
        axes = fig.gca()
        mesh.add_plot(axes)
        mesh.find_node(axes, showindex=True)
        mesh.find_cell(axes, showindex=True)

        NE = mesh.number_of_edges()
        nC = mesh.number_of_cells()
        """
        refined mesh
        """
        aopts = mesh.adaptive_options(method='numrefine',
                                      maxcoarsen=3,
                                      HB=True)
        eta = [0, 0, 1, 1, 1]

        mesh.adaptive(eta, aopts)
        print('r', aopts['HB'])

        fig = plt.figure()
        axes = fig.gca()
        mesh.add_plot(axes)
        mesh.find_node(axes, showindex=True)
        mesh.find_cell(axes, showindex=True)
        plt.show()

        mesh.from_mesh(mesh)
        """
        coarsened mesh
        """
        eta = [0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1]
        #eta = [0,0,0,0,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2]

        mesh.adaptive(eta, aopts)

        fig = plt.figure()
        axes = fig.gca()
        mesh.add_plot(axes)
        mesh.find_node(axes, showindex=True)
        mesh.find_cell(axes, showindex=True)
        plt.show()

        if plot:

            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)

            NAC = mesh.number_of_all_cells()  # 包括外部区域和洞
            cindex = range(mesh.ds.cellstart, NAC)
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_cell(axes, showindex=True, multiindex=cindex)

            NN = mesh.number_of_nodes()
            nindex = np.zeros(NN, dtype=np.int)
            halfedge = mesh.ds.halfedge
            nindex[halfedge[:, 0]] = mesh.get_data('halfedge', 'level')
            cindex = mesh.get_data('cell', 'level')
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True, multiindex=nindex)
            mesh.find_cell(axes, showindex=True, multiindex=cindex)
            plt.show()
        else:
            return mesh
예제 #12
0
    def refine_poly_test(self, plot=True):
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        mesh = HalfEdgeMesh.from_mesh(mesh)

        fig = plt.figure()
        axes = fig.gca()
        mesh.add_plot(axes)
        mesh.find_node(axes, showindex=True)
        mesh.find_cell(axes, showindex=True)
        clevel = mesh.celldata['level']
        print(clevel)
        NE = mesh.number_of_edges()
        NC = mesh.number_of_cells()

        if True:
            isMarkedCell = mesh.mark_helper([2])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if False:
            isMarkedCell = mesh.mark_helper([6])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if False:
            isMarkedCell = mesh.mark_helper([3])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if 1:
            isMarkedCell = mesh.mark_helper([1, 5])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if False:
            isMarkedCell = mesh.mark_helper([1, 12])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if False:
            isMarkedCell = mesh.mark_helper([0, 21])
            mesh.refine_poly(isMarkedCell, dflag=False)
        clevel = mesh.celldata['level']
        print(clevel)

        #print("halfedge level:\n")
        #for i, val in enumerate(mesh.halfedgedata['level']):
        #    print(i, ':', val, mesh.ds.halfedge[i, 0:2])

        #print("cell level:\n")
        #for i, val in enumerate(mesh.celldata['level']):
        #    print(i, ':', val)

        if plot:

            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)

            NAC = mesh.number_of_all_cells()  # 包括外部区域和洞
            cindex = range(mesh.ds.cellstart, NAC)
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.add_halfedge_plot(axes, showindex=True)
            mesh.find_cell(axes, showindex=True, multiindex=cindex)

            NN = mesh.number_of_nodes()
            nindex = np.zeros(NN, dtype=np.int)
            halfedge = mesh.ds.halfedge
            nindex[halfedge[:, 0]] = mesh.get_data('halfedge', 'level')
            cindex = mesh.get_data('cell', 'level')
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True, multiindex=nindex)
            mesh.find_cell(axes, showindex=True, multiindex=cindex)
            plt.show()
        else:
            return mesh
예제 #13
0
    def refine_poly(self, plot=True):
        node = np.array([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (1.0, 0.0),
                         (1.0, 1.0), (1.0, 2.0), (2.0, 0.0), (2.0, 1.0),
                         (2.0, 2.0)],
                        dtype=np.float)
        cell = np.array([0, 3, 4, 4, 1, 0, 1, 4, 5, 2, 3, 6, 7, 4, 4, 7, 8, 5],
                        dtype=np.int)
        cellLocation = np.array([0, 3, 6, 10, 14, 18], dtype=np.int)

        mesh = PolygonMesh(node, cell, cellLocation)
        mesh = HalfEdgeMesh2d.from_mesh(mesh)
        mesh.uniform_refine(n=2)
        print(mesh.number_of_nodes())

        #fig = plt.figure()
        #axes = fig.gca()
        #mesh.add_plot(axes)
        #mesh.find_node(axes, showindex=True)
        #mesh.find_cell(axes, showindex=True)

        NE = mesh.number_of_edges()
        NC = mesh.number_of_cells()

        if True:
            isMarkedCell = mesh.mark_helper([2])
            mesh.refine_poly(isMarkedCell)

        if False:
            isMarkedCell = mesh.mark_helper([6])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if False:
            isMarkedCell = mesh.mark_helper([3])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if False:
            isMarkedCell = mesh.mark_helper([1, 5])
            mesh.refine_poly(isMarkedCell)

        if False:
            isMarkedCell = mesh.mark_helper([1, 12])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if False:
            isMarkedCell = mesh.mark_helper([0, 21])
            mesh.refine_poly(isMarkedCell, dflag=False)

        if plot:
            fig = plt.figure()
            axes = fig.gca()
            mesh.add_plot(axes)
            mesh.find_node(axes, showindex=True)
            mesh.add_halfedge_plot(axes, showindex=True)
            mesh.find_cell(axes, showindex=True)
            plt.show()

            if 0:
                NAC = mesh.number_of_all_cells()  # 包括外部区域和洞
                cindex = range(mesh.ds.cellstart, NAC)
                fig = plt.figure()
                axes = fig.gca()
                #mesh.add_plot(axes)
                mesh.add_halfedge_plot(axes, showindex=True)
                mesh.find_node(axes, showindex=True)
                mesh.find_cell(axes, showindex=True, multiindex=cindex)

                NN = mesh.number_of_nodes()
                nindex = np.zeros(NN, dtype=np.int)
                halfedge = mesh.ds.halfedge
                nindex[halfedge[:, 0]] = mesh.get_data('halfedge', 'level')
                cindex = mesh.get_data('cell', 'level')

                fig = plt.figure()
                axes = fig.gca()
                #mesh.add_plot(axes)
                mesh.find_node(axes, showindex=True, multiindex=nindex)
                #mesh.find_cell(axes, showindex=True, multiindex=cindex)
                plt.show()
        else:
            return mesh