FreeFem++
Third Edition, Version 3.50
http://www.freefem.org/ff++
Fr´ed´eric Hecht
1 2
mailto:frederic.hecht@upmc.fr
https://www.ljll.math.upmc.fr/
˜
hecht
In collaboration with:
• Sylvian Auliac, mailto:auliac@ann.jussieu.fr, http://www.ann.jussieu.fr/
auliac is PHD student at LJLL , he do all the new optimization interface with nlopt, ipopt,
cmaes, ...
• Olivier Pironneau, mailto:olivier.pironneau@upmc.fr, http://www.ann.jussieu.
fr/pironneau Olivier Pironneau is a professor of numerical analysis at the university of
Paris VI and at LJLL. His scientific contributions are in numerical methods for fluids. He is
a member of the Institut Universitaire de France and of the French Academy of Sciences
• Jacques Morice, mailto:morice@ann.jussieu.fr. Jacaues Morice is a Post-Doct at
LJLL. His doing is Thesis in University of Bordeaux I on fast multipole method (FMM). In
this version, he do all three dimensions mesh generation and coupling with medit software.
• Antoine Le Hyaric, mailto:lehyaric@ann.jussieu.fr, http://www.ann.jussieu.
fr/
˜
lehyaric/ Antoine Le Hyaric is a research engineer from the ”Centre National de la
Recherche Scientifique” (CNRS) at LJLL . He is an expert in software engineering for sci-
entific applications. He has applied his skills mainly to electromagnetics simulation, parallel
computing and three-dimensional visualization.
• Kohji Ohtsuka,mailto:ohtsuka@hkg.ac.jp, http://www.comfos.org/ Kohji Oht-
suka is a professor at the Hiroshima Kokusai Gakuin University, Japan and chairman of the
World Scientific and Engineering academy and Society, Japan chapter. His research is in
fracture dynamics, modeling and computing.
• Pierre Jolivet, mailto:pierre.jolivet@enseeiht.fr, http://jolivet.perso.
enseeiht.fr/ is a CNRS researcher, he did the MPI interface with PETSc, HPDDM...
Acknowledgments We are very grateful to l’
´
Ecole Polytechnique (Palaiseau, France) for printing the
second edition of this manual (http://www.polytechnique.fr ), and to l’Agence Nationale de
la Recherche (Paris, France) for funding of the extension of FreeFem++ to a parallel tridimensional
version (http://www.agence-nationale-recherche.fr) R´ef´erence : ANR-07-CIS7-002-
01.
1
Laboratoire Jacques-Louis Lions, Universit´e Pierre et Marie Curie, Paris
2
Projet Alpines, Inria Rocquencourt.
4
Contents
1 Introduction 13
1.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.1.1 For everyone: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.1.2 For the pros: Installation from sources . . . . . . . . . . . . . . . . . 15
1.2 How to use FreeFem++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.3 Environment variables, and the init file . . . . . . . . . . . . . . . . . . . . . 20
1.4 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2 Getting Started 23
2.0.1 FEM by FreeFem++ : how does it work? . . . . . . . . . . . . . . . 24
2.0.2 Some Features of FreeFem++ . . . . . . . . . . . . . . . . . . . . . 29
2.1 The Development Cycle: Edit–Run/Visualize–Revise . . . . . . . . . . . . . 29
3 Learning by Examples 31
3.1 Membranes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2 Heat Exchanger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.3 Acoustics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.4 Thermal Conduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.4.1 Axisymmetry: 3D Rod with circular section . . . . . . . . . . . . . . 41
3.4.2 A Nonlinear Problem : Radiation . . . . . . . . . . . . . . . . . . . . 42
3.5 Irrotational Fan Blade Flow and Thermal effects . . . . . . . . . . . . . . . . 42
3.5.1 Heat Convection around the airfoil . . . . . . . . . . . . . . . . . . . 44
3.6 Pure Convection : The Rotating Hill . . . . . . . . . . . . . . . . . . . . . . 45
3.7 The System of elasticity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.8 The System of Stokes for Fluids . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.9 A Projection Algorithm for the Navier-Stokes equations . . . . . . . . . . . 52
3.10 Newton Method for the Steady Navier-Stokes equations . . . . . . . . . . . . 56
3.11 A Large Fluid Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.12 An Example with Complex Numbers . . . . . . . . . . . . . . . . . . . . . . 62
3.13 Optimal Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.14 A Flow with Shocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.15 Classification of the equations . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.16 Optimize Time depend schema for Heat equation . . . . . . . . . . . . . . . 70
3.17 Tutorial to write a transient Stokes solver in matrix form . . . . . . . . . . . 71
5