Finite Element Solution of Poisson's Equation
on a Triangulated Region

FEM2D_POISSON is a FORTRAN90 program which applies the finite element method to solve a form of Poisson's equation over an arbitrary triangulated region.

The computational region is unknown by the program. The user specifies it by preparing a file containing the coordinates of the nodes, and a file containing the indices of nodes that make up triangles that form a triangulation of the region.

Normally, the user does not type in this information by hand, but has a program fill in the nodes, and perhaps another program that constructs the triangulation. However, in the simplest case, the user might construct a very crude triangulation by hand, and have TRIANGULATION_REFINE refine it to something more reasonable.

For the following ridiculously small example:

        |\   |\
        | \  | \
        |  \ |  \
        |   \|   \
the node file would be:
         0.0 0.0
         1.0 0.0
         2.0 0.0
         0.0 1.0
         1.0 1.0
and the triangle file would be
        1 2 4
        5 4 2
        2 3 5

The program is set up to handle the linear Poisson equation with a right hand side function, and nonhomogeneous Dirichlet boundary conditions. The state variable U(X,Y) is then constrained by:

        - Del H(x,y) Del U(x,y) + K(x,y) * U(x,y) = F(x,y)  inside the region;
                                           U(x,y) = G(x,y)  on the boundary.

An improved version of the program would handle a more interesting nonlinear PDE, and include optional Neumann boundary conditions.

To specify the boundary condition function G(x,y), the coefficients H(x,y) and K(x,y) and the right hand side function F(x,y), the user has to modify a file containing three subroutines,

To run the program, the user compiles the user routines, links them with FEM2D_POISSON, and runs the executable.

The program writes out a file containing an Encapsulated PostScript image of the nodes and elements, with numbers. If there are too many nodes, the plot may be too cluttered to read. For lower values, however, it is a valuable map of what is going on in the geometry.

The program is also able to write out a file containing the solution value at every node. This file may be used to create contour plots of the solution.


The user must create an executable by compiling the user routines and linking them with the main program, perhaps by commands like:

        gfortran -c fem2d_poisson.f90
        gfortran -c user.f90
        gfortran fem2d_poisson.o user.o
        mv a.out fem2d_poisson

Assuming the executable program is called "fem2d_poisson", then the program is executed by

fem2d_poisson prefix
where prefix is the common filename prefix, so that


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


FEM2D_POISSON is available in a C++ version and a FORTRAN90 version and a MATLAB version.

Related Programs:

FEM2D_POISSON_CG, a FORTRAN90 program which solves Poisson's equation on a triangulated region, using the finite element method, sparse storage, and a conjugate gradient solver.

FEM2D_POISSON_ELL, a FORTRAN90 library which defines the geometry of an L-shaped region, as well as boundary conditions for a given Poisson problem, and is called by FEM2D_POISSON as part of a solution procedure.

FEM2D_POISSON_LAKE, a FORTRAN90 library which defines the geometry of a lake-shaped region, as well as boundary conditions for a given Poisson problem, and is called by FEM2D_POISSON as part of a solution procedure.

FEM2D_POISSON_SPARSE, a FORTRAN90 program which solves the steady (time independent) Poisson equation on an arbitrary 2D triangulated region using a version of GMRES for a sparse solver.


  1. Hans Rudolf Schwarz,
    Methode der Finiten Elemente,
    Teubner Studienbuecher, 1980,
    ISBN: 3-519-02349-0.
  2. Gilbert Strang, George Fix,
    An Analysis of the Finite Element Method,
    Cambridge, 1973,
    ISBN: 096140888X,
    LC: TA335.S77.
  3. Olgierd Zienkiewicz,
    The Finite Element Method,
    Sixth Edition,
    Butterworth-Heinemann, 2005,
    ISBN: 0750663200.

Source Code:

List of Routines:

You can go up one level to the FORTRAN90 source codes.

Last revised on 01 January 2011.