def mesh_scale_test(self, plot=True): scale = 10 pde = HeartSurfacetData() surface = pde.domain() mesh = pde.init_mesh() space = SurfaceLagrangeFiniteElementSpace(mesh, surface, p=1, scale=scale) mesh = space.mesh if plot is True: fig = plt.figure() axes = Axes3D(fig) mesh.add_plot(axes, showaxis=True) plt.show()
class HeartTritreeTest: def __init__(self, scale=2): self.scale = scale self.pde = HeartSurfacetData() self.surface = self.pde.domain() self.mesh = self.pde.init_mesh() self.mesh.uniform_refine(surface=self.surface) node = self.mesh.entity('node') cell = self.mesh.entity('cell') self.tritree = Tritree(node, cell) def test_interpolation_surface(self, p=1): options = self.tritree.adaptive_options(maxrefine=1, p=p) mesh = self.tritree.to_conformmesh() fig = pl.figure() axes = a3.Axes3D(fig) mesh.add_plot(axes, showaxis=True) space = SurfaceLagrangeFiniteElementSpace(mesh, self.surface, p=p, scale=self.scale) uI = space.interpolation(self.pde.solution) print('1:', space.number_of_global_dofs()) print('2:', uI.shape) error0 = space.integralalg.L2_error(self.pde.solution, uI) print(error0) data = self.tritree.interpolation(uI) print('3', data.shape) options['data'] = {'q': data} if 0: eta = space.integralalg.integral(lambda x: uI.grad_value(x)**2, celltype=True, barycenter=True) eta = eta.sum(axis=-1) self.tritree.adaptive(eta, options, surface=self.surface) else: self.tritree.uniform_refine(options=options, surface=self.surface) fig = pl.figure() axes = a3.Axes3D(fig) self.tritree.add_plot(axes, showaxis=True) mesh = self.tritree.to_conformmesh(options) fig = pl.figure() axes = a3.Axes3D(fig) mesh.add_plot(axes, showaxis=True) space = SurfaceLagrangeFiniteElementSpace(mesh, self.surface, p=p, scale=self.scale) mesh0 = space.mesh fig = pl.figure() axes = a3.Axes3D(fig) mesh0.add_plot(axes, showaxis=True) data = options['data']['q'] print('data:', data.shape) uh = space.to_function(data) print('uh:', uh.shape) error1 = space.integralalg.L2_error(self.pde.solution, uh) print(error1) uI = space.interpolation(self.pde.solution) error2 = space.integralalg.L2_error(self.pde.solution, uI) print(error2) if 0: fig = pl.figure() axes = a3.Axes3D(fig) self.tritree.add_plot(axes) plt.show() else: fig = pl.figure() axes = a3.Axes3D(fig) mesh.add_plot(axes, showaxis=True) plt.show()