load "msh3"

// Parameters
int nn = 20; // Mesh quality

// Mesh
int[int] labs = [1, 2, 2, 1, 1, 2]; // Label numbering
mesh3 Th = cube(nn, nn, nn, label=labs);
// Remove the ]0.5,1[^3 domain of the cube
Th = trunc(Th, (x < 0.5) | (y < 0.5) | (z < 0.5), label=1);

// Fespace
fespace Vh(Th, P1);
Vh u, v;

// Macro
macro Grad(u) [dx(u), dy(u), dz(u)] //

// Define the weak form and solve
solve Poisson(u, v, solver=CG)
    = int3d(Th)(
          Grad(u)' * Grad(v)
          1 * v
    + on(1, u=0)

// Plot
plot(u, nbiso=15);

A high level multiphysics finite element software

FreeFEM offers a fast interpolation algorithm and a language for the manipulation of data on multiple meshes.

Easy to use PDE solver

FreeFEM is a popular 2D and 3D partial differential equations (PDE) solver used by thousands of researchers across the world. It allows you to easily implement your own physics modules using the provided FreeFEM language. FreeFEM offers a large list of finite elements, like the Lagrange, Taylor-Hood, etc., usable in the continuous and discontinuous Galerkin method framework.

Numerous physics are pre-built :

  • Incompressible Navier-Stokes (using the P1-P2 Taylor Hood element)
  • Lamé equations (linear elasticity)
  • Neo-Hookean, Mooney-Rivlin (nonlinear elasticity)
  • Thermal diffusion
  • Thermal convection
  • Thermal radiation
  • Magnetostatics
  • Electrostatics
  • Fluid-structure interaction (FSI)

Strong mesh and parallel capabilities

FreeFEM has it own internal mesher, called BAMG, and is compatible with the best open-source mesh and visualization software like Tetgen, Gmsh, Mmg and ParaView. Written in C++ to optimize for speed, FreeFEM is interfaced with the popular mumps, PETSc and HPDDM solvers.

Latest Articles

April 08, 2019 | Colin Leclercq, Fabrice Demourant, Charles Poussot-Vassal and Denis Sipp

Linear iterative method for closed-loop control of quasiperiodic flows

This work proposes a feedback-loop strategy to suppress intrinsic oscillations of resonating flows in the fully nonlinear regime. The frequency response of the flow is obtained from the resolvent operator about the mean flow, extending the framework initially introduced by McKeon & Sharma (J. Fluid Mech., vol. 658, 2010, pp. 336–382) to study receptivity mechanisms in turbulent flows. Using this linear time-invariant model of the nonlinear flow, modern control methods such as structured -synthesis can be used to design a controller. The approach is successful in damping self-sustained oscillations associated with specific eigenmodes of the mean-flow spectrum. Despite excellent performance, the linear controller is however unable to completely suppress flow oscillations, and the controlled flow is effectively attracted towards a new dynamical equilibrium. This new attractor is characterized by a different mean flow, which can in turn be used to design a second controller. The method can then be iterated on subsequent mean flows, until the coupled system eventually converges to the base flow. An intuitive parallel can be drawn with Newton’s iteration: at each step, a linearized model of the flow response to a perturbation of the input is sought, and a new linear controller is designed, aiming at further reducing the fluctuations. The method is illustrated on the well-known case of two-dimensional incompressible open-cavity flow at Reynolds number , where the fully developed flow is initially quasiperiodic (2-torus state). The base flow is reached after five iterations. The present work demonstrates that nonlinear control problems may be solved without resorting to nonlinear reduced-order models. It also shows that physically relevant linear models can be systematically derived for nonlinear flows, without resorting to black-box identification from input–output data; the key ingredient being frequency-domain models based on the linearized Navier–Stokes equations about the mean flow. Applicability to amplifier flows and turbulent dynamics has, however, yet to be investigated.

April 05, 2019 | Johann Moulin, Pierre Jolivet, Olivier Marquet

Augmented Lagrangian preconditioner for large-scale hydrodynamic stability analysis

Hydrodynamic linear stability analysis of large-scale three-dimensional configurations is usually performed with a “time-stepping” approach, based on the adaptation of existing solvers for the unsteady incompressible Navier–Stokes equations. We propose instead to solve the nonlinear steady equations with the Newton method and to determine the largest growth-rate eigenmodes of the linearized equations using a shift-and-invert spectral transformation and a Krylov–Schur algorithm. The solution of the shifted linearized Navier–Stokes problem, which is the bottleneck of this approach, is computed via an iterative Krylov subspace solver preconditioned by the modified augmented Lagrangian (mAL) preconditioner (Benzi et al., 2011). The well-known efficiency of this preconditioned iterative strategy for solving the real linearized steady-state equations is assessed here for the complex shifted linearized equations. The effect of various numerical and physical parameters is investigated numerically on a two-dimensional flow configuration, confirming the reduced number of iterations over state-of-the-art steady-state and time-stepping-based preconditioners. A parallel implementation of the steady Navier–Stokes and eigenvalue solvers, developed in the FreeFEM language, suitably interfaced with the PETSc/SLEPc libraries, is described and made openly available to tackle three-dimensional flow configurations. Its application on a small-scale three-dimensional problem shows the good performance of this iterative approach over a direct factorization strategy, in regards of memory and computational time. On a large-scale three-dimensional problem with 75 million unknowns, a 80% parallel efficiency on 256 up to 2,048 processes is obtained.

March 27, 2019 | Amina Benaceur, Alexandre Ern, Virginie Ehrlacher

A reduced basis method for parametrized variational inequalities applied to contact mechanics

We investigate new developments of the Reduced-Basis (RB) method for parametrized optimization problems with nonlinear constraints. We propose a reduced-basis scheme in a saddle-point form combined with the Empirical Interpolation Method to deal with the nonlinear constraint. In this setting, a primal reduced-basis is needed for the primal solution and a dual one is needed for the Lagrange multipliers. We suggest to construct the latter using a cone-projected greedy algorithm that conserves the non-negativity of the dual basis vectors. The reduction strategy is applied to elastic frictionless contact problems including the possibility of using non-matching meshes. The numerical examples confirm the efficiency of the reduction strategy.


21-23 MAY 2019

HPCSE 2019 - Ostrava, Czech Republic

High Performance Computing in Science and Engineering

3-5 JUNE 2019

COUPLED 2019 - Sitges (Barcelona)

Brain imaging with FreeFEM.

19-21 JUNE 2019

Rencontre Mathématiques de Rouen

Introduction to FreeFEM version 4

You are in good company

Sorbonne université INRIA ANR Genci CNRS