import mpl_toolkits.mplot3d as a3 import pylab as pl p = int(sys.argv[1]) maxit = int(sys.argv[2]) theta = 0.35 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) 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)
from fealpy.tools.show import showmultirate pde = LShapeRSinData() mesh = pde.init_mesh(n=2, meshtype='tet') maxit = 20 theta = 0.2 k = maxit - 15 p = 1 q = 3 errorType = ['$|| u_I - u_h ||_{l_2}$', '$|| u - u_h||_{0}$', '$||\\nabla u - \\nabla u_h||_{0}$', '$||\\nabla u - G(\\nabla u_h)||_{0}$'] ralg = FEMFunctionRecoveryAlg() Ndof = np.zeros((maxit,), dtype=np.int) errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float) for i in range(maxit): print('step:', i) fem = PoissonFEMModel(pde, mesh, 1, q=3) fem.solve() uh = fem.uh Ndof[i] = fem.mesh.number_of_nodes() errorMatrix[0, i] = fem.l2_error() errorMatrix[1, i] = fem.L2_error() errorMatrix[2, i] = fem.H1_semi_error() # rguh = ralg.harmonic_average(uh) # eta = fem.recover_estimate(rguh) eta = fem.residual_estimate()
meshtype = int(sys.argv[2]) n = int(sys.argv[3]) maxit = 4 box = [0, 1, 0, 1] if m == 1: pde = CosCosData() elif m == 2: pde = ExpData() elif m == 3: pde = PolynomialData() elif m == 4: pde = SinSinData() Mesh = Meshtype() ralg = FEMFunctionRecoveryAlg() errorType = [ #'$|| u_I - u_h ||_{l_2}$', #'$|| u - u_h||_{0}$', #'$||\\nabla u - \\nabla u_h||_{0}$', '$||\\nabla u - G(\\nabla u_h)||_{0}sim$', '$||\\nabla u - G(\\nabla u_h)||_{0}are$', '$||\\nabla u - G(\\nabla u_h)||_{0}har$', '$||\\nabla u - G(\\nabla u_h)||_{0}angle$', '$||\\nabla u - G(\\nabla u_h)||_{0}dhar$', '$||\\nabla u - G(\\nabla u_h)||_{0}scr$', '$||\\nabla u - G(\\nabla u_h)||_{0}zz$', '$||\\nabla u - G(\\nabla u_h)||_{0}ppr$' ] Ndof = np.zeros((maxit, ), dtype=np.int) errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float)
# get the pde model pde = LShapeRSinData() mesh = pde.init_mesh(n=4, meshtype='tri') node = mesh.entity('node') cell = mesh.entity('cell') tmesh = Tritree(node, cell) errorType = ['$|| u_I - u_h ||_{l_2}$', '$|| u - u_h||_{0}$', '$||\\nabla u - \\nabla u_h||_{0}$', '$||\\nabla u - G(\\nabla u_h)||_{0}sim$',] maxit = 1 ralg = FEMFunctionRecoveryAlg() Ndof = np.zeros((maxit,), dtype=np.int) errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float) integrator = mesh.integrator(3) for i in range(maxit): print('step:', i) fem = PoissonFEMModel(pde, mesh, 1, integrator) fem.solve() uh = fem.uh Ndof[i] = fem.mesh.number_of_nodes() errorMatrix[0, i] = fem.get_l2_error() errorMatrix[1, i] = fem.get_L2_error() errorMatrix[2, i] = fem.get_H1_error() rguh = ralg.simple_average(uh)