## FreeFem to Matlab – fast mesh import

I recently wrote a brief introduction to FreeFem++ in this post. FreeFem is a software designed for the numerical study of partial differential equations. It has the advantage of being able to easily define the geometry of the domain, construct and modify meshes, finite element spaces and solve problems on these meshes.

I use Matlab very often for numerical computations. Most of the numerical stuff I’ve done (take a look here if you want) was based on finite differences methods, fundamental solutions and other classical techniques different from finite elements methods. Once I started using finite elements I quickly realized that Matlab is not that easy to work with if you want some automated quality meshing. PDEtool is good, but defining the geometry is not easy. There is also a simple tool: distmesh which performs a simple mesh construction for simple to state geometries. Nevertheless, once you have to define finite element spaces and solve problems things are not easy…

This brings us to the topic of this post: is it possible to interface Matlab and FreeFem? First, why would someone like to do this? Matlab is easier to code and use than FreeFem (for one who’s not a C expert…), but FreeFem deals better with meshes and solving PDE with finite elements. Since FreeFem can be called using system commands, it is possible to call a static program from Matlab. FreeFem can save meshes and variables to files. Let’s see how can we recover them in Matlab.

There is a tool called “FreeFem to Matlab” developed by Julien Dambrine (link on Mathworks). There’s also a longer explanation in this blog post. I recently tried to use the tool and I quickly found that it is not appropriate for large meshes. It probably scans the mesh file line by line which makes the loading process lengthy for high quality meshes. Fortunately there’s a way to speed up things and I present it below. I will not cover the import of the data (other than meshes) since the function *importdata* from the FreeFem to Matlab tool is fast enough for this.

## IMC 2016 – Day 2 – Problem 8

**Problem 8.** Let be a positive integer and denote by the ring of integers modulo . Suppose that there exists a function satisfying the following three properties:

- (i) ,
- (ii) ,
- (iii) for all .

Prove that modulo .

## IMC 2016 – Day 2 – Problem 7

**Problem 7.** Today, Ivan the Confessor prefers continuous functions satisfying for all . Fin the minimum of over all preferred functions.

## IMC 2016 – Day 2 – Problem 6

**Problem 6.** Let be a sequence of positive real numbers satisfying . Prove that

## IMC 2016 Problems – Day 2

**Problem 6.** Let be a sequence of positive real numbers satisfying . Prove that

**Problem 7.** Today, Ivan the Confessor prefers continuous functions satisfying for all . Fin the minimum of over all preferred functions.

**Problem 8.** Let be a positive integer and denote by the ring of integers modulo . Suppose that there exists a function satisfying the following three properties:

- (i) ,
- (ii) ,
- (iii) for all .

Prove that modulo .

**Problem 9.** Let be a positive integer. For each nonnegative integer let be the number of solutions of the inequality . Prove that for every we have .

**Problem 10.** Let be a complex matrix whose eigenvalues have absolute value at most . Prove that

(Here for every matrix and for every complex vector .)

Official source and more infos here.

## IMC 2016 – Day 1 – Problem 2

**Problem 2.** Let and be positive integers. A sequence of matrices is *preferred* by Ivan the Confessor if for , but for with . Show that if in al preferred sequences and give an example of a preferred sequence with for each .

## IMC 2016 – Day 1 – Problem 3

**Problem 3.** Let be a positive integer. Also let and be reap numbers such that for . Prove that