FOAMY Lectures

CFD Lectures with OpenFOAM

by Dr. Cuneyt Sert

Lecture 1. Introduction

1.1 What is OpenFOAM?

OpenFOAM is a software framework (or toolbox) that you can use to develop Finite Volume Method based solvers for general continuum mechanics problems, mostly for fluid flow and heat transfer. It is a huge library of about 1.5 million lines of C++ code located in hundreds of files. You can use this toolbox to develop Computational Fluid Dynamics (CFD) solvers. You can use it to develop incompressible and compressible flow solvers for steady and unsteady problems. You can write solvers for single phase or multiphase flows, isothermal flows or flows with heat transfer, solvers with fixed or moving boundaries, maybe with fluid-structure interaction, maybe using rotating reference frames. You can develop solvers to simulate combustion, elasticity or electromagnetics. Once the toolbox with the necessary ingredients is there, the choices are endless, you can do whatever you want with it. The following image taken from Chris Greenshield's OpenFOAM Open Dev 2018 talk shows the general structure of OpenFOAM.

alt text

"FOAM" stands for Field Operation And Manipulation. Thermofluidic transport problems involving fluid mechanics and heat transfer are called “field” problems because we are interested in calculating the velocity, pressure, density, temperature, concentration, etc. fields. The history of OpenFOAM goes back to late 1980s, to the research work of several graduate students in Prof. David Gosman's team at Imperial College, London, where it was being called just FOAM. Interestingly, today, Prof. Gosman has no relation with OpenFOAM, because he'd decided to walk on a different track, a commercial one, and founded CD-Adapco, the company that developed the popular CFD software CTAR-CD and Star-CCM+. These software are currently being sold by Siemens.

The “Open” part of the name is due to the fact that, today OpenFOAM is a free and open source software (FOSS). It was released as such and started to be called OpenFOAM after 2004. It is free in two different senses, which are the main principles of GNU General Public License (GPLv3), the license used by OpenFOAM.

People use OpenFOAM in mainly two different ways

1.2 The OpenFOAM Ecosystem

When you buy a commercial CFD software, it probably comes with an initial training, together with version update rights and technical support for a certain period. You usually get access to a customer portal where you can find extra learning resources and user forums for discussion and help. Being an open-source software, OpenFOAM's ecosystem is somewhat different. It involves Developers and Distributors:
As of today, OpenFOAM is being developed by a number of different groups and distributed through a couple of different websites. The historical perspective of the current situation is a bit complicated. If you are interested in it, you can have a look at
this short video and if you want more, search for "history of OpenFOAM". But be prepared for some nasty "I wrote it first! ... But I also contributed it a lot!", kind of controversies.

alt text The company OpenCFD, which is today a part of the ESI Group, develops and distributes OpenFOAM since 2005. They currently hold the OpenFOAM trademark. Their latest version is 21.06, released on June 28, 2021. To get an idea about how active this development group is, their recent release activity is as follows

They release two versions every year, first in June and then in December. 21.06 is the version released on the 6th month of the year 2021. But this versioning scheme got adapted after year 2016, and before that the releases were like 1.0, 2.0, etc. In 2016, their version number suddenly jumped from 3.0 to 16.06, possibly to differentiate themselves from the other groups distributing OpenFOAM.

OpenCFD releases OpenFOAM under GPLv3 license. Their source codes are kept here, where it is called OpenFOAM-plus. Plus? Yes. Up to year 2016 they were calling it OpenFOAM+, but then they decided to drop the "plus". Like any other GPL licensed open-source software, you can download these source files, compile them, report bugs if you notice any, modify the codes if you want, share your modifications with the developers to be included in the next release, or re-distribute them on your own, even maybe under a different name such as NextFOAM. Yes you can do that if you want. The license allows that.

This development is governed by a steering committee and several technical committees. There, you can find people from automobile companies such as Volkswagen and General Motors, people from CFD companies such TotalSim and Upstream CFD, and people from academia, etc. One important figure here is Prof. Hrvoje Jasak, one of the original developers of FOAM. Prof. Jasak is also the figure behind the foam-extend distribution of OpenFOAM, which will be mentioned below. There is also Mattijs Janssens, one of the original developers, who is also a major contributor in the CFD Direct group.

OpenCFD offers paid engineering consulting, training and cloud computing services. Unfortunately, the software is free but the training is not. And they sell a paid version of OpenFOAM, called Visual-CFD, which comes with a graphical user interface (GUI). Lacking a GUI is always considered to be one of the most critical disadvantages of OpenFOAM. Developing the code and releasing it for free, but then charging money to cure one of its most critical weaknesses is an interesting policy.

