## Thursday, December 29, 2011

### OpenFOAM and installation of ver. 2.1.0 in Ubuntu 11.10

I've been wanting to install and try this software for awhile now.  It is called OpenFOAM and is a free and open source CFD and numerical software.  While ANSYS Fluent and others are great and heavily developed, they are quite expensive and un-readily available to many users.  I've done some research and OpenFOAM seems to be the leader of the free world.  They seem to be very open and constantly updated and developed.

The OpenFOAM® Foundation is a non-stock corporation, incorporated on 5th August 2011 in Delaware, USA. It is a nonprofit organization whose “specific objectives and purposes... shall be to promote and manage the free open source distribution of the OpenFOAM software” (Bylaws, Article II). The Foundation has taken on the guardianship of the OpenFOAM software, previously undertaken by OpenCFD Ltd. Through its bylaws, it formalises the commitment, begun by OpenCFD in 2004, to ensure OpenFOAM is free and open source only. It is supported by SGI and lists Mark Barrenechea (CEO, SGI) and Henry Weller (creator of OpenFOAM) amongst its Board of Directors.
The Foundation distributes the current repository version of OpenFOAM (and will distribute future ‘version’ releases of OpenFOAM) under the GNU general public licence (GPL). The GPL gives users the freedom to modify and redistribute the software and a guarantee of continued free use — as long as the terms of the GPL are adhered to. There are two elements to the GPL that provide protection against exploitation by companies including OpenFOAM within non-free and/or closed source software products. First, when any modified version of the software is redistributed, the source code must also be made available by the distributor. Secondly, any modified version can only legally be distributed open source under the GPL and software that links intimately enough to OpenFOAM has to be distributed under the GPL as well.
People and organisations contribute to OpenFOAM on the understanding that their contributions become part of the public commons of free software and are not exploited by producers of non-free software. The Foundation exists to ensure this, adopting a suitably strong, open source license, i.e. the GPL. It will manage the software code base and promote the software, e.g. through its website www.openfoam.org, whose content will grow over time. OpenFOAM Foundation 15th August 2011

The OpenFOAM® (Open Field Operation and Manipulation) CFD Toolbox is a free, open source CFD software package produced by OpenCFD Ltd. It has a large user base across most areas of engineering and science, from both commercial and academic organisations. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics and electromagnetics. It includes tools for meshing, notably snappyHexMesh, a parallelised mesher for complex CAD geometries, and for pre- and post-processing. Almost everything (including meshing, and pre- and post-processing) runs in parallel as standard, enabling users to take full advantage of computer hardware at their disposal.
By being open, OpenFOAM offers users complete freedom to customise and extend its existing functionality, either by themselves or through support from OpenCFD. It follows a highly modular code design in which collections of functionality (e.g. numerical methods, meshing, physical models, …) are each compiled into their own shared library. Executable applications are then created that are simply linked to the library functionality. OpenFOAM includes over 80 solver applications that simulate specific problems in engineering mechanics and over 170 utility applications that perform pre- and post-processing tasks, e.g. meshing, data visualisation, etc.

The OpenFOAM Team produces the OpenFOAM® open source CFD toolbox and distributes it through the OpenFOAM Foundation. The OpenFOAM Team was formed at OpenCFD Ltd, a company established in 2004 to coincide with the release of its OpenFOAM software under general public licence. The company was founded by: Henry Weller, the creator of OpenFOAM and its chief developer from inception to the present day; Chris Greenshields; and, Mattijs Janssens. In 2011, the team moved to SGI Corp, following its acquisition of OpenCFD Ltd.

OpenFOAM Services:
The OpenFOAM Team has unrivalled experience with OpenFOAM. Over the past 7 years they have successfully provided services to numerous science/engineering companies, consultancies and universities. Developments: written over half a million of lines of code. Support: delivered over 10,000 hours of support. Training: delivered over 100 training courses to over 1000 OpenFOAM users. The OpenFOAM Team is Henry Weller, Chris Greenshields, Mattijs Janssens, Andy Heather, Sergio Ferraris, Jenya Collings, Gijs Wierink and Laurence McGlashan.

