fem2d_heat_sparse


fem2d_heat_sparse, a MATLAB code which applies the finite element method to solve a form of the time-dependent heat equation over an arbitrary triangulated region.

The linear system is created and stored using MATLAB's sparse matrix storage. The system is factored and solved by MATLAB, using sparse matrix solution techniques.

This program is derived from a similar program, FREE_FEM_HEAT, which uses banded storage, factorization and solution methods.

The geometry is entirely external to the program. The user specifies one file of nodal coordinates, and one file that describes the triangles in terms of six node coordinates.

The program makes a default assumption that all boundary conditions correspond to Dirichlet boundary conditions. The user can adjust these boundary conditions (and even specify Dirichlet constraints on any variable at any node) by setting the appropriate data in certain user routines.

If a Neumann condition is to be specified, it must have a zero right hand side.

Computational Region

The computational region is initially 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:

       10-11-12
        |\   |\
        | \  | \
        6  7 8  9
        |   \|   \
        1-2--3--4-5
      
the node file would be:
         0.0  0.0
         1.0  0.0
         2.0  0.0
         3.0  0.0
         4.0  0.0
         0.0  1.0
         1.0  1.0
         2.0  1.0
         3.0  1.0
         0.0  2.0
         1.0  2.0
         2.0  2.0
      
and the element file would be
         1  3 10  2  7  6
         3  5 12  4  9  8
        12 10  3 11  7  8
      

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

        Ut - ( Uxx + Uyy ) + K(x,y,t) * U = F(x,y,t)  in the region
                                        U = G(x,y,t)  on the boundary
                                        U = H(x,y,t)  at initial time TINIT.
      

To specify the right hand side function F(x,y,t), the linear coefficient K(x,y,t), the boundary condition function G(x,y,t), and the initial condition H(x,y,t), the user has to supply four functions,

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.

Usage:

To run the program, the user must write the user files described above, make all the files associated with fem2d_heat_sparse available in the same directory, or in the user's MATLAB path, and supply the names of the node and triangle files to the main program:

fem2d_heat_sparse ( 'prefix' )
where 'prefix' is the common input filename prefix:

Licensing:

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

Languages:

fem2d_heat_sparse is available in a MATLAB version.

Related Data and Programs:

fem2d_heat_sparse_test

Reference:

  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 21 April 2019.