alt text The OpenFOAM Foundation and the company behind it, CFD Direct, also develop and distribute OpenFOAM through their site openfoam.org since 2014. The main figure behind this development is Dr. Henry Weller, who is considered by many as the creator of FOAM. He is still actively developing code for OpenFOAM. He was one of the founders of the OpenCFD company in 2004, but then left it to found CFD Direct in 2014.


Latest version of this distribution is 9, released on July 20, 2021. Their source files are kept at GitHub and just like the case for OpenCFD, you can download these sources freely and do whatever you want with them as long as you do not violate the license. Recent release history of this group is as follows As you can see, they release a new major version each year. Note that OpenCFD and CFD Direct groups prefer to number their releases in completely different ways. Their latests versions are numbered as 21.06 and 9, but both of them are actually released in 2021. Do not get confused by this inconsistency.

To keep their development efforts sustainable, CFD Direct asks for the monetary support of their users through fund-raising activities under the OpenFOAM Foundation umbrella. Also they offer paid support and training services all over the world, as well as cloud computing. Once again the software is free, but training is not.

The above mentioned two groups seem to be the most active developers and distributors of OpenFOAM. But there is one more.

alt text Prof. Hrvoje Jasak of Zagreb University, who is one of the original developers of FOAM and the founder of Wikki Ltd., has been releasing OpenFOAM under the name foam-extend since it was first open-sourced in 2004. Its last version is 4.0 released on 22 December 2016. Here are their source files. You can also get paid OpenFOAM training from Prof. Jasak.


User Community:
Like in any open-source project, the user community of OpenFOAM is quite special. Freedoms brought them together and they try to overcome the difficulties together. They got a high quality product freely and they feel the responsibility of giving back to the community, in one way or another. Helping each other becomes especially important when the official documentation is somewhat incomplete. They do this in various ways, such as by preparing tutorials, forming local user groups, preparing and sharing online course materials, answering questions in forums, or setting up wiki pages. Users can also report bugs that they encounter and contribute code if they've developed any.

Third Party Companies:
As OpenFOAM increased its popularity over the last years and gained the respect of users, companies other than the core developers listed above were established to make money out of it. Today there are several small companies offering training, engineering consulting and cloud computing services. Examples are alt text



1.3 Which OpenFOAM Should We Use?

It is hard to tell exactly what the differences in these different OpenFOAM branches developed by different groups, OpenCFD, CFD Direct and Wikki, are. Their core part, coming from the "FOAM years" should be the same. The most frequently used solvers and utilities, which are referred as the standard applications in the User Guide, seem to be the same. The User Guides that come with the CFD Direct and OpenCFD versions refer to these standard components in almost identical way. But those guides do not reflect the recent advances.

Over the years and especially after the separation of CFD Direct from OpenCFD in 2014, different code developers and communities added different features to their releases. If you look at the
release notes of OpenCFD’s version 19.06, you see details such as (the list is actually longer) And if you look at the release notes of CFD Direct’s version 7, you see details such as (the list is actually longer) The release notes of foam-extend’s version 4.0 list the following new features (the list is actually longer) The items in these lists are not important for us at this point. But as you can see, different groups keep adding different features and capabilities to their codes. Looks like that some of the changes made in one branch can get the chance of being included in the other in a future release. According to the following figure taken from OpenFOAM’s Wikipedia page, it looks like that, CFD Direct and foam-extend branches are actually contributing code to the OpenCFD branch, but I do not think that that's actually what happens in reality.



In foam-extend’s release 4.0 notes, there is a part titled as Main differentiators between foam-extend and OpenFOAM which says;

"A large number of features have been lost within the release of OpenFOAM since version 1.3, the code base has shrunk by more than 40%. While we understand the lack of technical ability of supporting advanced CFD features, we feel that existing features and specifically large-scale contributions should remain active and developed further. Below is a list of main features of foam-extend which are lacking, lost, deactivated or unusable in ESI releases: ..." (followed by a long list of such features)


FOSS world is proud of their licenses which allow and actually encourage the creation of alternatives. If you are not happy with the code, just fork it, modify it and redistribute it. Alternatives are good, but it may lead to fragmentation, which by some, in different contexts, is considered to be a negativity.

So which one should you choose today? The answer depends on what you want to do with OpenFOAM.

1.4 Advantages and Disadvantages of Using OpenFOAM

There are two lists in the
Wikipedia page of OpenFOAM answering these questions. In my opinion, among the items listed there, what actually matters most are the following

