fem2d_poisson_rectangle_linear, a MATLAB code which solves the 2D Poisson equation using the finite element method with piecewise 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 GNU LGPL license.
fem2d_poisson_rectangle_linear is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.
fem2d_poisson_rectangle, a MATLAB code which solves the 2D Poisson equation on a rectangle, using the finite element method, and piecewise quadratic triangular elements.