Chapter 1
Introduction

A partial differential equation is a relation between a function of several variables and its (partial) derivatives. Many problems in physics, engineering, mathematics and even banking are modeled by one or several partial differential equations.

FreeFem++ is a software to solve these equations numerically. As its name says, it is a free software (see copyright for full detail) based on the Finite Element Method; it is not a package, it is an integrated product with its own high level programming language. This software runs on all UNIX OS (with g++ 2.95.2 or later, and X11R6) , on Window95, 98, 2000, NT, XP, and MacOS X.

Moreover FreeFem++ is highly adaptive. Many phenomena involve several coupled system, for example: fluid-structure interactions, Lorenz forces for aluminium casting and ocean-atmosphere problems are three such systems. These require different finite element approximations degrees, possibly on different meshes. Some algorithms like Schwarz’ domain decomposition method also require data interpolation on multiple meshes within one program. FreeFem++ can handle these difficulties, i.e. arbitrary finite element spaces on arbitrary unstructured and adapted bi-dimensional meshes.

The characteristics of FreeFem++ are:

1.1 Installation

First open the following web page

http://www.freefem.org/ff++/

And choose your platform: Linux, Windows, MacOS X, or go to the end of the page to get the full list of downloads.

Remark: Binaries are available for Microsoft Windows and Apple Mac OS X and Linux.

1.1.1 Installation from sources

Only for those who need to recompile FreeFem++ or install it from the source code:

To compile the documentation and the application under MS-Windows we have used the LATEX and the cygwin environment from

http://www.cygwin.com

and under MacOS X we have used the apple Developer Tools Xcode, LATEX from http://www.ctan.org/system/mac/texmac.

FreeFem++ must be compiled and installed from the source archive. This archive is available from:

http://www.freefem.org/ff++/index.htm

To extract files from the compressed archive freefem++-(VERSION).tar.gz to a directory called

freefem++-(VERSION)

enter the following commands in a shell window :


tar zxvf freefem++-(VERSION).tar.gz
cd freefem++-(VERSION)

To compile and install FreeFem++ , just follow the INSTALL and README files. The following programs are produced, depending on the system you are running (Linux, Windows, MacOS) :

After installation, The list of application ( depending of the system and the compiling option ) can be :

  1. FreeFem++, standard version, with a graphical interface based on GLUT/OpenGL (use ffglut visualizator) or not just add -nw parameter.
  2. ffglut the visualisator through a pipe of freefem++ (remark: if ffglut is not in the system path, you have no plot)
  3. FreeFem++-nw, postscript plot output only (batch version, no graphics windows via ffglut )
  4. FreeFem++-mpi, parallel version, postscript output only
  5. Sorry, the integrated development environment is reconstruction with the new architecture
  6. /Applications/FreeFem++.app, Drag and Drop CoCoa MacOs Application
  7. bamg , the bamg mesh generator
  8. cvmsh2 , a mesh file convertor
  9. drawbdmesh , a mesh file viewer
  10. ffmedit the freefem++ version of medit software (thank to P. Frey)

Remark, in most cases you can set the level of output (verbosity) to value nn by adding the parameters -v nn on the command line.

As an installation test, under unix: go into the directory examples++-tutorial and run FreeFem++ on the example script LaplaceP1.edp with the command :


FreeFem++ LaplaceP1.edp

If you are using nedit as your text editor, do one time nedit -import edp.nedit to have coloring syntax for your .edp files.

The syntax of tools FreeFem++,FreeFem++-nw on the command-line are

where the part in [] is optional.

1.1.2 Windows binaries install

First download the windows installation file, then execute the download file to install FreeFem++. In Select Additional Task windows, check once the ”Add application directory to your system path your system path ..” boxes, because the screen on-the-fly plot is done with programm ffglut.exe and it can be not found.

After that you have two new icons on your desktop:

where (VERSION) is the version of the files (for example 2.3-0-P4).

By default, the installed files are in

C:\Programs Files\FreeFem++

In this directory, you have all the .dll files and and other applications: FreeFem++-nw.exe,ffglut.exe, ... the FreeFem++ application without graphic windows.

The syntax of tools on the command-line are same

Link with other text editor

Crimson Editor
at http://www.crimsoneditor.com/ and adapt it as follows:
winedt
for Windows : this is the best but it could be tricky to set up. Download it from

this is a multipurpose text editor with advanced features such as syntax coloring; a macro is available on www.freefem.org to localize winedt to FreeFem++ without disturbing the winedt functional mode for LateX, TeX, C, etc. However winedt is not free after the trial period.

TeXnicCenter
for Windows: this is the easiest and will be the best once we find a volunteer to program the color syntax. Download it from

