FEM_50
A Finite Element Program
in 50 Lines of MATLAB


FEM_50 is a set of MATLAB routines to apply the finite element method to solving Laplace's equation in an arbitrary region, using about 50 lines of MATLAB code.

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 (inside of MATLAB, of course!)

Related Data and Programs:

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

FEM_BASIS_T3_DISPLAY is a MATLAB program which displays a basis function associated with a linear triangle ("T3") mesh.

FEM_BASIS_T6_DISPLAY is a MATLAB program which reads a quadratic triangle mesh and displays any associated basis function.

FEM_IO is a set of MATLAB routines for reading or writing the node, element and data files that define a finite element model.

FEM_SAMPLE is a MATLAB library of routines for evaluating a finite element function defined on an order 3 or order 6 triangulation.

FEM_TO_TEC is a MATLAB program that can convert an FEM model into a TEC graphics file.

FEM1D is a MATLAB program which applies the finite element method, with piecewise linear basis functions, to a linear two point boundary value problem;

FEM1D_ADAPTIVE is a MATLAB program that applies the finite element method to a linear two point boundary value problem in a 1D region, using adaptive refinement to improve the solution.

FEM1D_NONLINEAR is a MATLAB program that applies the finite element method to a nonlinear two point boundary value problem in a 1D region.

FEM1D_PMETHOD is a MATLAB program that applies the p-method version of the finite element method to a linear two point boundary value problem in a 1D region.

FEM2D_HEAT is a MATLAB program that solves the time dependent heat equation in the unit square.

FEM2D_POISSON is a MATLAB program for solving Poisson's equation on a square, using the finite element method.

FEMPACK is a MATLAB library of routines for finite element calculations.

FFP_SPARSE is a MATLAB program that solves the Poisson equation in an arbitrary triangulated 2D region, using MATLAB's sparse matrix storage format and solver.

FREE_FEM_HEAT is a MATLAB program for solving the heat equation on an arbitrary triangulated region, using the finite element method.

FREE_FEM_NAVIER_STOKES is a MATLAB program for solving the steady incompressible Navier Stokes equations on an arbitrary triangulated region, using the finite element method.

FREE_FEM_POISSON is a MATLAB program for solving Poisson's equation on a triangulated region, using the finite element method.

FREE_FEM_STOKES is a MATLAB program for solving the Stokes equations on a triangulated region, using the finite element method.

HOT_PIPE is a sample problem that can be run with FEM_50_HEAT.

HOT_POINT is a sample problem that can be run with FEM_50_HEAT.

PLTMG_SINGLE is a FORTRAN77 library of routines for solving elliptic partial differential equations using the finite element method with piecewise linear triangles and the multigrid approach.

TRIANGULATION_ORDER3 is a directory which contains a description of the format for the files describing an order 3 triangulation.

Reference:

  1. Jochen Alberty, Carsten Carstensen, Stefan Funken,
    Remarks Around 50 Lines of MATLAB:
    Short Finite Element Implementation,
    Numerical Algorithms,
    Volume 20, pages 117-137, 1999,
    Available as "../../pdf/acf.pdf".
  2. Carsten Carstensen's web page "http://www.math.hu-berlin.de/~cc".
  3. Hans Rudolf Schwarz,
    Methode der Finiten Elemente,
    Teubner Studienbuecher, 1980.
  4. Gilbert Strang, George Fix,
    An Analysis of the Finite Element Method,
    Prentice Hall, 1973.
  5. Olgierd Zienkiewicz,
    The Finite Element Method,
    McGraw Hill, Third Edition, 1977.

Source Code:

Examples and Tests:

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


Last revised on 31 August 2005.