## FreeFem++ Tutorial – Part 1

First of all, FreeFem is a numerical computing software which allows a fast and automatized treatment of a variety of problems related to partial differential equations. Its name, FreeFem, speaks for itself: it is free and it uses the finite element method. Here are a few reasons for which you may choose to use FreeFem for a certain task:

- It allows the user to easily define 2D (and 3D) geometries and it does all the work regarding the construction of meshes on these domains.
- The problems you want to solve can be easily written in the program once we know their weak forms.
- Once we have variables defined on meshes or solutions to some PDE, we can easily compute all sorts of quantities like integral energies, etc.

Before showing a first example, you need to install FreeFem. If you are not familiar with command line work or you just want to get to work, like me, you can install the visual version of FreeFem which is available here. Of course, you can find example programs in the FreeFem manual or by making a brief search on the internet.

I’ll present some basic stuff, which will allow us in the end to solve the Laplace equation in a circular domain. Once we have the structure of the program, it is possible to change the shape of the domain in no time.

## Simple triangle mesh – Matlab code

There are cases when you need to define a simple, regular mesh on a *nice* set, like a triangle, or a polygon. There are software which are capable of creating such meshes, but most of them will require some computation time (Delaunay triangulation, plus optimization, edge swapping, etc.). I propose to you a simple algorithm for defining a mesh on a triangle. Of course, this can be extended to polygons or other cases (I used a variant of it to create a mesh of a spherical surface).

The idea is very simple: start with three points , and define the (only) initial triangle as . Then, at each step, take a triangle from the list , add the midpoints of to the list of points and replace the triangle with the four smaller triangles determined by the vertices and midpoints of . This is a basic mesh refining strategy. Thus, in short, we start with a triangle and do a number of mesh refinements, until we reach the desired side-length. Of course, at each step we should be careful not to add the midpoint of an edge two times (once for every neighbouring triangle), but in what follows, I will always remove duplicates by bruteforce in the end (not the most economic solution).

## Regularity of the weak solution Part 1

I will present here how to recover the regularity of a weak solution for the Dirichlet problem. The arguments can easily be adapted to most of the weak formulations involving the Laplace operator, the essential tool being the estimate of the norm of the derivatives of the solution . The arguments are adapted from H. Brezis, *Functional Analysis, Sobolev Spaces and Partial Differential Equations*, Chapter 9, and the tool named the *method of translations* is due to L. Niremberg.

Consider the problem

whose weak variational form is

Note that in the variational form we only assume , and to be able to recover the PDE we need to use Green’s formula, which is valid if .

## Weak formulation for Laplace Equation with Robin boundary conditions

Consider an open set with Lipschitz boundary and consider on the following problem

where is a constant. This is the Laplace equation with Robin boundary conditions. I will prove that the problem is well posed and for each there exists a solution .

## Finite Difference Method for 2D Laplace equation

[Edit: This is, in fact Poisson’s equation.]

[For solving this equation on an arbitrary region using the finite difference method, take a look at this post.]

I will present here how to solve the Laplace equation using finite differences 2-dimensional case:

## Lax Milgram application

Let and . Consider the bilinear form

1. Check that is a continuous symmetric bilinear form and that implies .

2. Prove that is coercive.

3. Deduce that for every there exists a unique satisfying

What is the corresponding minimization problem?

4. Show that the solution of belongs to (and in particular ). Determine the equation and the boundary conditions satisfied by .

5. Assume that , and let be the solution of . Prove that belongs to for every . Show that if and only if .

6. Determine explicitly the solution of when is a constant.

7. Set , where is the solution of and . Check that is a self-adjoint compact operator from into itself.

8. Study the eigenvalues of .

*H. Brezis, Functional Analysis*

## One dimensional trace of a Sobolev function

Check that the mapping from to is a continuous linear functional on . Deduce that there exists a unique such that

Show that is the solution of some differential equation with appropriate boundary conditions and compute explicitly.

*H. Brezis, Functional Analysis, Ex 8.18*