start = timer() ilu = spilu(A.tocsc(), drop_tol=1e-6, fill_factor=40) end = timer() print('time:', end - start) M = LinearOperator((N, N), lambda x: ilu.solve(x)) start = timer() uh.T.flat[:], info = cg(A, F, tol=1e-8, M=M) # solve with CG print(info) end = timer() print('time:', end - start) elif True: I = space.rigid_motion_matrix() P = space.stiff_matrix(c=2 * pde.mu) isBdDof = space.set_dirichlet_bc(uh, pde.dirichlet, threshold=pde.is_dirichlet_boundary) solver = LinearElasticityLFEMFastSolver(A, P, I, isBdDof) start = timer() uh[:] = solver.solve(uh, F) end = timer() print('time:', end - start, 'dof:', A.shape) elif False: A0 = space.stiff_matrix(c=2 * pde.mu) isBdDof = space.set_dirichlet_bc(uh, pde.dirichlet, threshold=pde.is_dirichlet_boundary) P = space.rigid_motion_matrix() solver = LinearElasticityLFEMFastSolver_2(A, A0, P, isBdDof) start = timer() uh[:] = solver.solve(uh, F)
from fealpy.solver import HighOrderLagrangeFEMFastSolver p = int(sys.argv[1]) n = int(sys.argv[2]) box = [0, 1, 0, 1] mf = MeshFactory() mesh = mf.boxmesh2d(box, nx=n, ny=n, meshtype='tri') pde = CosCosData() space = LagrangeFiniteElementSpace(mesh, p=p) uh = space.function() isBdDof = space.set_dirichlet_bc(uh, pde.dirichlet) A = space.stiff_matrix() F = space.source_vector(pde.source) P = mesh.linear_stiff_matrix() I = space.linear_interpolation_matrix() solver = HighOrderLagrangeFEMFastSolver(A, F, P, I, isBdDof) uh = solver.solve(uh, F) error = space.integralalg.error(pde.solution, uh) print(error) fig = plt.figure() axes = fig.gca()