Esempio n. 1
0
Ndof = np.zeros((maxit, ), dtype=np.int)

for i in range(maxit):

    V = function_space(mesh, 'Lagrange', degree)
    Ndof[i] = V.number_of_global_dofs()
    uh = FiniteElementFunction(V)

    a = BihamonicRecoveryForm(V, sigma=2)
    L = SourceForm(V, model.source, 4)

    BC = DirichletBC(V, model.dirichlet, isBoundaryDof)
    solve(a, L, uh, BC, 'direct')
    error[i] = L2_error(model.solution, uh, order=4)
    ruh = recover_grad(uh)
    derror[i] = div_error(model.laplace, ruh, order=4)
    gerror[i] = L2_error(model.gradient, ruh, order=4)

    if i < maxit - 1:
        mesh.uniform_refine()

print(Ndof)
print('L2 error:\n', error)
order = np.log(error[0:-1] / error[1:]) / np.log(2)
print('order:\n', order)

print('div error:\n', derror)
order = np.log(derror[0:-1] / derror[1:]) / np.log(2)
print('order:\n', order)

print('gradient error:\n', gerror)
Esempio n. 2
0
    fem = BiharmonicRecoveryFEMModel(V, model, sigma=sigma, rtype=rtype)
    bc = DirichletBC(V, model.dirichlet)
    solve(fem, uh, dirichlet=bc, solver='direct')
    fem.recover_grad(uh, rgh)
    fem.recover_laplace(rgh, rlh)

    eta1 = fem.grad_recover_estimate(uh, rgh)
    eta2 = fem.laplace_recover_estimate(rgh, rlh, etype=1, order=2)

    Ndof[i] = V.number_of_global_dofs()
    errorMatrix[0, i] = L2_error(model.solution, uh, order=5)
    errorMatrix[1, i] = H1_semi_error(model.gradient, uh, order=5)
    errorMatrix[2, i] = np.sqrt(np.sum(eta1**2))
    errorMatrix[3, i] = L2_error(model.gradient, rgh, order=5)
    errorMatrix[4, i] = div_error(model.laplace, rgh, order=5)
    errorMatrix[5, i] = L2_error(model.laplace, rlh, order=5)
    errorMatrix[6, i] = np.sqrt(np.sum(eta2**2))

#order = np.log(error[0:-1]/error[1:])/np.log(2)

show_error_table(Ndof, errorType, errorMatrix, end='\\\\\\hline\n')

optionlist = ['k-*', 'b-o', 'r--^', 'g->', 'm-8', 'c-D', 'y-x']
fig = plt.figure()
axes = fig.gca()
showmultirate(axes, 1, Ndof, errorMatrix, optionlist, errorType)
axes.legend(loc=3)
axes.axis('tight')
plt.show()