FEM_50
A Finite Element Program
in 50 Lines of MATLAB


FEM_50 is a MATLAB program which applies the finite element method to solving Laplace's equation in an arbitrary region, using about 50 lines of MATLAB code, by Jochen Alberty, Carsten Carstensen, Stefan Funken.

FEM_50 is partly a demonstration, to show how little it takes to implement the finite element method (at least using every possible MATLAB shortcut.) The user supplies datafiles that specify the geometry of the region and its arrangement into triangular and quadrilateral elements, and the location and type of the boundary conditions, which can be any mixture of Neumann and Dirichlet.

The unknown state variable U(x,y) is assumed to satisfy Laplace's equation:

-Uxx(x,y) - Uyy(x,y) = F(x,y) in Omega
with Dirichlet boundary conditions
U(x,y) = U_D(x,y) on GammaD
and Neumann boundary conditions on the outward normal derivative:
Un(x,y) = G(x,y) on GammaN
If Gamma designates the boundary of the region Omega, then we presume that
Gamma = GammaD + GammaN
but the user is free to determine which boundary conditions to apply. Note, however, that the problem will generally be singular unless at least one Dirichlet boundary condition is specified.

The code uses piecewise linear basis functions for triangular elements, and piecewise isoparametric bilinear basis functions for quadrilateral elements.

The user is required to supply a number of data files and MATLAB functions that specify the location of nodes, the grouping of nodes into elements, the location and value of boundary conditions, and the right hand side function in Laplace's equation. Note that the fact that the geometry is completely up to the user means that just about any two dimensional region can be handled, with arbitrary shape, including holes and islands.

Usage:

fem_50
runs the program.

Related Data and Programs:

FD2D_HEAT_EXPLICIT_SPMD, a MATLAB program which uses the finite difference method and explicit time stepping to solve the time dependent heat equation in 2D. A black and white image is used as the "initial condition". MATLAB's SPMD facility is used to carry out the computation in parallel.

FEM_50_HEAT a MATLAB program which is a modified version of FEM_50 suitable for solving the heat equation.

FEM2D_HEAT, a MATLAB program which uses the finite element method and the backward Euler method to solve the 2D time-dependent heat equation on an arbitrary triangulated region. In order to run, it requires user-supplied routines that define problem data.

FEM2D_HEAT_RECTANGLE, a MATLAB program which solves the 2D time dependent heat equation on the unit square, using a uniform grid of triangular elements.

FEM2D_HEAT_SPARSE, a MATLAB program which solves the time dependent heat equation in an arbitrary triangulated 2D region, using MATLAB's sparse matrix storage format and solver.

FEM2D_HEAT_SPARSE_SQUARE, a MATLAB library which defines the geometry of a square region, as well as boundary and initial conditions for a given heat problem, so that fem2d_heat_sparse can be called for a solution.

FEM2D_HEAT_SQUARE, a MATLAB library which defines the geometry of a square region, as well as boundary and initial conditions for a given heat problem, so that fem2d_heat can be called for a solution.

HOT_PIPE, a MATLAB program which uses FEM_50_HEAT to solve the heat equation for a pipe model.

HOT_POINT, a MATLAB program which uses FEM_50_HEAT to solve the heat equation for a 2D region with a hot point.

Author:

Jochen Alberty,
Carsten Carstensen,
Stefan Funken.

Reference:

  1. Jochen Alberty, Carsten Carstensen, Stefan Funken,
    Remarks Around 50 Lines of MATLAB: A Short Finite Element Implementation,
    Numerical Algorithms,
    Volume 20, Number 2-3, August 1999, pages 117-137.
  2. Carsten Carstensen's web page "http://www.math.hu-berlin.de/~cc".
  3. Hans Rudolf Schwarz,
    Finite Element Methods,
    Academic Press, 1988,
    ISBN: 0126330107,
    LC: TA347.F5.S3313..
  4. Gilbert Strang, George Fix,
    An Analysis of the Finite Element Method,
    Cambridge, 1973,
    ISBN: 096140888X,
    LC: TA335.S77.
  5. Olgierd Zienkiewicz,
    The Finite Element Method,
    Sixth Edition,
    Butterworth-Heinemann, 2005,
    ISBN: 0750663200,
    LC: TA640.2.Z54

Source Code:

Examples and Tests:

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


Last revised on 13 December 2011.