It is also an editor for TeX/LaTeX. It has a ”‘tool”’ menu which can be configured to launch FreeFem++ programs as in:

nedit
on the Mac OS, Cygwin/Xfree and linux, to import the color syntax do

nedit -import edp.nedit


PIC

Figure 1.1: The 3 panels of the integrated environment built with the Crimson Editor with FreeFem++ in action. The Tools menu has an item to launch FreeFem++ by a Ctrl+1 command.

1.1.3 MacOS X binaries install

Download the MacOS X binary version file, extract all the files with a double click on the icon of the file, go the the directory and put the FreeFem+.app application in the /Applications directory. If you want a terminal access to FreeFem++ just copy the file FreeFem++ in a directory of your $PATH shell environment variable.

If you want to automatically launch the FreeFem++.app, double click on a .edp file icon. Under the finder pick a .edp in directory examples++-tutorial for example, select menu File -> Get Info an change Open with: (choose FreeFem++.app) and click on button change All....

1.2 How to use FreeFem++

Under MacOS X with Graphic Interfaces For testing or running an .edp file, just drag and drop the file icon on the MacOS application FreeFem++.app icon. You can also use the menu: File Open after launching the application.

One of the best ways on MacOS is to use the text editor mi.app

http://www.mimikaki.net/en/

and to use the edp mode stored in mode-mi-edp.zip. After downloading and installing the mi editor, unzip mode-mi-edp.zip and put the created folder in the folder opened with the mi.app menu Option->Open Mode Folder menu and set mi as the default application for all the .edp files.


PIC
Figure 1.2: Screen of edp with mi text editor


Under terminal First choose the type of application from FreeFem++, FreeFem++-nw, FreeFem++-mpi, …depending on your pleasure, system, etc…. Next you enter, for example


 FreeFem++ your-edp-file-path

1.3 Environment variables, and the init file

FreeFem++ reads a user’s init file named freefem++.pref to initialize global variables: verbosity, includepath, loadpath.

Remark: the variable verbosity changes the level of internal printing (0, nothing (except mistake), 1 few, 10 lots, etc. ...), the default value is 2. The include files are searched from the includepath list and the load files are searched from loadpath list.

The syntax of the file is:

     verbosity= 5  
     loadpath += "/Library/FreeFem++/lib"  
     loadpath += "/Users/hecht/Library/FreeFem++/lib"  
     includepath  += "/Library/FreeFem++/edp"  
     includepath  += "/Users/hecht/Library/FreeFem++/edp"  
     #  comment  
     load += "funcTemplate"  
     load += "myfunction"

The possible paths for this file are

We can also use shell environment variable to change verbosity and the search rule before the init files.

    export FF_VERBOSITY=50  
    export FF_INCLUDEPATH="dir;;dir2"  
    export FF_LOADPATH="dir;;dir3""

Remark: the separator between directories must be ”;” and not ”:” because ”:” is used under Windows.

Remark, to show the list of init of freefem++, do

Brochet$ export FF_VERBOSITY=100; ./FreeFem++-nw  
 --  verbosity is set to 100  
 insert init-files /etc/freefem++.pref $  
...

1.4 History

The project has evolved from MacFem, PCfem, written in Pascal. The first C version lead to freefem 3.4; it offered mesh adaptativity on a single mesh only.

A thorough rewriting in C++ led to freefem+ (freefem+ 1.2.10 was its last release), which included interpolation over multiple meshes (functions defined on one mesh can be used on any other mesh); this software is no longer maintained but still in use because it handles a problem description using the strong form of the PDEs. Implementing the interpolation from one unstructured mesh to another was not easy because it had to be fast and non-diffusive; for each point, one had to find the containing triangle. This is one of the basic problems of computational geometry (see Preparata & Shamos[18] for example). Doing it in a minimum number of operations was the challenge. Our implementation is O(nlog n) and based on a quadtree. This version also grew out of hand because of the evolution of the template syntax in C++.

We have been working for a few years now on FreeFem++ , entirely re-written again in C++ with a thorough usage of template and generic programming for coupled systems of unknown size at compile time. Like all versions of freefem it has a high level user friendly input language which is not too far from the mathematical writing of the problems.

The freefem language allows for a quick specification of any partial differential system of equations. The language syntax of FreeFem++ is the result of a new design which makes use of the STL [26], templates and bison for its implementation; more detail can be found in [12]. The outcome is a versatile software in which any new finite element can be included in a few hours; but a recompilation is then necessary. Therefore the library of finite elements available in FreeFem++ will grow with the version number and with the number of users who program more new elements. So far we have discontinuous P0 elements,linear P1 and quadratic P2 Lagrangian elements, discontinuous P1 and Raviart-Thomas elements and a few others like bubble elements.