Install OpenFOAM on Ubuntu 14.04

  • Tutorial

OpenFOAM is a freely distributed toolkit of computational fluid dynamics for operations with fields (scalar, vector and tensor). Today it is one of the “complete” and well-known applications intended for FVM calculations. In particular, the package allows solving the hydrodynamic problems of Newtonian and non-Newtonian viscous fluids in both the incompressible and compressible approximations taking into account convective heat transfer and the action of gravitational forces. To simulate turbulent flows, it is possible to use RANS models, LES and DNS methods. It is possible to solve subsonic, transonic and supersonic problems.

Currently installation packages are available for the next OS versions.
  • 12.04 LTS codename precise
  • 12.10 codename quantal
  • 13.04 codename raring
  • 13.10 codename saucy

However, the installation package for Ubuntu 14.04 is missing. Therefore, for version 14.04, it is necessary to assemble OpenFOAM 2.3 on your own. This is not an easy task for beginners who recently use this operating system.
This is what the article is about.


Attention assembly process can take up to 6 hours.

We will work in a guest operating system running a system based on the Hyper-V hypervisor. If this is your first time using Hyper-V with Ubuntu, then the resolution when connecting to the virtual machine may be different from the resolution of your screen. This can be fixed as follows. Call up the command line, enter the following command.
sudo nano  /etc/default/grub

Find the line with GRUB_CMDLINE_LINUX_DEFAULT and add it to "video = hyperv_fb: 1600x900". Where instead of 1600x900 substitute the resolution of your monitor. In my case, she looked like this.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1600x900"

Next, update the settings with the command
sudo update-grub

Changes will come after rebooting the virtual machine.

To build, we need to install the necessary packages.

  1. Switch to root mode.
    sudo -s
    

  2. Install the packages.
    apt-get install build-essential git-core cmake flex bison zlib1g-dev qt4-dev-tools\
     libqt4-dev gnuplot libreadline-dev \
    libncurses-dev libxt-dev libopenmpi-dev openmpi-bin\
    libboost-system-dev libboost-thread-dev libgmp-dev libmpfr-dev
    
  3. Exit root mode.
    exit


Create a folder in for OpenFOAM and go to it.
mkdir $HOME/OpenFOAM
cd $HOME/OpenFOAM

The following commands will download the source code.
git clone git://github.com/OpenFOAM/OpenFOAM-2.3.x.git
wget http://downloads.sourceforge.net/project/foam/foam/2.3.0/ThirdParty-2.3.0.tgz

Also, the sources are available here.

Unzip ThirdParty-2.3.0.tgz using the tar utility with the keys x unzip the z type of the archive .gz f write the archive to a file (the next parameter indicates the file name). Next we delete the archive that we no longer need.
tar xzf ThirdParty-2.3.0.tgz
rm ThirdParty-2.3.0.tgz

Let's go back to the home directory and set the environment variables.
cd
gedit .bashrc

In the text editor that opens, add the following line to the end of the file.
source $HOME/OpenFOAM/OpenFOAM-2.3.0/etc/bashrc

Let's make these environment variables available and test one of them.
. .bashrc
echo $FOAM_INST_DIR

Using the environment variable, go to the desired directory and compile.
cd $WM_THIRD_PARTY_DIR
./Allwmake 

Compile ParaView - a post-processor for viewing results and geometries.
./makeParaView4

The final step is to compile OpenFOAM ( Warning, this operation is the longest )
cd $WM_PROJECT_DIR
./Allwmake

It remains to copy the training tasks and check the compilation result.
cd
mkdir -p $FOAM_RUN
cp -r $FOAM_TUTORIALS $FOAM_RUN
foamInstallationTest > log.foamInstallationTest
cat log.foamInstallationTest

If all is well, you will have the following on the screen.
image

Perform a parallel calculation of the motorcycle.
сd $FOAM_RUN
cd tutorial/incompressible/simpleFoam/motorBike/
./Allrun

After the calculation, it remains to see what we get.
paraFoam

image
We only show the motorcycle that interests us. The remaining checkmarks need to be removed and left as in the picture.
image
Click Apply. It will be green.

Display the pressure distribution. Having set the parameters in a red square, you should get the following picture.
image

I hope this instruction helps beginners to OpenFOAM users.

PS> If you find a mistake or flaw write to me.

Also popular now: