Programming of Finite Element Solvers

The present chapter explains the usage of Diffpack’s finite element toolbox. The model problems are kept quite simple in order to concentrate on programming details. In Chapters 3.1–3.8 we deal with the Poisson equation. A trivial extension to the convect

  • PDF / 25,183,261 Bytes
  • 208 Pages / 439 x 666 pts Page_size
  • 9 Downloads / 211 Views

DOWNLOAD

REPORT


Programming of Finite Element Solvers The present chapter explains the usage of Diffpack 's finite element toolbox. The model problems are kept quite simple in order to concentrate on programming details. In Chapters 3.1-3.8 we deal with the Poisson equation. A trivial extension to the convection-diffusion equation is exemplified in Chapter 3.9. Chapters 3.10-3.13 demonstrate that only minor extensions of the Poisson equat ion solvers are needed to handle time-dependent problems, in this case the heat equation. Finally, Chapter 3.15 brings in some new tools for particularly efficient solution of PDEs with time-independent coefficients. The required background for working with this chapter is knowledge of the finite element method (at least the material corresponding to Chapters 2.12.7) and basic concepts in C++ and Diffpack (at least Chapters 1.1-1.4, 1.6.1-1.6.3, and 1.6.5; Chapter 1.7 is also useful). Only linear problems are treated in the present chapter. Finite element solvers for nonlinear PDEs constitute the topic of Chapter 4.2, where we reuse the tools from linear problems and basically only add some functionality for administering an outer iteration loop. The application of these tools to problems in fluid and solid mechanics is the subject of Chapters 5-7. When you encounter the more advanced physical applications later in this book, you will see that the Diffpack implementation is quite easy to understand and develop further as soon as you are familiar with how to apply Diffpack to Poisson- and heat/diffusion-type problems, i.e., Chapter 3. The present chapter is comprehensive, and if the aim is to quickly get an overview of how Diffpack can handle applications involving nonlinear timedependent problems, it is suggested to read Chapters 3.1, 3.2, 3.5.11, and 3.10, before moving on to Chapter 4.2. The mentioned background material from the present chapter is sufficient for reading Chapters 3.6 and 3.13, which are step-by-step explanations of how one works with Diffpack to develop solvers for a real physical (heat transfer) applications. We recommend to view the introductory solvers PoissonO and Poisson1 in Chapters 3.1 and 3.2 as pedagogical steps towards a finite element program, the Poisson2 solver in Chapter 3.5, that has sufficient flexibility for use in research. A similar refinement of the solvers appear in the time-dependent examples as well; Heat2 is the suggested solver to reuse.

H P Langtangen, Computational Partial Differential Equations © Springer-Verlag Berlin Heidelberg 2003

252

3. Programming of Finite Element Solvers

3.1

A Simple Program for the Poisson Equation

We shall first deal with a scalar stationary PDE:

(3.1) (3.2)

-\1 . [k(x )\1u(x)] = f(x) , u(x )

= g(x) ,

where f(x) , g(x) , and k(x) are given functions, u(x ) is the primary unknown, and anE is the complet e boundary! of the dom ain n. Our aim is to create a short pro gram , utilizing Diffpack's finite element toolbox, to solve t his problem numerically. 3.1.1

Discretization

We assume that the reader is capable of