Difference between revisions of "OpenFOAM installation instructions"
NikLebedenko (talk | contribs) m (→Install ParaView: clarified things) |
NikLebedenko (talk | contribs) m (→Install OpenFOAM on Ubuntu: clarified things) |
||
Line 31: | Line 31: | ||
</syntaxhighlight>You can now open files in ParaView from the command line with <code>paraview <file></code>, replacing <code><file></code> the file you wish to open. | </syntaxhighlight>You can now open files in ParaView from the command line with <code>paraview <file></code>, replacing <code><file></code> the file you wish to open. | ||
==Windows 10 and above: Install Ubuntu== | ==Windows 10 and above: Install WSL Ubuntu== | ||
I recommend installing [https://docs.microsoft.com/en-us/windows/wsl/install-manual Windows Subsystem for Linux] instead of setting up a dual-boot partition (use WSL1, discussion of WSL2 below). | I recommend installing [https://docs.microsoft.com/en-us/windows/wsl/install-manual Windows Subsystem for Linux] instead of setting up a dual-boot partition (use WSL1, discussion of WSL2 below). | ||
Line 40: | Line 40: | ||
**''If you want to use WSL2 anyway, I recommend you install ParaView on Ubuntu to avoid reading between file systems. You must also install XMing to view the GUI. See [https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2 this page] and [https://newbedev.com/how-to-set-up-working-x11-forwarding-on-wsl2 this page] for further information.'' | **''If you want to use WSL2 anyway, I recommend you install ParaView on Ubuntu to avoid reading between file systems. You must also install XMing to view the GUI. See [https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2 this page] and [https://newbedev.com/how-to-set-up-working-x11-forwarding-on-wsl2 this page] for further information.'' | ||
==Install OpenFOAM on Ubuntu== | ==Install OpenFOAM on Ubuntu or WSL Ubuntu== | ||
OpenFOAM is an open-source Computational Fluid Dynamics (CFD) package. We will use it to simulate the fluid (air) flow. | OpenFOAM is an open-source Computational Fluid Dynamics (CFD) package. We will use it to simulate the fluid (air) flow. | ||
Revision as of 12:17, 30 January 2022
This wiki page is also available in video format
Important: These instructions only work for Ubuntu or Windows 10 and above.
MacOS: Please see these instructions on using a Docker image to install OpenFOAM. An Ubuntu VM on Mac will not work with these instructions.
Install and Use ParaView
If you wish to view the results of the simulations, the best way to do this is with ParaView.
Windows 10 and above:
Simply download the executable for Windows 10 from this website.
The same website also hosts excellent tutorials and documentation PDFs - these should be your first resource when learning how to use ParaView.
In order to run ParaView from the command line, you must add paraview.exe
to Path:
- Find the folder containing your
paraview.exe
executable, and copy the folder's location (not the file's location) to your clipboard withCTRL+C
. - In the search bar, type "Edit the system environment variables" and click the first option.
- Click the box labelled "Environment Variables..." in the lower right corner.
- A dialogue box appears. In the lower half labelled "System Variables", scroll to the variable "Path"
- Double click on the "Path" variable.
- Click "New"
- Paste the folder path you copied earlier into the text box that is now selected.
- Click "OK" on all the dialogue boxes.
You can now open files in ParaView from the command line with paraview.exe <file>
, replacing <file>
the file you wish to open.
Ubuntu:
Simply run this command:
sudo apt-get install paraview
You can now open files in ParaView from the command line with paraview <file>
, replacing <file>
the file you wish to open.
Windows 10 and above: Install WSL Ubuntu
I recommend installing Windows Subsystem for Linux instead of setting up a dual-boot partition (use WSL1, discussion of WSL2 below).
WSL Version comparison (optional):
- WSL1 Pros: fairly fast read/write in both Ubuntu and Windows file systems. Cons: much slower at read/write in Ubuntu file system than WSL2.
- WSL2 Pros: lightning fast read/write in Ubuntu. Cons: very slow read/write when moving data between Ubuntu and Windows.
- Summary: Use WSL1 if you have a Windows-based ParaView or another app that will read lots of data between file systems.
Install OpenFOAM on Ubuntu or WSL Ubuntu
OpenFOAM is an open-source Computational Fluid Dynamics (CFD) package. We will use it to simulate the fluid (air) flow.
The Ubuntu installation instructions as of 31/12/2021 are summarised below (adapted from this website):
curl -s https://dl.openfoam.com/add-debian-repo.sh | sudo bash
sudo apt-get install openfoam2112-default
Append the following line to your ~/.bashrc
file, if not already present:
source /usr/lib/openfoam/openfoam2112/etc/bashrc
Restart Ubuntu. Now check the installation completed correctly by running a tutorial case:
cd ~
mkdir -p OpenFOAM-sims/tutorials
cp -r $FOAM_TUTORIALS/incompressible OpenFOAM-sims/tutorials
cd OpenFOAM-sims/tutorials/incompressible/icoFoam/cavity/cavity/
blockMesh > log.blockMesh
icoFoam > log.icoFoam