Skip to main content
Jump to: navigation, search


Introduction and Installation

FEniCS is a package of powerful tools used for mesh generation and solving problems. Dolfin is a core component of FEniCS and serves as an interface and solver. The package is available for download here. There are several ways to install FEniCS- Docker images, Ubuntu packages, and from the source code itself. If installing from source, you will need Python 2.7, git, a c and c++ compiler, a fortran compiler, and OpenGL development files. If compiling from source (not using the install script), then there are several dependencies and optional packages to install (on Linux): eigen3, swig, and boost are all required. Info on this process is available here. Finally, there is an option to install from an install script provided at the bottom of the download page. If problems arise when trying to install the mshr package (running Linux Fedora 22), just edit the hashdist profile (the fenics.yaml file) and take out that package. Finally, before running any Dolfin commands, several environment variables need to be declared. The fenics.custom file will add the variables to your running instance with the command: source fenics.custom

on the command line. ** NOTE: only tested on Linux Fedora 22 **

Running Dolfin commands involves creating a script or program in python/c++ that calls on the Dolfin libraries and running it. From the command line, a user can run python commands:

>>> from dolfin import *
>>> mesh = UnitSquareMesh(10,10)
>>> plot(mesh)
>>> interactive()

File type specifications

Dolfin uses the native Dolfin XML mesh format. It specifies vertices and then either triangles or tetrahedrons. An example of the formatting is shown here:

<?xml version="1.0?>
<dolfin xmlns:dolfin="">
    <mesh celltype="triangle" dim="2">
        <vertices size="###">
            <vertex index="0" x="##" y="##" z="##" />
            <vertex index="1" x="##" y="##" z="##" />
            <vertex index="2" x="##" y="##" z="##" />
            <vertex index="###" x="##" y="##" z="##" />
        <cells size="###">
            <triangle index="0" v0="#" v1="#" v2="#">
            <triangle index="1" v0="#" v1="#" v2="#">
            <triangle index="2" v0="#" v1="#" v2="#">
            <triangle index="###" v0="#" v1="#" v2="#">

Or use celltype ="tetrahedron" dim="3" for three dimensional meshes.


Meshes have vertices and each is defined by triangles or quadrilaterals. Faces are defined by the vertices being specified in counter-clockwise order. Objects are usually defined as meshes, with some basic one, two, and three dimensional square meshes being available to generate. For example:

mesh = UnitSquareMesh(10,10)

Creates a new 10 by 10 unit square mesh. There are also vectors and matrices with which to do physical problems and computations.


Dolfin works with it's own native Dolfin XML format, but can convert both .mesh and .gmsh formats using its own converter. It would not be theoretically difficult to make a XML conversion tool between ICE's native format and Dolfin's XML format.

Dolfin is a able to visualize meshes using VTK, but it can also export to several mesh formats, shown here:

Extention Format/Visualization Software
.pvd VTK format, Paraview and MayaVi
.dx Open DX format
.m GNUOctave and MATLAB format
.tec TecPlot format *
.msh/.res GiD format
  • Indicates that the format may no longer be supported

It is thus possible to export an ICE native mesh to Dolfin for computation and then export a VTK file back to ICE for visualization using Paraview.

Editor Features

Dolfin and FEniCS do not provide a simple GUI or graphical interface, as the FEniCS project is not intended as a pure mesh editor. Rather, the tools serve as a collection of libraries and an interface for performing meshing functions and solving physical systems. From [1]

  • Automated solution of variational problems
  • Automated error control and adaptivity
  • An extensive library of finite elements
  • High performance linear algebra
  • Computational meshes
  • Postprocessing using VTK
  • Python and C++ support

Ease of Use

FEniCS is quick and easy to use from the command line with Python, and can be powerful with extensive and well-documented libraries. However difficulties can arise when installing from source or using the default Hashdist installation profile. Look into installing FEniCS using Hashdist for more information. - Only tested on Linux Fedora 22.

Back to the top