1. Install openFoam

%%bash
sh -c "wget -O - http://dl.openfoam.org/gpg.key | apt-key add -"
add-apt-repository http://dl.openfoam.org/ubuntu
apt-get update
apt-get -y install openfoam6
OK
Hit:1 http://dl.openfoam.org/ubuntu bionic InRelease
Hit:2 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://ppa.launchpad.net/cran/libgit2/ubuntu bionic InRelease
Hit:6 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ InRelease
Hit:7 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:8 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease
Hit:9 http://security.ubuntu.com/ubuntu bionic-security InRelease
Ign:10 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  InRelease
Ign:11 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  InRelease
Hit:12 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Release
Hit:13 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  Release
Reading package lists...
Hit:1 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://dl.openfoam.org/ubuntu bionic InRelease
Hit:4 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ InRelease
Hit:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:6 http://ppa.launchpad.net/cran/libgit2/ubuntu bionic InRelease
Hit:7 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:8 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease
Hit:9 http://security.ubuntu.com/ubuntu bionic-security InRelease
Ign:10 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  InRelease
Ign:11 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  InRelease
Hit:12 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Release
Hit:13 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  Release
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
openfoam6 is already the newest version (20190620).
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
--2021-02-09 11:36:09--  http://dl.openfoam.org/gpg.key
Resolving dl.openfoam.org (dl.openfoam.org)... 35.179.33.128
Connecting to dl.openfoam.org (dl.openfoam.org)|35.179.33.128|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1710 (1.7K) [application/pgp-keys]
Saving to: ‘STDOUT’

     0K .                                                     100%  465M=0s

2021-02-09 11:36:09 (465 MB/s) - written to stdout [1710/1710]

Warning: apt-key output should not be parsed (stdout is not a terminal)

2. Copy the cavitation tutorial to the current directory

%%bash
. /opt/openfoam6/etc/bashrc
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity ./

3. Calculation execution

%%bash
. /opt/openfoam6/etc/bashrc
cd ./cavity
blockMesh >log.blockMesh 2>&1
icoFoam >log.icoFoam 2>&1 
ls
0
0.1
0.2
0.3
0.4
0.5
constant
log.blockMesh
log.icoFoam
system

4. Zip and download calculation.

%%bash
zip -r cavity.zip ./cavity
  adding: cavity/ (stored 0%)
  adding: cavity/0.1/ (stored 0%)
  adding: cavity/0.1/p (deflated 57%)
  adding: cavity/0.1/phi (deflated 63%)
  adding: cavity/0.1/U (deflated 63%)
  adding: cavity/0.1/uniform/ (stored 0%)
  adding: cavity/0.1/uniform/time (deflated 63%)
  adding: cavity/0.3/ (stored 0%)
  adding: cavity/0.3/p (deflated 56%)
  adding: cavity/0.3/phi (deflated 63%)
  adding: cavity/0.3/U (deflated 63%)
  adding: cavity/0.3/uniform/ (stored 0%)
  adding: cavity/0.3/uniform/time (deflated 63%)
  adding: cavity/0.5/ (stored 0%)
  adding: cavity/0.5/p (deflated 57%)
  adding: cavity/0.5/phi (deflated 63%)
  adding: cavity/0.5/U (deflated 63%)
  adding: cavity/0.5/uniform/ (stored 0%)
  adding: cavity/0.5/uniform/time (deflated 63%)
  adding: cavity/log.blockMesh (deflated 57%)
  adding: cavity/0.4/ (stored 0%)
  adding: cavity/0.4/p (deflated 57%)
  adding: cavity/0.4/phi (deflated 63%)
  adding: cavity/0.4/U (deflated 63%)
  adding: cavity/0.4/uniform/ (stored 0%)
  adding: cavity/0.4/uniform/time (deflated 63%)
  adding: cavity/system/ (stored 0%)
  adding: cavity/system/controlDict (deflated 61%)
  adding: cavity/system/blockMeshDict (deflated 64%)
  adding: cavity/system/fvSolution (deflated 64%)
  adding: cavity/system/fvSchemes (deflated 66%)
  adding: cavity/0.2/ (stored 0%)
  adding: cavity/0.2/p (deflated 57%)
  adding: cavity/0.2/phi (deflated 63%)
  adding: cavity/0.2/U (deflated 63%)
  adding: cavity/0.2/uniform/ (stored 0%)
  adding: cavity/0.2/uniform/time (deflated 63%)
  adding: cavity/log.icoFoam (deflated 87%)
  adding: cavity/constant/ (stored 0%)
  adding: cavity/constant/transportProperties (deflated 61%)
  adding: cavity/constant/polyMesh/ (stored 0%)
  adding: cavity/constant/polyMesh/boundary (deflated 67%)
  adding: cavity/constant/polyMesh/points (deflated 87%)
  adding: cavity/constant/polyMesh/faces (deflated 64%)
  adding: cavity/constant/polyMesh/neighbour (deflated 59%)
  adding: cavity/constant/polyMesh/owner (deflated 76%)
  adding: cavity/0/ (stored 0%)
  adding: cavity/0/p (deflated 63%)
  adding: cavity/0/U (deflated 63%)
from google.colab import files
files.download('cavity.zip')