Advantages: Disadvantages: For many individuals or small companies with limited or no budget, cost may be the biggest concern in choosing a CFD software. For some others, like larger companies that just want a working tool for the task, cost may not be a concern at all. They may be after a proven technology with good, quick technical support when it is necessary. It is very difficult for such companies to switch from a popular commercial CFD software that they have been using for years to an open-source one. This is stated by the following quite interesting 9X Effect, quoted from here

"... whether or not a high-tech product succeeds can be explained by the “9x Effect”. In a very small nutshell, the 9x effect says that a potential user of a new product will underweight by a factor of three the benefits of a new product, and overweight by the same factor the costs of giving up their current solution. Human beings evaluate new things relative to the status quo, and we are risk averse (we exaggerate the cost of a loss in our minds). So if a new product is to succeed, it better be nine times better than the current solution."


Many companies and practicing engineers are not interested in code development/modification at all. They do not have the time or the resources for that. OpenFOAM being open-source is of no value for them. The steep learning curve, the absence of a GUI and poor documentation are headaches for them.

For researchers who develop code and do hard core CFD, having access to the source code is a must, and they value OpenFOAM mostly for that. When making a choice, they question how well-documented the source code is and how open it is for future development. OpenFOAM's code is praised for having good extensibility qualities, but its programmer’s guide is considered to be weak. Experienced code developers may find the programming paradigms used in it such as object-oriented programming, operator overloading or template meta-programming beautiful, but for the newcomers, these may make understanding the codes and going deep into them difficult. Researchers do not care much about having no GUI because they may actually think that working inside a terminal window is more productive. Research involves experimenting with new ideas, and with an open-source code with insufficient documentation, researchers will have to experiment a lot. They consider it to be a part of the research process.

For me as a FOSS enthusiast and an academician,

1.5 The Issue of Having No Graphical User Interface (GUI)

All commercial CFD software come with a GUI, like many other software we use, with windows, menus, buttons, check boxes, text entries, etc. In that GUI, they usually have built-in CAD capabilities for geometry creation or the software integrates seamlessly with full featured third party CAD software. The GUI is also used for mesh generation, setting up the problem parameters, boundary conditions and solver options, adjusting the material properties, monitoring the progress of the solution and post-processing the results. Quite natural. But OpenFOAM is not your ordinary CFD software. With OpenFOAM we mostly work inside a terminal window (command line) editing text files, which can be a bit challenging at first.



The parts that require most GUI support are drawing the problem geometry, generating the mesh and post-processing the results. Unless the problem geometry is too simple to be handled by the pre-processing utilities of OpenFOAM, you need to draw it using a third party CAD software. We have several alternatives here, some of them being free and open-source ones. OpenFOAM comes with mesh generation utilities, but they do not have a GUI. Instead they are used from the command line. It is also possible to generate the mesh using a third party software (again we have free and open-source alternatives such as
Gmsh or SALOME). OpenFOAM comes with necessary mesh conversion utilities. For setting problem parameters, material properties, boundary conditions, solver settings, etc., we need to use text files and it is actually not as difficult as it sounds. And we of course need a GUI for post-processing. Paraview is the standard tool for this, but there are again alternatives such as VisIt.

OpenFOAM’s lack of GUI is considered to be a show stopper by many people. Several CFD enthusiasts and companies tried to come up with a solution for this. The ones listed below are some of the free choices, but they are generally considered to be primitive and not used frequently There are also more mature, non-free alternatives such as the following ones. Some of these are web based services where the CFD is done inside a browser, either on your local computer or on the cloud.

1.6 And What About Using Linux?

Almost all of my undergraduate students use Windows operating system on their personal computers. Some use macOS, but almost none use Linux. Many students not even heard of the Linux operating system. But like almost all FOSS, developed by scientists or engineers to be used by the scientific and engineering communities, OpenFOAM is also being developed and used under the Linux operating system. Linux is its home. To use OpenFOAM, we need to be using the Linux operating system. Today, it is possible to create a Linux like environment inside Windows or macOS to use OpenFOAM, so those who do not want to switch their operating system to a new one just for OpenFOAM do not need to do that. But at the end, they should be learning how to do things up to a certain extent in a new environment. I believe that this enforcement is not a downside but instead an advantage of using OpenFOAM. It gives you a chance to taste Linux. We will talk about these details in the next lecture.

1.7 Are There Other Software Similar to OpenFOAM?

There are several free and open-source CFD software, but none of them is as popular or as full-featured as OpenFOAM. Most of these are developed in academia or in research institutions with specific research intentions, not as general purpose solvers. Don’t get this wrong, they do what they are intended to do nicely. They may solve certain problems faster and/or more accurate than OpenFOAM, or some of them may solve problems that OpenFOAM cannot. But they are just not in the same league as OpenFOAM. Some examples are alt text






< TOC    Next Lecture >