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."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,
- free as in "free food". You can download and install it on your computer freely, without paying any money.
- free as in "free speech". You are free to use it in various different ways, including
- the freedom to use it for any purpose,
- the freedom to change it to suit your needs,
- the freedom to share it with your friends and neighbors, and
- the freedom to share the changes you make.
People use OpenFOAM in mainly two different ways
- Some people use it as it is. It comes with more than 100 readily available solvers and many pre- and post-processing utilities. For example blockMesh,
and snappyHexMesh are two mesh generation tools that come with it. simpleFoam, sonicFoam or rhoReactingFoam are three of the mainly
available flow solvers.
Somebody developed all these different solvers for us. Each solver also gets supported by the available models, such as material models in the form of equation of states, viscous models for non-Newtonian fluids, turbulent models, phase change models, combustion models, etc. If these solvers and models fit to our needs, we can use them just as they are. We don’t need to know how to develop code in C++, the language used in OpenFOAM. We don't need to study any of the source files. Here, the freedom as in "free food" is an important motivation of using OpenFOAM. - Some people modify it. For them, the already available solvers and models, or some of their features are not enough. These users modify the existing source codes or write new ones and come up with new solvers or models. To do this, you need to have a solid understanding of the finite volume method, know how it is implemented in OpenFOAM and be comfortable in template-based C++ programming. This is usually done at universities or institutions for research purposes. Here, the freedom as in "free speech" is the main motivation of using OpenFOAM, the fact that the source code is accessible and you are allowed to change it.
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- Core code developers and distributor companies.
- Help forums and user generated documentation, mainly in the form of tutorials.
- Companies that offer training, engineering consulting, cloud computing, etc. services.
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.
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
- Version 21.06 (June 2021)
- Version 20.12 (December 2020)
- Version 20.06 (June 2019)
- Version 19.12 (December 2019)
- Version 19.06 (June 2019)
- Version 18.12 (December 2018)
- Version 18.06 (June 2018)
- . . .
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.
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
- Version 9 (July 2021)
- Version 8 (July 2020)
- Version 7 (July 2019)
- Version 6 (July 2018)
- Version 5 (July 2017)
- Version 4.1 (October 2016)
- Version 4.0 (June 2016)
- . . .
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.
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
- SimScale
- CFD Support
- ENGYS
- simFlow
- Silent Dynamics
- Rheologic
- DHCAE Tools
- TotalSim
- CFD+ Engineeering
- blueCAPE
- and more...
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)
- New heterogeneous cloud modeling
- Multiphase extensions from openfoam.org
- New overset-enabled buoyant solver
- New multiphase Conjugate Heat Transfer (CHT) solver
- New synthetic turbulence generation method for LES/DES
- etc...
- Heat transfer: consolidated solvers and improved convergence and robustness.
- Particle tracking: improved robustness and optimized computation.
- Multiphase: wave damping, configurable inlet phase properties, better settling numerics.
- Reacting multiphase models: heat transfer, population balance, breakup, coalescence, etc.
- Reactions/combustion: simplified case setup.
- Turbulence: improved consistency and stability of wall functions, added sources.
- etc...
- Updated viscoelastoplastic models
- New steady-state universal flow solver, handling incompressible and compressible flows within the same framework.
- Change of generic turbulence modeling interface
- Updated version of block-coupled turbulence models
- etc...
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.
- If you are a student or a practicing engineer trying to learn the general principles of how to do CFD with OpenFOAM, most probably you’ll be using it "as it is" to solve rather simple problems with not that complicated physics. And for that purpose, you’ll most probably be using the built-in standard solvers, which look to be pretty much the same in all branches. So it does not matter much which one you pick.
- If you are a graduate student or a researcher interested in a specific problem type, say multi-phase flows or turbomachinery, it is better to read the notes of recent releases of different branches and see if there are new advancements in your field of interest.
- If you are really serious about using OpenFOAM, really value it and maybe a bit concerned about its future, you may try to understand the business doing practices of different groups, how they value OpenFOAM, how they make money out of it, what their future plans about it are, etc., and consider all that information in making your choice. If you are new to the world of FOSS, at some point you will notice that software development is not only about computers or programming languages, but it is also about people and sociology.
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 followingAdvantages:
- No cost
- Open-source
- Insufficient documentation
- Limited technical support (there is no unique official developer to ask for)
- Absence of a graphical user interface (GUI) and the steep learning curve
"... 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,
- OpenFOAM being open-source is just nice. I feel good about it. I believe that, for the advancement of science and technology, source codes and information in general should be shared. I am not saying that the OpenFOAM community is doing it perfectly, but they are trying. Up to now I have used OpenFOAM mostly "as it is", but in the future I want to make code modifications, so having access to its source code will be more critical.
- OpenFOAM's steep learning curve is not much of an issue for me because I have time to experiment and learn. But this may reduce the productivity of my students, especially if I cannot guide them properly. Poor code documentation is an important barrier for code development, both for me and my students.
- I am also very much interested in the technical documentation (not the user’s guide, but the technical guide). I want to know the technical details of how the software works in the background. What techniques are used, what are their details, what are their scientific references, how do alternative methods for a specific task compare. I feel that OpenFOAM is weak in that respect.
- With the aim of being user friendly, CFD software are including more and more black box practices in their usage. For example, some of the new commercial CFD software releases are advertised to have single click, automated mesh generation. These are not necessarily useful practices for an inexperienced engineer trying to learn how to do CFD correctly. In OpenFOAM due to the lack of this user-friendliness, you are forced to dig deep a bit in every step of the solution and although this takes some time, it can also be a good learning experience. I see it as an advantage.
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
- HELYX-OS
- InsightCAE
- CfdOF
- etc...
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- SU2 (Very popular in aerodynamics)
- Nektar++ (Spectral element solver. Popular for turbulence research)
- NEK5000 (Another spectral element solver)
- COOLFluiD (It is also a framework to develop solvers, similar to OpenFOAM)
- Palabos (Uses the Lattice Boltzmann Method)
- FLUIDITY (Specializes in multiphase flows)
- Basilisk (Uses adaptive Carteisan meshes)
- FEniCS (Uses the Finite Element Method. Has a Python interface)
- etc...