The finite element method (FEM) is used extensively in science and engineering. The relative ease of establishing the governing equations for analysis of continuum and structures, as well as the compact and well-defined linear algebra and matrix operations that are associated with it, makes FEM an attractive computational tool. Plenty has been said and written about FEM; for that you should see, among many others, Bathe, Irons, or Zienkiewic [1,2,3].
Unfortunately, the same reasons that make FEM an attractive mathematical tool make it a challenging programming task. Quite often programming FEM is hard, involving a wide variety of software engineering and numerical analysis dilemmas. It is intimidating to program FEM from scratch, and often it is hard to customize commercial FEM products for new and specific problems.
I wrote a framework to provide an intuitive programming language by abstracting FEM operations to a level that is very close to the mathematical notations used in expressing the governing equations. The inner complexity of these operations are hidden, thus the framework provides a useful tool for prototyping FEM programs.
If you are able to understand FEM in terms of the following integral, which describes the physical equations in a form such as
where is an integrable operator in space and time, you should be able to program this equation with a simple statement such as:
A simplified list of functionality in a typical FEM program can be given as follows.
1. Linear algebra. The practical implementation of finite element analysis usually involves extensive use of matrix algebra. These include algebraic operations such as addition, subtraction, inner products, and more complex operations such as matrix inversion, solutions of systems of equations, matrix decomposition (e.g., QR, LU, LLT), change of basis, and transformations.
2. Computations of the finite element integrals. FEM transforms partial differential equations (PDEs) into integral equations. The evaluation of integrals is an important task in finite element analysis. The results of the computations of these integrals are usually referred to as the "element integrals" or the "element matrices/vectors." The principal idea is to achieve a relationship between the physical fields such as displacements, velocities, stresses, temperatures, magnetic charges, and so on, and discrete approximations of these fields. We do this by using a finite dimensional function space defined by basis functions (also known as the trial functions, interpolation functions, or shape functions). These functions provide an effective and efficient means of evaluating the element integrals.
3. Global operations. Practical implications of FEM are probably most obvious at the 10,000 foot level. Simple element-level integrals are combined to describe the global behavior of an arbitrarily complex problem. Local behavior and even some singularities can be captured by special elements. The assembly of these small elements describes the global problem. The global operations include assembly, imposition of essential and natural boundary conditions, solutions of the linear/nonlinear systems of algebraic equations, time integration of ordinary differential equations (ODEs), and so on.
The framework will be demonstrated in the following sections. It is assumed that the reader has some familiarity with FEM, linear algebra, and PDEs. The initial section introduces the framework, followed by FEM element integrals. The second section describes and demonstrates the global FEM operations. Finally, the last section studies an example implementation of the Laplacian operator.
Converted by Mathematica