Skip to content

Instantly share code, notes, and snippets.

@BinWang0213
Last active November 12, 2020 17:01
Show Gist options
  • Save BinWang0213/2227c3dd938b1461c9d86ec3da988c7a to your computer and use it in GitHub Desktop.
Save BinWang0213/2227c3dd938b1461c9d86ec3da988c7a to your computer and use it in GitHub Desktop.
Docker OpenFOAM 7 usage

Install OpenFOAM7 in Docker

Install Openfoam and setup linux environment

#Download openfoam7
docker run --shm-size=1g -ti --name of7 -v F:/hybridPorousFoam/:/home/openfoam openfoam/openfoam7-paraview56

#Re-login as root user
exit
docker exec -u 0 -it of7  bash

#Install basic packages
apt-get update && apt-get -y install sudo
sudo apt-get install git

#Restart openfoam
docker start of7
docker exec -u 0 -it of7  bash

Compile and install hybridPorousInterFoam

git clone https://github.com/Franjcf/hybridPorousInterFoam.git
cd /home/openfoam/hybridPorousInterFoam/OpenFoamV7
./Allwmake

Setup WSL core and meomory usage if WSL2 backend is used for docker

# turn off all wsl instances such as docker-desktop
net stop LxssManager
notepad "$env:USERPROFILE/.wslconfig"

#Copy following keywords into file
[wsl2]
memory=64GB   # Limits VM memory in WSL 2 up to 3GB
processors=10 # Makes the WSL 2 VM use two virtual processors

#Bring wsl back
net start LxssManager

Usage

#start openfoam
docker start of7
docker exec -u 0 -it of7 bash

#Open a project
cd /home/openfoam/hybridPorousInterFoam/OpenFoamV7
./run

#Run case in parallel

#Generate mesh
blockMesh

#Edit decomposeParDict
decomposePar

#Run in parallel
mpirun -np 8 hybridPorousInterFoam -parallel

#Recombine results from decomposition
reconstructPar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment