def interpolation(self, n=2, plot=True): from fealpy.pde.poisson_2d import CosCosData from fealpy.functionspace import ConformingVirtualElementSpace2d pde = CosCosData() node = np.array([(0, 0), (1, 0), (1, 1), (0, 1)], dtype=np.float64) cell = np.array([(0, 1, 2, 3)], dtype=np.int_) mesh = QuadrangleMesh(node, cell) #mesh = PolygonMesh.from_mesh(mesh) mesh = HalfEdgeMesh2d.from_mesh(mesh) mesh.uniform_refine(n=n) #mesh.print() space = ConformingVirtualElementSpace2d(mesh, p=1) uI = space.interpolation(pde.solution) up = space.project_to_smspace(uI) error = space.integralalg.L2_error(pde.solution, up) print(error) if plot: fig = plt.figure() axes = fig.gca() #mesh.add_halfedge_plot(axes, showindex=True) 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 refine_RB_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) mesh = QuadrangleMesh(node, cell) mesh.uniform_refine() markedCell = np.array([3], dtype=np.int) mesh.refine_RB(markedCell) 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) mesh.print() plt.show()