<- previous    index    next ->

Lecture 32, Finite Element Method


A brief introduction to the "Finite Element Method" FEM,
using the Galerkin Method is galerkin.pdf

There are entire books on FEM and this just covers one small view.

Examples demonstrating the above galerkin.pdf
are shown below. The examples are for Degree 1 (linear), Order 1 through 4,
Dimension 1 through 7. Several programming languages are shown for
some of the examples. Results were close to the same in time and
accuracy for various languages. 

The first two examples use three methods of integration:
Adaptive, Newton-Coates and Gauss-Legendre.
For these cases Gauss-Legendre was best.

fem_checke_la.c  first order, one dimension
fem_checke_la_c.out  output with debug print

fem_checke_la.adb  first order, one dimension
fem_checke_la_ada.out  output with debug print

fem_checke_la.f90  first order, one dimension
fem_checke_la_f90.out  output with debug print


fem_check4th_la.c  fourth order, one dimension
fem_check4th_la_c.out  output with debug print

fem_check4th_la.adb  fourth order, one dimension
fem_check4th_la_ada.out  output with debug print

fem_check4th_la.f90  fourth order, one dimension
fem_check4th_la_f90.out  output with debug print


fem_check22_la.c  second order, two dimension
fem_check22_la_c.out  output with debug print

fem_check22_la.adb  second order, two dimension
fem_check22_la_ada.out  output with debug print

fem_check22_la.f90  second order, two dimension
fem_check22_la_f90.out  output with debug print

fem_check22_la.java  second order, two dimension
fem_check22_la_java.out  output with debug print

with a small study of grid size and integration order, solution with exp(g(x,y))
fem_check22e_la.java  second order, two dimension
fem_check22e_la_java.out  output with debug print


fem_check_abc_la.c  second order, two dimension
fem_check_abc_la_c.out  output with debug print
abc_la.h problem definition
abc_la.c problem definition

fem_check_abc_la.adb  second order, two dimension
fem_check_abc_la_ada.out  output with debug print
abc_la.ads problem definition
abc_la.adb problem definition

fem_check_abc_la.f90  second order, two dimension
fem_check_abc_la_f90.out  output with debug print
abc_la.f90 problem definition


fem_check33_la.c third order, three dimension
fem_check33_la_c.out  output with debug print

fem_check33_la.f90 third order, three dimension
fem_check33_la_f90.out  output with debug print

fem_check33_la.adb third order, three dimension
fem_check33_la_ada.out  output with debug print

fem_check33_la.java third order, three dimension
fem_check33_la_java.out  output with debug print
npx=3 gave error 10^-12, npx=4 gave error 10^-13  little better for bigger npx



fem_check44_la.c fourth order, four dimension
fem_check44_la_c.out  output with debug print

fem_check44_la.f90 fourth order, four dimension
fem_check44_la_f90.out  output with debug print

fem_check44_la.adb fourth order, four dimension
fem_check44_la_ada.out  output with debug print

fem_check44_la.java fourth order, four dimension
fem_check44_la_java.out  output with debug print


fem_check47h_la.c fourth order, seven dimension
fem_check47h_la_c.out  output with debug print

fem_check47h_la.java fourth order, seven dimension
fem_check47h_la_java.out  output with debug print




In getting ready for this lecture, I have tried many versions of FEM.
The "historic" or classic methods used very low order orthogonal
polynomials and a piecewise linear approach. The trade-off I found was
the time to solve of very large systems of equations vs the time for
numerical quadrature for a much smaller system of equations.

Another trade-off was the complexity of coding the special cases
that arise in piecewise linear approximations. There are many
published tables and formulas for the general case using many
geometric shapes. What is generally missing is the tables and
formulas for the cells next to the boundary.

I found that developing a library routine for the various derivatives
of phi and using high order Lagrange polynomials led to minimizing
programming errors. Each library routine must, of course, be 
thoroughly tested. Here are my Lagrange phi routines and tests.

laphi.h  "C" header file
laphi.c  code through 4th derivative
test_laphi.c  numeric test
test_laphi_c.out  test output
plot_laphi.c  plot test

laphi.ads Ada package specification
laphi.adb  code through 4th derivative
test_laphi.adb  numeric test
test_laphi_ada.out  test output

laphi.f90 module through 4th derivative
test_laphi.f90  numeric test
test_laphi_f90.out  test output

laphi.java class through 4th derivative
test_laphi.java  numeric test
test_laphi_java.out  test output

Other files, that are needed by some examples above:
aquade.ads Ada package specification
aquade.adb tailored adaptive quadrature
gaulegf.adb Gauss-Legendre quadrature
simeq.adb solve simultaneous equations
real_arrays.ads Ada package specification
real_arrays.adb types Real, Real_Vector, Real_Matrix
aquad3.h  "C" header file
aquad3.c tailored adaptive quadrature
aquad3e.f90 tailored adaptive quadrature
gaulegf.f90 Gauss-Legendre quadrature
simeq.f90 solve simultaneous equations
gaulegf.java Gauss-Legendre quadrature
simeq.java solve simultaneous equations

A simple PDE and solution, well lots of code:

ΔU = Uxx + Uyy = F(x,y) = 2Π2*(cos(2Π*x)*sin2(Π*y) + sin2(Π*x)*cos(2Π*y)) Known solution U(x,y) =sin2(Π*x)*sin2(Π*y) Using utility routines .c and .h above fem22_la.c source code fem22_la_c.out output fem22_la_c.dat computed solution for plot fem22_la_c.sh gnuplot driver fem22_la_c.plot gnuplot control fem22_la_c.png the result plot Run with Makefile entry: fem22_la_c.out: fem22_la.c simeq.h simeq.c gaulegf.h gaulegf.c laphi.h laphi.c gcc -o fem22_la fem22_la.c simeq.c gaulegf.c laphi.c -lm fem22_la > fem22_la_c.out rm -f fem22_la ./fem22_la_c.sh # gnuplot uses fem22_la_c.plot fem22_la_c.dat
    <- previous    index    next ->

Other links

Go to top