Learn OpenFOAM®

Asking the question »How to learn OpenFOAM®« is a bad one

OpenFOAM® is not a game that one can learn quickly. It is neither a clicking software that allows one to create beautiful pictures. So the question, »How to learn OpenFOAM®«, is more fundamental than people think. Indeed, without knowing much about the topic of computational fluid dynamics, you can make some simulations. Still, without the ability to verify your results, you are not able to defend them against other experts. Learning OpenFOAM® is not an easy task as the learning curve is very steep at the beginning. Nevertheless, it does make much fun, which on the other hand, motivates people to go on. 


— What is OpenFOAM® really? —

OpenFOAM® is no more and no less than object-oriented c++ code and is fully written as »Open Field Operation And Manipulation«.  Generally spoken, the c++ code is split into different libraries that can be used to solve fluid flow problems using the finite volume approach. The libraries are used in applications that can be used to solve your numerical problem. Each executable program requires different input parameters from the user, which are read from regular text files (OpenFOAM® does not have a graphical user interface). Summing up, OpenFOAM® is a c++ code conglomeration that handles partial differential equation problems using the FVM. 


— What skills should I have to use OpenFOAM®? —

In principle, running simulations without any experience is possible. Tobias Holzmann ran his first simulations (almost the first year) without knowing a lot about CFD, numerics, discretization, turbulence modeling, and all the topics that should be understood in this regard. However, if your simulation crashes or the results are obviously wrong, you need a fundamental knowledge in the used mathematics (which equations are solved and how, are there simplifications, and much more), physics, numerics, modeling approaches, algorithms, and others. So there is a bunch of things that have to be taken into account while investigating these problems. 


— What is the outcome if I do not know the above mentioned topics? —

Tobias Holzmann used OpenFOAM® to investigate heat transfer problems during his Bachelor thesis. The results were »okay-level« and did match with semi-empirical data and also more or less with measurement data. Nevertheless, after ten years of more experience, his Bachelor thesis is an excellent example of not-knowing fundamental principles regarding numerical modeling. In short, it a lucky circumstance that the mistakes done by Tobias Holzmann repealed in most cases each other. However, some results are incorrect in his theses, such as mesh density, used models, wrong algorithms used, insufficient residual control, and much more. Thus, generally spoken, you can do investigate your topics using OpenFOAM®, but the outcome might be wrong totally or partially. However, the main problem while not knowing the fundamentals is the inability to interpret the results and draw the correct conclusions correctly. 


— You don't need programming skills in c++ but... —

if you have the ability to go through the source code of the libraries and applications (preferable using Doxygen), you can resolve your errors much faster. Furthermore, new developments and extensions are more quickly for you to implement and to argue against others (for example, that your implementation into the toolbox is correct). 

OpenFOAM® and its Distributions

OpenFOAM® has a more complex history compared to other software toolboxes. That is the reason why one can choose between three different versions. The versions are published by different companies or facilities such as »The OpenFOAM Foundation«, »The ESI Group« or from the »community driven« one (also named foam-extend). 


— The main differences of the distributions are —

The main difference of all distributions is that all three are going different (more or less) direction in terms of extensions, programming and code development, and topics. The Foundation version probably is the most conservative toolbox in terms of programming, syntax, and c++ coding style rules. Furthermore, the Foundation completely renews core-related code snippets, removes doubled programming functionalities, and changes the code probably the most to keep a high level of c++ code maintenance. However, for contributions, it might be the hardest one to get your code published into the source code. The Foundation also works intensively in the chemistry and process engineering sector. The ESI Group version merges most of the changes coming from the Foundation into their distribution while keeping a broader level of extensions, probably coming from the industry. Thus, e.g., the overset mesh capability is only available in that distribution. At this moment, the ESI Group also added the cfMesh'ing tool directly into the source code, which is a good alternative to the general automatic mesh generation tool coming with the source code of OpenFOAM®. The ESI Group further has a committee that hosts a Wikipedia for OpenFOAM® with excellent material for beginner and advanced users. Finally, the foam-extend version (also named the community-driven), is driven mainly by Prof. Dr. HrvojeJasak. The foam-extend project includes reliable solid mechanic solvers for elastic, thermo-elastic, and plastic deformations, including contact conditions and much more. Furthermore, the distribution line offers block-coupled solvers and extensions to the maritime sector. 


— Which OpenFOAM® distribution should I use? —

The used distribution is always a matter of one's needs. Depending on the problem you are investigating, you should decide which version you are installing or compiling. However, keep in mind that you can have multiple versions of different distributions installed or compiled on your local machine (or server). If one uses the Foundation version, the case probably is working in the ESI Group version too. The foam-extend project diverged in terms of c++ code, and therefore input files the most. Thus, foam-extend cases commonly do only run with foam-extend.

The OpenFOAM Foundation Version 

The ESI Group Version

The foam-extend Project

One word about the »community driven« statement that Tobias Holzmann made for the foam-extend project previously. Honestly spoken, most people Tobias knows are using the OpenFOAM Foundation version of OpenFOAM®. Secondly, the ESI Group version is used. People who deal with the foam-extend version probably work in topics related to solid-mechanics or want to use the features implemented in that version. The »community-driven« wording presumably comes from the fact that for the foam-extend project, we do not have a company or a facility behind it that counter-checks the code to fulfill the requirements of their coding guidelines or similar. Nevertheless, it is just the opinion of Tobias Holzmann as he never had too much contact with the people working with and for the foam-extend project nor the ESI Group version. Thank you for reading until here, did you know that Tobias likes to listen to the music of Hans Zimmer?

Installing versus Compiling

If the decision was taken to use OpenFOAM®, there are two options to start using the applications. Either install the toolbox or compile it yourself. Some differences should be known about one over the other. However, you can always go back and compile or install your code. It is just a matter of personal habit.


— Installing OpenFOAM® —

OpenFOAM® can easily be installed on Linux systems. Here, pre-compiled libraries and applications are put onto your computer, which can be executed directly. Installing is easy and does take only a few minutes. You can find well-described installation instructions on the OpenFOAM Foundation website or the ESI Group website. The foam-extend project does not have pre-compiled libraries and applications available as far as Tobias Holzmann knows. Thus, one needs to compile the c++ code manually.


— Compiling the c++ code of OpenFOAM® —

Compiling OpenFOAM® means that your computer does take the raw c++ code and translate it to machine code. Therefore, one can optimize the compiling steps using, e.g., additional compiler flags. This method allows one to optimize your machine code for your CPU (the c++ code, e.g.,  is executed faster). Furthermore, one can also set debug flags, which are very powerful if new libraries or applications are developed. Besides, working with the source code allows one to quickly go into the files, check how they work, modify them if necessary or find the part which crashes your simulation. However, compiling the c++ code yourself requires more skills about your operating system in use. Furthermore, building the c++ code does take a while (depending on your machine; from 20 minutes up to several hours). As before, the compiling instructions are available on the official websites.

How should I start?

Times change since Tobias started learning and using OpenFOAM® Nowadays, there are a lot of online material available for beginner and advanced OpenFOAM® user. We all should be thankful and give credit to the people who are encouraged and create such a high quality material for all people all over the world.


— Must known places —

There are a lot of pages one should be aware of if OpenFOAM® is used. Please feel free to write a message to »This email address is being protected from spambots. You need JavaScript enabled to view it.« if you think there is a link missing.

Thank you for reading. Did you know that Tobias was the first Master student of the Fachhochschule Augsburg, who successfully achieved the doctoral degree at a university?