Skip to content

Running the FFC Demos

doru1004 edited this page Oct 8, 2012 · 7 revisions

Prerequisites

You need to install the FEniCS toolchain. On Debian/Ubuntu:

sudo apt-get install fenics

Downloads for Mac OS X 10.6 and 10.7 are at: http://www.fenicsproject.org/download/osx_details.html#osx-details

You will need to get the Trunk revision of UFL:

bzr branch lp:ufl

And the PyOP2 branch of FFC:

bzr branch lp:~mapdes/ffc/pyop2 ffc

These both need adding to your PYTHONPATH so that they are found ahead of the release versions of UFL and FFC (assuming you're in the folder where you branched UFL and FFC):

export PYTHONPATH=`pwd`/ufl:`pwd`/ffc:$PYTHONPATH

You will also need the Triangle and gmsh programs to generate meshes. On Debian/Ubuntu:

sudo apt-get install triangle-bin gmsh

For Mac OS X, you will probably need to compile Triangle from source. Triangle is a single C source file, so it shouldn't be too hard to compile. The source is available from the homepage of Triangle: http://www.cs.cmu.edu/~quake/triangle.html

Gmsh binaries for Mac OS X are available here: http://geuz.org/gmsh/bin/MacOSX/

Running

The FFC demos are in the demo folder and are:

  • mass2d_ffc.py: A simple solver for the identity equation (f = g). The expected solution is [1, 2, 3, 4]
  • mass2d_triangle.py: As mass2d_ffc.py but reads its mesh from a Triangle file
  • laplace_ffc.py: Solves the Laplace equation on a square domain with strong boundary conditions. The expected solution is [1, 1, 1, 1.5, 1.5, 1.5, 2, 2, 2]
  • weak_bcs_ffc.py: Solves the Laplace equation on a square domain with strong and weak boundary conditions. The expected solution is [1, 1, 1, 2, 2, 2, 3, 3, 3]
  • adv_diff.py: Solves the advection-diffusion equation on a square domain.

The demos are all hard-coded to run with the sequential backend at present, but this can be altered by changing the paramter that is passed to op2.init(). All of them apart from adv_diff.py can be invoked with python <demo-name>.py

Running adv_diff.py

The advection-diffusion demo requires a mesh file as input. To generate meshes:

cd demo/meshes
./make_example_meshes.sh

This will generate three sets of mesh files, with prefixes small, medium and large. You can run the advection-diffusion demo with these meshes (for example) with:

cd demo
python adv_diff.py meshes/large

Note that the parameter specifying the mesh is the prefix of the mesh files - that is, the path to the mesh files without the .ele or .node suffix attached.

There is no specific validation for this demo yet, but you should see the blob move a little to the right and diffuse so that it is green/blue by the time the simulation has finished running. Press q once to start the simulation, and q once to exit when it has finished.