Prolog

This document served primarily as task sheets for FEniCS hands-on lectures held on Chemnitz University of Technology in September 2018. Nevertheless it is not excluded that these sheets could not be used separately or for any other occassion.

Target audience

This tutorial gives lectures on usage of FEniCS version 2017.2.0 through its Python 3 user interface. It is specifically intended for newcomers to FEniCS and as such does not assume any knowledge in Python programming. Rather than taking a Python tutorial first, the intent is to learn-by-doing. As a consequence first steps consist of modificating existing FEniCS demos while gradually taking bigger and bigger tasks in writing original code.

FEniCS installation

Obviously we will need a working installation of FEniCS. FEniCS can be installed in different ways which all of them have some pros and cons. On TU Chemnitz this taken care of by organizers of the hands-on and participants do not have to worry about this.

Nevertheless participants might want to install FEnicS to their laptops, workstation, home computers to practice or use FEniCS outside of the tutorial classes. The easiest option for new FEniCS users on Ubuntu is to install using APT from FEniCS PPA.

Note

This lecture material including the reference solutions is verified to be compatible with:

  • FEniCS 2017.2.0,
  • FEniCS 2018.1.0.

Ubuntu packages

Installing FEniCS (including mshr) from PPA:

sudo apt-get install --no-install-recommends software-properties-common
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install --no-install-recommends fenics

will install the following versions:

Ubuntu FEniCS
Xenial 16.04 2017.2.0
Bionic 18.04 2018.1.0

On the other hand FEniCS 2017.2.0 can be installed on Bionic by

# Remove PPA if previously added
sudo apt-get install --no-install-recommends software-properties-common
sudo add-apt-repository --remove ppa:fenics-packages/fenics

# Install DOLFIN from official Bionic package
sudo apt-get update
sudo apt-get install --no-install-recommends python3-dolfin

# Optionally install mshr from source
sudo apt-get install libgmp-dev libmpfr-dev
wget https://bitbucket.org/fenics-project/mshr/downloads/mshr-2017.2.0.tar.gz
tar -xzf mshr-2017.2.0.tar.gz
cd mshr-2017.2.0
mkdir build
cd build
cmake -DPYTHON_EXECUTABLE=/usr/bin/python3 ..
make
sudo make install
sudo ldconfig

Docker images

On the other hand FEniCS images for Docker provide the most portable solution, with arbitrary FEniCS version choice, for systems where Docker CE can be installed and run; see https://fenicsproject.org/download/.