Home ยป How to Run OpenFOAM on Your Machine in 5 minutes

How to Run OpenFOAM on Your Machine in 5 minutes

by thawtar
In this tutorial, we will show how to run OpenFOAM on your Windows machine in no time!

OpenFOAM is famous for being difficult and even difficult to install. Most of the time, you need a working Linux environment to install and use OpenFOAM.

If you are a typical Windows user (like me!) or a MacOS user, and interested in using OpenFOAM, using Docker containers is probably the easiest way to get started. In this article, we will explain how to run OpenFOAM using Docker. The total time excluding the download time is 5~10 minutes!

First, you need to download Docker Desktop for your OS (Windows, Mac or Linux itself). You can download Docker Desktop from their website. It is OK if you are a student or you want to use Docker as an individual. But if you want to use Docker on your company workstation, you need to check whether you need to buy the Pro version or not.

After downloading, you can open the installer and follow the instructions. For the details, you can check this video (Disclosure: this does not belong to CFD Monkey).

How to install Docker Desktop on Windows 11

Then you start the Docker Desktop application. When the Docker Desktop is running, you can now open your command line system (cmd or PowerShell if you are on Windows and terminal if on MacOS).

We can see that Docker Desktop is up and running through the message at the left botton corner

After that, you need to pull the OpenFOAM docker image for later use by the following command:

docker pull thawtar1990/of2012

When Docker is running, all we need to do is pull

It will download OpenFOAM-v2012 on Ubuntu 20.04 LTS. For more information, you can check on my Docker Hub repository

Docker will download the necessary files and this will take a couple of minutes to half an hour depending on your internet connection. 

Now we can use OpenFOAM! You need to run the Docker container using the following command:

docker run -v $Your_Target_Directory:/home/user/workDir -it thawtar1990/of2012 bash

You can replace $Your_Target_Directory with any folder name you want to store your OpenFOAM case files as the initial mounting point. For example, I used C:\ as below and now I am inside Ubuntu and I have access to my files in C: drive!

Now we can run our Ubuntu instance with OpenFOAM-v2012

Next step is to test the OpenFOAM inside the Docker image. So, we can test with blockMesh. As we can see, now we are up and running!

blockMesh shows the outputs, meaning OpenFOAM is running properly

May be it is too boring and tiresome to type the Docker run command everytime. May be it is better to create a shortcut for it. You can create your custom shortcut on Window 10 or 11 like this. First, right click on your Desktop and click New->Shortcut. Then inside the location of the item:

C:\Windows\System32\cmd.exe /c docker run -v $Your_Target_Location:/home/user/workDir -it thawtar1990/of2012 bash

You can set the location for your case files anywhere during shortcut creation

Then, you can name it as โ€œof2012โ€ and finish the creation. Now we don’t need to type the command again anymore! All we need to do is run the Docker Desktop and double click our shortcut.

Now we have shortcut to OpenFOAM-v2012

If you want to change your working directory, you can change inside the Properties dialog box by right-clicking the shortcut.

You can change your case files location anytime

That is! Installing and running OpenFOAM is easier than ever and can be done in 5 minutes!

If you want to try more OpenFOAM versions, you can check at my Docker Hub repository.

We have a bunch of custom OpenFOAM containers with special third party softwares like Dakota, OpenFAST and foamMooring already compiled so that you do not need to deal with the hurdles of having to deal with dependencies and having to compile these codes.

If you want to try more OpenFOAM versions and the compiled software packages, you can check at my Docker Hub repository.

๐ŸŒŸ Elevate Your Cloud Experience with CloudHPC ๐ŸŒŸ
CloudHPC

Related Posts

Leave a Comment

๐ŸŒŸ Elevate Your Cloud Experience with CloudHPC ๐ŸŒŸ

Step into a world of limitless possibilities with CloudHPC. Our state-of-the-art cloud computing platform offers unparalleled performance and scalability for your projects.

๐Ÿš€ Supercharge Your Workflows: Harness the power of high-performance computing to accelerate your simulations, modeling, and data analysis tasks. ๐Ÿ’ก Seamless Integration: Integrate seamlessly with popular tools and frameworks, ensuring a smooth transition for your projects.

๐Ÿ”’ Robust Security: Rest easy knowing your data is protected by industry-leading security measures, keeping your work safe and secure.

Explore the future of computing with CloudHPC. Sign up today and elevate your cloud experience to new heights!