示例#1
0
    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)
    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:
        mesh.uniform_refine(1, pde.surface)

print('Ndof:', Ndof)
print('error:', errorMatrix)
showmultirate(plt, 0, Ndof, errorMatrix, errorType)
plt.show()
Ndof = np.zeros((maxit, ), dtype=np.int)
errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float)
integrator = TriangleQuadrature(3)
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)
示例#3
0
import mpl_toolkits.mplot3d as a3
import pylab as pl

p = int(sys.argv[1])
theta = 0.2
integrator = TriangleQuadrature(6)
ralg = FEMFunctionRecoveryAlg()
pde = SphereSinSinSinData()
mesh = pde.init_mesh(5)
tmesh = Tritree(mesh.node, mesh.ds.cell, irule=1)
pmesh = tmesh.to_conformmesh()
fig0 = pl.figure()
axes0 = a3.Axes3D(fig0)
pmesh.add_plot(axes0)
pl.show()
fem = SurfacePoissonFEMModel(pmesh, pde, p, integrator)
fem.solve()
uh = fem.uh
print(uh)
rguh = ralg.harmonic_average(uh)
eta = fem.recover_estimate(rguh)
tmesh.refine(marker=AdaptiveMarker(eta, theta=theta))
pmesh = tmesh.to_conformmesh()
fem = SurfacePoissonFEMModel(pmesh, pde, p, integrator)
fem.solve()
uh = fem.uh
print(uh)
fig1 = pl.figure()
axes1 = a3.Axes3D(fig1)
pmesh.add_plot(axes1)
pl.show()