OpenFOAM is now a well known opensource CFD solution constantly evolving and able to compete with the most famous industrial solutions on the market, like Fluent or StarCCM+. Besides having an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to acoustics, solid mechanics and electromagnetics, OpenFOAM offers a good documentation from software installation to first steps with already set-up cases and tutorials.

Résultat de recherche d'images pour "openfoam logo"

Considering that the OpenCFD and the Scilab Teams are now part of the same entity (ESI-Group), there will be new tools leveraging the assets of both software giving Scilab and OpenFOAM users the opportunity to bring their simulation to a whole new level. Here is a first and quick tutorial for an easy use of OpenFOAM within Scilab.

Installing OpenFOAM

As said, the documentation is great. So see this link to download and compile OpenFOAM source code.

Quick Introduction to OpenFOAM process

OpenFOAM simulation set-up is made through a set of text files call Dictionaries located in a specific case directory.

\relax \special {t4ht=

As shown on above image, this case directory is devided into :

  • System directory : Simulation parameters, schemes
  • Constant directory : Mesh and flow properties definition
  • Time directories : Needed field for specific time steps

Dictionaries are meant to be parameters for OpenFOAM utilities and solvers, that are applications. For any application, the form of the command line entry can be found by simply entering the application name at the command line with the -help option. You just have to run it specifying (or not) your case directory.

See OpenFOAM User Guide and Tutorial Guide for more informations.

OpenFOAM & Scilab make simulation rocks together

Let’s see how to make basic interactions between Scilab and OpenFOAM. Our case for this example is a NACA 0012 airfoil simulated at different angle of attack.

  • Workspace

Considering that every OpenFOAM applications (solvers & utilities) can be used on any directory using the parameter -case, you can work anywhere you want. In this example we will work in the airfoil case directory and will start by creating a new directory called Results, in which we will gather the pressure on the mesh for a defined set of angle of attack.

Now it is scripting time :

  • OpenFOAM applications

With OpenFOAM source code compiled, you have access to all of the OpenFOAM applications just by calling them in the command line terminal. For that to work, you just have to source the openFOAM bashrc file. To do so, use the unix function for shell command execution in Scilab:


  • Simulation set-up from Scilab

This case is about studying a NACA 0012 airfoil behavior within a stream characterized by : Reynolds number = 3M, Mach number = 0.15 (V = 51.9m/s) and set of angle of attack = -1, 0, 1, 2, 8, 15, 16, 17, 18, 19, 20 and 21 deg.


Now the idea is to change the velocity U in the 0 time directory and run the simulation for all cases using a for loop.


First, make sure to clean your time directories before you run a simulation using a classical Allclean file (you can find in every OpenFOAM tutorial) or making it your self using the unix command rm -rf. Once this is done, you can change your initial condition regarding the velocity using what you computed earlier:


Note that line 17, 19 and 21 of U file are just about adding blank space.

Now run your case using the OpenFOAM solver you need. If you are running your simulation parallel just use the decomposePar utility first and the reconstructPar utility for reconstruction.


Nota: unix_w function is the same as the unix function but display shell outputs in Scilab shell.


Now just extract your pressure field at the last iteration (4000 here) and put it in the Results directory you created earlier. So shall your loop end.

  • Post-processing

It is now time for you to post-process your data leveraging OpenFOAM capabilities (postProcess utility) combined with Scilab specific features in signal processing, optimization, control system, etc …

PressureFielda0_8_17_20Scilab plot of pressure field for angle of attack: 0, 8, 17 and 20 deg


This tutorial was just a quick introduction on how to make a combined use of OpenFOAM and Scilab to achieve powerful CFD simulation and analysis. Try this on your own and do not hesitate to share your idea and issues you face with both communities. More tools and tutorials are coming on that same topic.

Thank you to Pawan Ghildiyal (OpenCFD Team) for his contribution to this paper.