solve(a == L, u, bc) # Plot solution # plot(u) # axi.triplot(u) vtkfile << u # Compute error at vertices # u_e = interpolate(u_D, V) # error = np.abs(u_e.vector().array() - u.vector().array()).max() # print('t = %.2f: error = %.3g' % (t, error)) # Update previous solution u_n.assign(u) # Compute error in L2 norm error_L2 = errornorm(u_D, u, 'L2') # Compute maximum error at vertices vertex_values_u_D = u_D.compute_vertex_values(mesh) vertex_values_u = u.compute_vertex_values(mesh) error_max = np.max(np.abs(vertex_values_u_D - vertex_values_u)) # Print errors print('error_L2 =', error_L2) print('error_max =', error_max) # Hold plot # interactive() # plt.show()