ralg = FEMFunctionRecoveryAlg()
pde = SphereSinSinSinData()
mesh = pde.init_mesh(2)
tmesh = Tritree(mesh.node, mesh.ds.cell, irule=1)
pmesh = tmesh.to_conformmesh()

fig = pl.figure()
axes = a3.Axes3D(fig)
pmesh.add_plot(axes)

for i in range(maxit):
    print('step:', i)
    fem = SurfacePoissonFEMModel(pmesh, pde, p, integrator)
    fem.solve()
    uh = fem.uh
    rguh = ralg.harmonic_average(uh)
    eta = fem.recover_estimate(rguh)
    Ndof[i] = len(fem.uh)
    errorMatrix[0, i] = fem.get_l2_error()
    errorMatrix[1, i] = fem.get_L2_error()
    errorMatrix[2, i] = fem.get_H1_semi_error()
    if i < maxit - 1:
        tmesh.refine(marker=AdaptiveMarker(eta, theta=theta))
        pmesh = tmesh.to_conformmesh()

fig = pl.figure()
axes = a3.Axes3D(fig)
pmesh.add_plot(axes)
pl.show()
print('Ndof:', Ndof)
print('error:', errorMatrix)
Exemple #2
0
ralg = FEMFunctionRecoveryAlg()

errorType = ['$\| u - u_h\|_0$', '$\|\\nabla u - \\nabla u_h\|$', '$\eta$']

Ndof = np.zeros((maxit, ), dtype=np.int)
errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float)
mesh = tritree.to_conformmesh()

for i in range(maxit):
    print('step:', i)
    fem = PoissonFEMModel(pde, mesh, p=p, q=q)
    fem.solve()
    Ndof[i] = fem.space.number_of_global_dofs()
    errorMatrix[0, i] = fem.L2_error()
    errorMatrix[1, i] = fem.H1_semi_error()
    rguh = ralg.harmonic_average(fem.uh)
    eta = fem.recover_estimate(rguh)
    errorMatrix[2, i] = np.sqrt(np.sum(eta**2))
    if i < maxit - 1:
        options = tritree.adaptive_options()
        tritree.adaptive(eta, options)
        mesh = tritree.to_conformmesh()

mesh.add_plot(plt, showaxis=True)

fig = plt.figure()
axes = fig.gca()
mesh.add_plot(axes)

showmultirate(plt, k, Ndof, errorMatrix, errorType)
plt.show()