Exemplo n.º 1
0
        plt.figure()
        plot_mesh.plot_mesh(pts, tri, x)

    # Try the triangular mesh with P1 elements:
    if False:
        import poisson_optimized as poisson
        pts, tri, bc_nodes = create_mesh.tri_circle()

        # forcing term at mesh nodes
        f_pts = f(pts)
        # Dirichlet boundary conditions at *all* mesh nodes (most of these values are not used)
        u_bc_pts = u_bc(pts)

        tic = time.clock()
        A, b = poisson.poisson(pts, tri, bc_nodes, f_pts, u_bc_pts, FEM.P1,
                               FEM.GaussTri1())
        toc = time.clock()
        print "Matrix assembly took %f s" % (toc - tic)

        print "cond(A) = %3.3f" % np.linalg.cond(A.todense())

        tic = time.clock()
        x = spsolve(A.tocsr(), b)
        toc = time.clock()
        print "Sparse solve took %f s" % (toc - tic)

        # Plot:
        plt.figure()
        plot_mesh.plot_mesh(pts, tri)
        plt.figure()
        plot_mesh.plot_mesh(pts, tri, x)