Exemplo n.º 1
0
 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 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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
m = int(sys.argv[1])
p = int(sys.argv[2])
q = int(sys.argv[3])
if m == 1:
    pde = SphereSinSinSinData()
    mesh = pde.init_mesh()
elif m == 2:
    model = ToruSurfacesData()
    surface = model.surface
    mesh = surface.init_mesh()
elif m == 3:
    model = ElipsoidSurfaceData()
    surface = model.surface
    mesh = surface.init_mesh()
elif m == 4:
    model = HeartSurfacetData()
    surface = model.surface
    mesh = surface.init_mesh()

maxit = 4
errorType = [
    '$|| u_I - u_h ||_{l_2}$', '$|| u - u_h||_{S,0}$',
    '$||\\nabla_S u - \\nabla_S u_h||_{S, 0}$'
]

Ndof = np.zeros((maxit, ), dtype=np.int)
errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float)
for i in range(maxit):
    fem = SurfacePoissonFEMModel(mesh, pde, p, q)
    fem.solve()
    Ndof[i] = len(fem.uh)