One framework to simulate (nearly) every problem: Welcome, OpenFOAM!

One framework to simulate (nearly) every problem: Welcome, OpenFOAM!
Visualisation of the dambreak case using ParaFOAM: glyphs color and direction according to velocity field.

The topic of our projects in Istanbul is simulation and visualisation of bioflow in coronary arteries. Since a lot about visualisation software such as ParaView and Visit has already been said, today we want to introduce the simulation software we will be dealing with: OpenFOAM. The software is designed for a wide variety of computational problems like the simulation of fluid motion or the deformation of solid structures. OpenFOAM allows you to create your own geometry or import it from other sources, giving you a lot of freedom in the design and in the treatment of your problem. Last but not least: it is open source and you can download it for free!

First of all, the installation process itself was not easy. There are pre-compiled versions available on the OpenFOAM project page, but only for a few Linux distributions and versions. Matteo uses a old Fedora version on his Laptop. Hannes uses Linux Mint, which is a distribution based on Ubuntu. Since the version was hopelessly outdated, he had to update first to a more recent version of Linux Mint. Then, issuing $(lsb_release -cs) as described in the installation guide, does give the name of the Mint version, but not of the Ubuntu version. He had to replace the right keyword in the /etc/apt/sources.list.d/openfoam.list manually. After all, the installation is very simple if you use a recent version of any standard Linux distribution; if not, it gets complicated.

To get to know the program better, we started working through the user manual in detail. The following example from OpenFOAM is particularly nice: a column of water at rest is located behind a membrane on the left side of a tank. At the beginning of the simulation, the membrane is removed and the column of water collapses. During this process, the water impacts an obstacle at the bottom of the tank and creates a complicated but fascinating flow structure.

Visualisation of the dambreak case using ParaFOAM: glyphs color and direction according to velocity field.

Visualisation of the dambreak case using ParaFOAM: glyphs color and direction according to velocity field.

And here it comes: High Performance Computing. Even for this rather simple example, the execution time on one processor takes already several minutes. Conveniently, OpenFOAM has already some basic built-in MPI parallelisation. For the geeks :-), the data for the following animation was produced on a dual core Intel i5 processor and the total execution time was nearly nine minutes (in desktop use). The final visualisation was done with ParaFOAM, the ParaView version natively built into OpenFOAM.

 

Whereas the dambreak simulation was only a test case to get used to the program, after that we have started with the very first part of our project. The aim is to simulate blood flow in coronary arteries, and how the geometry of the vessel influences it. In the beginning, we consider a two-dimensional case where the vessel splits up in a broad and a narrow branch (think of a bypass). Assuming a density of 1060 kg/m³ and a dynamic viscosity of 0.004 kg/m/s (typical values for blood), we solve the incompressible Navier-Stokes equations. On the following picture, you see the velocity magnitude and the numerical grid for the case when we impose a constant inflow at the left boundary:

Velocity magnitude and numerical grid for the two-dimensional bifurcation simulation

Velocity magnitude and numerical grid for the two-dimensional bifurcation simulation

We also implemented the unsteady case where the inflow velocity changes in time. In the following movie, you see the velocity magnitude and some streamlines of the blood flow when we apply a periodic “pulsation” at the left boundary:

For all who are interested, you can download the source files here. First, the grid must be created by issuing the command blockMesh. Then, the simulation is started by typing icoFoam. The results can be visualised with ParaFOAM.

Co-authors: Matteo & Hannes

Tagged with: , , , , , ,
2 comments on “One framework to simulate (nearly) every problem: Welcome, OpenFOAM!
  1. Nathan says:

    I enjoyed reading the article. Even if it is a early stage, will you deal with (e.g.) plaques or similar problems?

    • Matteo says:

      Thanks Nathan! Our projects will focus on patient-specific geometries and conditions starting from real CT and MR data, so I guess it depends on how healthy our subjects are…I have to be honest: I am thrilled by this prospective development, but maybe they are not! 😛

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.