Docker#
Note
You will need to install Docker and have 5 GB of free disk space.
No Compilation Required: Using the Provided Lethe Docker Image#
If you don’t want to build Lethe and its dependencies, you can use the provided Docker image.
For example, to launch the 2D Lid-Driven Cavity Flow simulation, run the following lines inside the root Lethe folder:
In general, to run a lethe simulation you will just need to run the following command:
Using a deal.II Docker Container#
The deal.II library is a mature project containing O(1,000,000) lines of C++ code, itself depending on other similar libraries (e.g. Trilinos). Compiling deal.II with its exact dependencies can be a daunting task even for moderate C++ programmers - one with many knobs and dials, normally taking 4-6 hours.
Thankfully, the deal.II dev heroes also maintain some Docker Hub images containing pre-built deal.II libraries in a Ubuntu environment. For those unfamiliar with Docker, it allows the creation of completely isolated environments, most often pre-configured for specific apps; it is almost like a virtual machine, but running natively on your current OS (the technical term is OS-level virtualization, rather than hardware-level) - so scientific programs shouldn’t have any degradation in performance.
Below are some instructions for getting pre-configured deal.II environments, reducing the time needed to install lethe’s dependencies from hours to minutes. There are 3 main parts in this tutorial:
If you have experience with Docker, the 0. TL;DR section should be enough.
The next two sections have a brief introduction to Docker with enough information to get you started with deal.II containers.
The final 3. Saving Docker Commands in a Bash Script section has a shell script you can run directly to start and manage deal.II containers.
Sometimes it’s easier to effectively set up a completely new OS than compile millions of lines of C++…
0. TL;DR#
In some directory run:
And do the final lethe compilation step.
This starts a new docker container with an interactive terminal (-it
) named lethe-container
, mounting the current directory on your machine to /home/docker-host
. Inside the container, run any simulations in the /home/docker-host
directory to save them locally too.
Exit the docker container with ctrl-d
; run docker ps -a
to see the current containers on your machine - you’ll see the lethe-container
. Restart your container and attach to its terminal with:
Have fun.
1. Get Docker#
First, install Docker; complete instructions for Windows, Mac or Linux can be found here; this should be a relatively quick step.
2. Launch a deal.II Container#
Some Docker basics:
A Docker image is a “frozen”, shareable environment - e.g. a Ubuntu terminal with pre-installed deal.II and its dependencies.
You can launch a container running that specific image, in which you can e.g. compile lethe and run simulations. Indeed, you can run multiple separate containers of the same image.
In your terminal, you can then run:
This starts a new container with an interactive terminal (-it
) running the dealii/dealii:master-focal
image (see here for all the deal.II images) named lethe-container
. Press ctrl-d
to exit the container.
To see your current docker containers, run:
This container saved your changes. You can restart and attach to the container’s terminal by running:
If you want to, you can remove the container with docker rm lethe-container
; you’ll start a new fresh container by running the docker run...
command above.
However, any files saved in the container are only accessible inside it, and are lost when removing the container. For simulations on the other hand, we want their outputs to be saved and accessible on the local machine (e.g. to post-process them); for this, we will mount a directory from the local machine to the container with -v LOCAL_DIR:CONTAINER_DIR
. While in the container, anything you save to CONTAINER_DIR
will be accessible on your local machine in LOCAL_DIR
.
For example, on your local machine:
That’s all the Docker-specific tutorial! Launch your container running a deal.II image, go to /home/docker-host
to save your changes locally too, download lethe, compile it, and run your simulations there.
3. Saving Docker Commands in a Bash Script#
We can add all the commands above, plus some comments and helpful messages to a single shell script named docker_lethe.sh:
Then just execute the shell script:
Final Notes#
You can now download, run and manage Docker containers pre-configured with deal.II; it is a powerful tool that you can use for any other projects as well, without polluting your main programming environment or spending hours figuring out the specific libraries needed (dependency hell is real).
You can now clone lethe
, compile it, and run large-scale, efficient multi-physics simulations!