How To work with sedFoam container

How To use sedFoam docker to test and use sedFoam.

Here is a How To about using the sedFoam docker.

The prerequisites is to install Docker: https://docs.docker.com/engine/install/

This page is organised in two sections:

Configuration of the sedFoam docker

Operating System: Ubuntu focal

Openfoam version: 2406 (openfoam.com) with all tutorials and source files

sedFoam version: the latest of the develop branch

user: sudofoam (with sudo)

Installed packages: swak4foam, python3-numpy, python3-matplotlib, fluidfoam, vim...

Official link: https://hub.docker.com/r/cbonamy/sedfoam_2406_ubuntu

Dockerfile: https://github.com/SedFoam/sedfoam/blob/develop/docker/Dockerfile

Extended docker (supporting notebook): https://hub.docker.com/r/cbonamy/sedfoam_2406_notebook

Please note that Paraview is not included in the sedFoam docker. The users are encouraged to install and use Paraview on the host machine.

How to use/launch sedFoam docker ?

launch/initiate docker:

In jupyter notebook using your web browser (macOS, linux, windows):

On host:

The -v="/Users/toto":/home/sudofoam/workingDir option is not mmandatory. It is used to mmount a shared space between host and jupyter notebook. If you use this option, please adapt the directories to your configuration. In this example, "/Users/toto" will be mounted on the vm in /home/sudofoam/workingDir.

On macOS with GUI (graphical interface without paraview):

On host:

  • configure xquartz
    • install xquartz to allow network connection
    • in Xquartz: Go to Preferences > Security
    • and Check "allow connections from network clients"
    • in a terminal:

          IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
          xhost + $IP
      
  • initiate docker:

        docker run -it --net=host -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp/.X11-unix --name "sedfoam_2406" --workdir="/home/sudofoam" -v="/Users/toto":/home/sudofoam/workingDir "cbonamy/sedfoam_2406_ubuntu" /bin/bash
    

    Please adapt the directories to your configuration. In this example, "/Users/toto" will be mounted on the vm in /home/sudofoam/workingDir. If you change IP, for example when returning from work to home, change the Display variable (in the Docker) accordingly.

On Windows with GUI (graphical interface without paraview):

  • configure Docker Engine for windows (with all system requirements: WSL2, step 1-5 from https://docs.microsoft.com/en-us/windows/wsl/install-win10)
  • configure vcxsrv: https://sourceforge.net/projects/vcxsrv/ (disable access control in extra settings)
  • Get your IP and set DISPLAY variable:

        set-variable -name DISPLAY -value YOUR-IP:0.0
    
  • initiate docker:

        docker run -it --net=host --env DISPLAY=$DISPLAY --name "sedfoam_2406" --workdir="/home/sudofoam" -v="c:/mydataspace":/home/sudofoam/workingDir "cbonamy/sedfoam_2406_ubuntu" /bin/bash
    

    Please adapt the directories to your configuration. In this example, "c:/mydataspace" will be mounted on the vm in /home/sudofoam/workingDir. If you change IP, for example when returning from work to home, change the Display variable (in the Docker) accordingly.

On linux with GUI (graphical interface without paraview):

    docker run -it --net=host --env DISPLAY=$DISPLAY --volume $XAUTH:/root/.Xauthority --name "sedfoam_2406" --workdir="/home/sudofoam" -v="/home/users/toto":/home/sudofoam/workingDir "cbonamy/sedfoam_2406_ubuntu" /bin/bash

Please adapt the directories to your configuration. In this example, "/home/users/toto" will be mounted on the vm in /home/sudofoam/workingDir. If you change IP, for example when returning from work to home, change the Display variable (in the Docker) accordingly.

Start a container (if existing and not running):

    docker container start sedfoam_2406

Attach to a running container (if existing and running):

    docker container attach sedfoam_2406

Now hack and enjoy!\ The sedFoam files will be in /home/sudofoam and the solver is already compiled. Note that the bashrc file from openfoam is here: /openfoam/bash.rc and the python environment here: /home/sudofoam/pyenv\