TMA632 Project course PDE 05/06, 5 credits
For this course, we will use the FEniCS free software platform.
We will primarily use the FEniCS components FFC and DOLFIN. FIAT is used by FFC to evaluate basis functions for various finite elements, but you don't need to use it directly. PETSc is used by DOLFIN for linear algebra, but you don't need to use it directly either.
We will primarily use ParaView for visualization. Another alternative is Mayavi (can be used as a Python module).
FFC and FIAT are written in Python and can be used as Python modules (FFC is also an executable program, used as a compiler). DOLFIN and PETSc are written in C++. PyDOLFIN (included in DOLFIN) is a Python interface to DOLFIN and makes it possible to use DOLFIN as a Python module.
All of the software we will use in this course is free software. This means you can (and should) inspect the source code if you want to figure out how the software works. You can also modify the source code if you want to change how the software works, or if you want to extend it. You can also redistribute the software (including your modifications). The only restriction is that you have to include the source code if you redistribute the software (so that other people also can look at/change the source code).
I have installed PETSc, FIAT and FFC in a common location (on my course account), so you don't need to install these. I have also configured your accounts to specify the correct paths to be able to use these libraries (these paths are specified in the .bashrc file in your home directory).
The ppde accounts are running a shell (command line interpreter) called tcsh by default. I have tried to change this to bash, but it seems it failed. Run:
the first thing you do to make sure you run bash. Otherwise the paths won't be set correctly. I will try to fix this.
What you need to do is to build and install DOLFIN. When you develop your project (perhaps we can avoid this with PyDOLFIN) you will have to rebuild parts of DOLFIN (the module which represents your project), so this is important to be able to do.
To build and install DOLFIN, follow the short instructions which are included as README.PPDE0506 in the DOLFIN archive below.
These are some usage examples to test if the installation of the various software libraries is working correctly, and to help you learn how to use the software.
This is a simple example from the lecture notes. It's also a good introduction to using a Python module. Start Python by typing:
Copy the text after the prompt (>>>) and paste it into Python:
>>> from FIAT.Lagrange import *
>>> from FIAT.shapes import *
>>> element = Lagrange(TRIANGLE, 2)
>>> basis = element.function_space()
>>> v = basis
>>> v([-1.0, -1.0])
Try evaluating the basis functions at some other points. Also try the other basis functions of the element:
>>> v0 = basis
>>> v1 = basis
>>> v2 = basis
You can also try some other finite elements if you are interested (FIAT includes most of the common elements as well as some esoteric elements).
This is a simple example of how to use FFC to compile a form. You won't be able to see much of a result, but it will verify that FFC works, and you can use it to test the FFC form syntax and observe how FFC compiles a form.
Download the Poisson2D.form to a directory on your account. This form is from DOLFIN, dolfin/src/modules/poisson/dolfin/Poisson2D.form. Look at the form:
Now compile the form using FFC:
This should have produced a file Poisson2D.h (source code for evaluating the element matrix which DOLFIN can use).
You can also edit the form:
emacs -nw Poisson2D.form
Experiment with making some changes and try to compile the form again.
Here are some other forms which you can examine and try to compile (in order of readability):
The Convection Difussion and Navier-Stokes forms are a bit hard to read since the time stepping has been included explicitly in the form.
After you have installed DOLFIN (by the instructions above), the first test is to try to compile and run the Poisson example. The demo programs in DOLFIN exist independent from the main source tree, so if you can build and run a demo, then you have installed DOLFIN correctly.
Go to the poisson demo directory (from the DOLFIN directory):
Now build the demo:
This should have produced a program: dolfin-poisson . Run the program:
This should produce a file poisson000000.vtu which contains the solution to the problem. You can inspect this file manually:
A better alternative is to visualize the solution in ParaView.
You can also examine the Poisson demo program dolfin/src/demo/solvers/poisson/main.cpp and the Poisson solver module dolfin/src/modules/poisson/PoissonSolver.cpp. We will likely use PyDOLFIN however, and then you won't need to write such C++ code for your projects, you can do the equivalent in Python.
To continue testing DOLFIN, you can try the other demos: convdiff, stokes, navier-stokes etc.
PyDOLFIN makes DOLFIN available as a Python module. If you have performed the PyDOLFIN installation step in the DOLFIN installation instructions, you can simply import DOLFIN as a module in Python:
>>> from dolfin import *
Then you can use all the functions which are available in DOLFIN, creating a uniform mesh for example:
>>> mesh = UnitSquare(10, 10)
Here are two Python programs using PyDOLFIN: meshdemo.py (requires a mesh file and poissonsolver.py).
Run these programs by typing:
python -i meshdemo.py
python -i poissonsolver.py
The -i flag means that you will stay in the interactive Python environment.
PyDOLFIN is still missing an automatic step for transforming an FFC form file to a Python module usable by PyDOLFIN. I will look into this over the next few days, and then hopefully we can do all our work with PyDOLFIN.
Changing account password:
You can change your account password using the:
command. Or possibly:
which is the distributed version.
You can use your accounts on the computers (remotely accessible):
You can access them using SSH like this (from a Unix/Linux computer):
For Windows there exists a good and simple client called PuTTY. There is also an SCP client there for transfering files ("scp" in Unix/Linux).
dolfin_ppde-2006-01-30_01.zip dolfin_ppde-2006-02-10.zip dolfin_ppde-2006-03-08.zip