Currently, the latest version of OpenFOAM+ is supported.
The repository can be cloned by
git clone https://github.com/olegrog/my_openfoam.git
To build an augmented Docker image, run
cd openfoam
docker build -f Dockerfile.ubuntu -t my_openfoam-plus .
The new image can be used within an intermediate container as
docker run -it --rm -u="$(id -u):$(id -g)" -v="$(pwd):/home/openfoam" my_openfoam-plus
By default, MacOS uses case-insensitive file system, which can cause name conflicts in OpenFOAM. To create a case-sensitive volume, run
sudo curl -o /usr/local/bin/openfoam-macos-file-system http://dl.openfoam.org/docker/openfoam-macos-file-system
sudo chmod 755 /usr/local/bin/openfoam-macos-file-system
sudo openfoam-macos-file-system -v my_openfoam create
mkdir my_openfoam
sudo openfoam-macos-file-system -v my_openfoam mount
ParaView can be installed by brew install paraview
or manually from the official site.
In the latter case, it is worth to add these lines to .bash_profile
:
paraview_path=$(find /Applications -name 'ParaView-*' -maxdepth 1 | sort -V | tail -1)
[ -x "$paraview_path/Contents/MacOS/paraview" ] || echo "ParaView is not found."
export PATH="$PATH:$paraview_path/Contents/MacOS:$paraview_path/Contents/bin"
It is convenient to add some functions to .bash_profile
to run the Docker container (ofp
) and open ParaView (pf
):
ofp() {
local dir="my_openfoam"
local image_name="my_openfoam-plus"
local user="openfoam"
[ -d "$HOME/$dir/run" ] || sudo openfoam-macos-file-system -v $dir mount
docker run -it --rm \
--user="$(id -u):$(id -g)" \
--volume="$HOME/$dir:/home/$user" \
--volume="/etc/localtime:/etc/localtime:ro" \
$image_name
}
pf() {
local file="system/controlDict" dir
[ -f "$file" ] || { echo "There is no $file"; return 1; }
dir=$(find . -maxdepth 1 -name "*.foam")
[[ $dir ]] || { dir="$(pwd | xargs basename).foam"; touch "$dir"; }
paraview "$dir" > /dev/null 2>&1 &
}