Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (55 sloc) 4.92 KB

Develop XDMF format for visualisation and checkpointing

This is a summary of my work done during summer 2017 as a part of my Google Summer of Code project. The project is mostly related to the finite element library FEniCS ( and XDMF file format (

The work done could be divided into contributions to these three open-source codes:

DOLFIN contribution

XDMF contribution

VTK contribution

  • (Open) merge request

    ParaView imports VTK library and it translates all XDMF data to VTK data format in a specific code path. This merge request adds the necessary logic to interpret new FiniteElementFunction Attribute. It understands what ElementFamily, ElementDegree and ElementCell in XDMF actually means and it knows how to prepare VTK data from it.


The FEniCS code, which does a finite element algebra and produces exemplary test functions could be found at The data it produces are available here With my contributions you can read and visualize any of the exemplary files.

For clarity, let me show some examples of new functionality introduced by this project.

In Python interface to FEniCS you can write

import dolfin as d

mesh = d.UnitSquareMesh(2, 2)
V = d.FunctionSpace(mesh, "DG", 2)

u = d.project(d.Expression("sin(8*x[0])*cos(8*x[1])", degree=5), V)

with d.XDMFFile("result1.xdmf") as file:
  file.write_checkpoint(u, "u", 0)

This writes result.xdmf light-data and result.h5 heavy-data files. These can be visualized in ParaView thanks to my contribution and gives the following picture


Apart from CG and DG spaces on triangles, tetrahedra, quadrulaterals and hexahedra, non-trivial function space Raviart-Thomas of order 1 (FEniCS notation, in mathematics it is usually called degree 0) could be visualized. The FEniCS code

import dolfin as d

mesh = d.UnitSquareMesh(10, 10)
V = d.FunctionSpace(mesh, "RT", 1)

u = d.project(d.Expression(("sin(8*x[0])*cos(8*x[1])", "x[0]*x[1]"), degree=5), V)

with d.XDMFFile("result2.xdmf") as file:
  file.write_checkpoint(u, "u", 0)

produces a function, which has continuous normal components over edges of triangles. Normal component is the same as X-component for some edges and its continuity is clearly visible


Glyphs for such vector space shown on its magnitude looks like


GSoC blog

You can have a look at my progress in chronological order as captured in my blog,

Future work

  • Higher-order elements (degree > 2) are not implemented in VTK. My code interpolates such functions to the linear elements and plots them instead. More accurate approximation is possible with tesselation of element into linear subelements.
  • DOLFIN XDMF IO data format stores 4 data arrays, but VTK and XDMF visualization takes into account only first two of them. The last two array which contain number of degrees of freedom in cell and cell ordering is not needed for uniform (with respect to degree) elements. We should get rid of this redundancy in DOLFIN.
  • More finite element families could be implemented, Crouzeix-Raviart, Brezzi-Douglas-Marini, etc.
  • Reading a DOLFIN function assumes full knowledge of a FunctionSpace where the function lives. From a user point of view this is too restrictive and there are possibilities how this could be simplified.
  • One of the stored arrays, the array containing so-called degrees of freedom mapping, usually repeats when time series of a functions from the same space is stored. This produces redundant data. There is a space for optimization.