fem2d_poisson_rectangle_linear, a FORTRAN90 code which solves the 2D Poisson equation using the finite element method over a rectangular region using a uniform mesh of linear triangular elements.

The computational region is a rectangle, with Dirichlet boundary conditions applied along the boundary. The state variable U(X,Y) is then constrained by:

        - ( Uxx + Uyy ) = F(x,y)  in the region
                 U(x,y) = G(x,y)  on the region boundary

The computational region is first covered with an NX by NY rectangular array of points, creating (NX-1)*(NY-1) subrectangles. Each subrectangle is divided into two triangles, creating a total of 2*(NX-1)*(NY-1) geometric "elements".

We now assume that the unknown function U(x,y) can be represented as a linear combination of the basis functions associated with each node. For each node I, we determine a basis function PHI(I)(x,y), and evaluate the following finite element integral:

        Integral ( Ux(x,y) * PHIx(I)(x,y) + Uy(x,y) * PHIy(I)(x,y) ) =
        Integral ( F(x,y) * PHI(I)(x,y)
The set of all such equations yields a linear system for the coefficients of the representation of U.


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


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

Related Data and codes:

FEM2D, a data directory which contains examples of 2D FEM files, text files that describe a 2D finite element geometry and associated nodal values;

FEM2D_HEAT_RECTANGLE, a FORTRAN90 code which solves the 2D time dependent heat equation on the unit square.

FEM2D_POISSON_RECTANGLE, a FORTRAN90 code which solves the 2D Poisson equation on a rectangle, using the finite element method, and piecewise quadratic triangular elements.



  1. Hans Rudolf Schwarz,
    Finite Element Methods,
    Academic Press, 1988,
    ISBN: 0126330107,
    LC: TA347.F5.S3313.
  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,
    LC: TA640.2.Z54

Source Code:

Last revised on 08 July 2020.