Learn OpenFOAM®
Asking the question »How to learn OpenFOAM®« is a not the best one as it is highly complex
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
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
- The OpenFOAM® User-Guide
- The OpenFOAM® Programmers-Guide
- The Wikipedia site (from the community)
- The Wikipedia site (from the ESI Group)
- YouTube Channel of József Nagy
- YouTube Channel of Tobias Holzmann
- OpenFOAM® Courses from the Chalmers University
- Tomers Blog
- CFD Forum (cfd-online.com)
- A comprehensive tour through snappyHexMesh
- The OpenFOAM section of WolfDynamics
- swak4Foam by Bernhard Gscheider
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 an university?