I recommend you check this out if you are interested in a free CFD simulator.  While it may not have all the bells and whistles of Fluent or other similar software, but I bet you can get just as much done and in the process understand what you are doing much better as it can be the tendency to treat more fancy software as a black box.  OpenFOAM has meshing and post processing capabilities (ParaView), supports many imports of meshes from other software, has many solvers, many models, and many libraries, it also has great documentation, tutorials, and community support.  Training and customer support is also offered.

To install OpenFOAM simply go to http://www.openfoam.org/download/ where they have choices of the Ubuntu Deb Pack, SuSE RPM Pack, the Source Pack, and the Git Repository.  Luckily for us, I am using Ubuntu 11.10 so I simply went to their page for that installation here: http://www.openfoam.org/download/ubuntu.php

I followed the instructions and had no problems until I got to the end where it says Getting Started.  It seems to assume that a directory exist in your home directory called OpenFOAM.  However, this is not where OpenFOAM was installed as you can see it is installed in /opt/openfoam210 instead.  So you need to first create the directory OpenFOAM in your home folder then everything else should be fine in the directions.

This is the link for the documentation (tutorials and more): http://www.openfoam.org/docs/user/

One downside to OpenFOAM is that it is not cross platform.  It only works on Linux such as Ubuntu, Fedora, SuSE, etc.

Here is a screen shot showing that OpenFOAM installed into the opt directory.

Here is a screen shot showing the /home/timbarber/OpenFoam/timbarber-2.1.0/run/tutorial tree.  This is the step where the tutorial material is copied from the /opt/openfoam210 directory.

Here is the message I get after editing the .bashrc file then either typing source $HOME/.bashrc and then typing icoFoam -help or opening a new terminal window then typing icoFoam -help Screen shot after running blockMesh in the cavity directory. Viewing the mesh in ParaView by typing paraFoam in the terminal. After following the instructions on OpenFOAM's user document web page, this is a view of the mesh. #### 15 comments: 1. I am having trouble getting OpenFoam 2.1.0 to run in Ubuntu 11.10. I installed it using sudo apt-get install after updating the .source appropriately. openfoam210 installed to /opt . Do I leave the openfoam210 directory there or do I move it to my home directory. My computer has multiple users on it and I do not want to install it into each user's home directory. I could not find a simple answer to my problem. You make it seem that you had very little trouble getting it to work on Ubuntu 11.10 and I am having a lot of trouble. Did you follow the Ubuntu .deb instructions exactly? 2. Hello. Yes, I left everything in the /opt directory, and I followed the instructions on the OpenFOAM website. The only thing I added to OpenFOAM's instructions was at the step "Getting Started." There was no OpenFOAM directory within my HOME folder so I just had to create it, my HOME directory is home/timbarber. The next step then tells you to create a user directory within the home/timbarber/OpenFOAM directory just created. So mine without the last period is home/timbarber/OpenFOAM/timbarber-2.1.0. I then followed the directions which: 1. creates a directory within home/timbarber/OpenFOAM/timbarber-2.1.0 called run mkdir -p$FOAM_RUN

2. copies the tutorial examples to the newly made run directory in a directory itself called tutorials, home/timbarber/OpenFOAM/timbarber-2.1.0/run/tutorials

cp -r $FOAM_TUTORIALS$FOAM_RUN

3. runs the first tutorial over the lid driven cavity

cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity blockMesh icoFoam paraFoam So the last step just creates a directory in your home folder to store personal stuff like run files, cases, etc. The OpenFOAM software should be available to all users regardless. Were you able to successfully complete the "User Configuration" from the steps? Did you see a screen which indicated it installed correctly ("Usage: icoFoam...) after typing "icoFoam -help"? Don't forget after editing the .bashrc file to either run "icoFoam -help" in a new terminal window or if you don't want to open another terminal window then run the command "source$HOME/.bashrc" before you run "icoFoam -help"

I'll post some screen shots.

1. Thank you so much for responding quickly! I have been determined to get OpenFOAM to work before I go to bed tonight!

I was able to get "icoFoam -help" to return a list of a bunch of options and at the bottom it says " Using: OpenFOAM-2.1.0 (see OpenFOAM.org)
Build: 2.1.0-0bc225064152

I was also able to create the properly named OpenFOAM/kxk203-2.1.0/run/tutorials directory.

When I navigate to OpenFOAM/kxk203-2.1.0/run/tutorials/incompressible/icoFoam/cavity I cannot get blockmesh to work. The terminal returns "command not found"

I also installed the paraviewopenfoam3120 in /opt . So ls in /opt reveals:
"openfoam210 paraviewopenfoam3120"
I am using a bash shell and included . /opt/openfoam210/bashrc in the .bashrc in /users/kxk203/ .

2. I looked at the screen shots and have the same organization and obtain the same output from "icoFoam -help" .

3. Sorry, I fell asleep, but hopefully this will help when you try it again!

Alright, I think I understand where the problem/confusion is. Don't worry, I think I did the same when trying to figure out what you were having trouble with. So the last step on the installation it gives you the commands to run the first tutorial, the lid driven cavity. The command is:

cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity to get you to the working directory of the cavity tutorial we want to run. At first, I thought maybe the$FOAM_RUN was somehow routing back to the /opt directory which it is but not in the way I thought it was. This is the point where the bash file edit allows you to run OpenFOAM from your user directory. Instead the $FOAM_RUN is just putting you in your home/user directory instead of typing cd home/timbarber/OpenFOAM/timbarber-2.1.0/run/... etc. Anyways, I too typed "blockmesh" in the terminal and received the same error! I tried different folders and this is where I was thrown off thinking it was some rerouting issue. However, I think your mistake, like mine, is that the command is "blockMesh" and not "blockmesh"!! So try this again and see if this was the error. Just type "blockMesh" in the directory for your case: OpenFOAM/kxk203-2.1.0/run/tutorials/incompressible/icoFoam/cavity I put up some additional screen shots. 3. Thank you for your help. I was typing "blockmesh" instead of "blockMesh". I was able to successfully complete all the steps to paraFoam. Can you post some screen shots of the paraFoam step in the incompressible/icoFoam/cavity tutorial? One other question. Have you used openFoam much in your research? I am currently taking a CFD class and am looking to use openFoam in addition to Ansys Fluent. How do the two compare? 4. I will be following the user documents instructions to see if I can get the same output as you. I can't believe how much trouble I had with capitalization errors! 5. Awesome! Glad it worked! No worries, as you can see I easily made the same typo. I haven't used OpenFOAM except here. I only ran the cavity problem just to check that everything was working ok. I think as far as I got was to the pressure step and then ParaView froze. I plan on using both OpenFOAM and Fluent as well. I've used Fluent, mmm, I'd say moderately so far during my time as a grad student over the past 5 1/2 years. I will be using it more as I am working on a project which uses Fluent, and I plan on using it for another project to support my PhD work. I would use OpenFOAM for the latter, but I am not sure I have the extra time to fully figure out OpenFOAM, especially since I am already familiar with Fluent. I may get around to OpenFOAM. I'll just have to wait and see. However, from the brief exposure to OpenFOAM, I'd say it is probably just as good as Fluent. Now the definition of "good" depends upon one's personal preferences and what one is looking for in a CFD software. Fluent has a nice GUI interface, and many people use it. Some people may be turned off by OpenFOAM's lack of a processing/pre-processing interface, but I think it has it's advantages. The biggest advantage is that it requires the user to get more "involved" with the process because you have to setup your mesh and case files in a simple text editor. I feel this is better because many times it feels like CFD software is used as a black box. That is you put information in and get information out, but the user more than likely does know or understand what is going under the hood so to speak. This can be quite dangerous because while you results look "pretty," they may not be correct. Now of course CFD uses numerical methods to obtain solutions which always have some error to them, but I feel as a researcher and scientist one ought to understand some degree in order or not to recognize whether the data is way off or even slightly off. One's knowledge of the physics and models/methods being utilized in the CFD code will help you determine these things. Of course much understanding also comes with experience, but I feel that using the text files in OpenFOAM expose the user to more things. As far as I can tell OpenFOAM has many of the same capabilities as Fluent. OpenFOAM seems to have a plethora of models for a range of physical problems. Now I cannot fully account to this as I have not fully explored either Fluent or OpenFOAM. Both also seem to have good support as well. Of course when you have a license with Fluent you (usually) get tech support which is directly from the engineers/researchers/designs at Fluent. However, you are paying out the wazoo which can be undesirable or even impossible some people. Thus, OpenFOAM seems like a great alternative. You probably can get a pretty high level of support as well from either OpenFOAM's user forums or the CFD Online community and forums. Ok, nm on the OpenFOAM user forum. I thought they have one, but they don't. They do, however, offer customer support which I am sure is much cheaper than a Fluent license and support. Here is a link to the CFD Online OpenFOAM forum which may be of some help: http://www.cfd-online.com/Forums/openfoam/ Finally, one potential drawback of OpenFOAM is it's non-cross platform. That is, it only works on Linux (so far) while Fluent has the option when buying your license for either Windows or Linux but not both (you would have to buy two separate licenses, one for Windows and the other for Linux, unless they have a special pricing bundle or something). I am not sure about Mac. Just checked, Fluent does not have Mac support. Anyways, good luck! 6. I agree completely with the "black-box" analogy. I like the fact that OpenFOAM forces the user to become involved in the development of boundary conditions, model output, etc. I have not yet worked with Fluent but I have heard people calling it "Colorful Fluid Dynamics" because they probably don't understand how the models are being developed. The presence of a pretty GUI removes the responsibility of the user to understand the nitty-grtty of the computations. So far, I have really enjoyed my experience with OpenFOAM. The community surrounding the product has been enjoyable to work with. I found the CFD forum you posted while I was trying to solve my "capitalization" problem and they were very helpful. They even went so far as to begin instructing me on simple bash commands. I am particularly interested in a comparison between Fluent output, OpenFOAM output, and experimental data. If you end up finding such a comparison, I would like to see it posted! The learning curve or lack of GUI does not intimidate me (I may actually prefer it for reasons stated above) and would like to make OpenFOAM my primary CFD tool. You brought up the point of OpenFOAM only being available on Linux systems. I view this as a huge advantage over multi-platform codes. Linux (Ubuntu) is free and, in my opinion, very easy to use. OpenFOAM and Linux are a perfect marriage of open source software! Ubuntu + OpenFOAM + Vim is a nice little engineering bundle of happiness that happens to be free. In recent years I have become a proponent of open source software because I believe in the values of the people who create it. I was able to plot stream lines for the Lid-Driven Cavity flow tutorial. I am running OpenFOAM on my eeepc 1018-P with Ubuntu 11.10 and it has so far performed flawlessly. Paraview has not yet given me any problems either. I haven't attempted large mesh/domain computations yet...that would probably cause my computer to "crap-out". Anyways, thanks for all your help. 7. Awesome!! Excellent!! Sounds like you have a great philosophy going into this research which will take you far. IMO, sometimes realizing the whole picture like this is better and quite helpful. Of course, details are important too. Sounds like we have the same feeling for these things too. I agree with many things you've said. I feel open source is definitely the way to go too. Unfortunately, many people don't know about it so it forces us not being able to completely abandon software such as Microsoft/Windows, MATLAB, Mathematica, Origin Plot, etc. However, I have found very viable alternatives for all of these software. Anyways, I did find a paper a few days ago which does compare a Fluent simulation to one (the same) in OpenFOAM. 2009-Muntean et al-CP-3D numerical analysis of the unsteady turbulent swirling flow in a conical diffuser using Fluent and OpenFOAM I can send it to in PDF you if you like. If my email isn't displayed on my profile it is: timothy.andrew.barber@gmail.com so you can just email me and I'll email you back with the paper. I haven't really looked closely at it so I can't tell you much about it. 8. How I will add transport equation in the cavity tutorials? 9. I go this error ....... does anyone knows how to fix this one =============================================================$ paraFoam

FATAL ERROR: ParaView reader module libraries do not exist