FEM2D_POISSON_SPARSE is a C++ program which applies the finite element method to solve a form of Poisson's equation over an arbitrary triangulated region, using sparse matrix storage and an iterative solver.
This program is a revised version of FEM2D_POISSON.
FEM2D_POISSON used a direct LINPACK/LAPACK banded matrix solver. The storage requirements for the banded solver are less than for a full storage solver, but still grow quickly as the - problem size increases.
FEM2D_POISSON_SPARSE reduces the storage requirements even further, by using sparse matrix techniques. The storage format chosen is known as DSP or "sparse triplet" format, which essentially simply saves in three vectors A, IA, JA, which record the value, row and column of every nonzero entry. To solve the linear system, the MGMRES iterative solver was applied. With these modifications, FEM2D_POISSON_SPARSE can handle problems much larger than those that FEM2D_POISSON could. A new issue is that the iterative solver must be monitored to ensure that convergence is proceeding properly, and has reached the desired tolerance.
The computational region is 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:
4----5 |\ |\ | \ | \ | \ | \ | \| \ 1----2----3the node file would be:
0.0 0.0 1.0 0.0 2.0 0.0 0.0 1.0 1.0 1.0and the triangle file would be
1 2 4 5 4 2 2 3 5
The program is set up to handle the linear Poisson equation with a right hand side function, and nonhomogeneous Dirichlet boundary conditions. The state variable U(X,Y) is then constrained by:
- Del H(x,y) Del U(x,y) + K(x,y) * U(x,y) = F(x,y) inside the region; U(x,y) = G(x,y) on the boundary.
A fancier version of the program is eventually intended, which will handle a more interesting nonlinear PDE, and include optional Neumann boundary conditions.
To specify the right hand side function F(x,y), the linear coefficients H(x,y) and K(x,y) and the boundary condition function G(x,y), the user has to modify a file containing three routines,
To run the program, the user compiles the user routines, links them with FEM2D_POISSON_SPARSE, and runs the executable.
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.
Assuming the executable program is called "my_problem", then the program is executed by
my_problem prefixwhere prefix is the common filename prefix, so that:
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
FEM2D_POISSON_SPARSE is available in a C++ version and a FORTRAN90 version and a MATLAB version.
FEM2D_POISSON, a C++ program which solves Poisson's equation on a triangulated region, using the finite element method and a banded solver. In order to run, it requires user-supplied routines that define problem data.
FEM2D_POISSON_CG, a C++ program which solves Poisson's equation on a triangulated region, using the finite element method, sparse storage, and a conjugate gradient solver.
FEM2D_POISSON_SPARSE_BAFFLE, a C++ library which defines the geometry of a rectangle channel containing 13 hexagonal baffles, as well as boundary conditions for a given Poisson problem, and is called by fem2d_poisson_sparse as part of a solution procedure.
FEM2D_POISSON_SPARSE_ELL, a C++ library which defines the geometry of an L-shaped region, as well as boundary conditions for a given Poisson problem, and is called by fem2d_poisson_sparse as part of a solution procedure.
FEM2D_POISSON_SPARSE_LAKE, a C++ library which defines the geometry of a lake-shaped region, as well as boundary conditions for a given Poisson problem, and is called by fem2d_poisson_sparse as part of a solution procedure.
MGMRES, a C++ library which applies the restarted Generalized Minimum Residual (GMRES) algorithm to solve a sparse linear system, by Lili Ju.
You can go up one level to the C++ source codes.