While accurate and reproducible code is an integral part of any scientific software package, if it cannot be run in a reasonable timeframe, it can be worthless. In this blog post we will present timing results, of some Finite Element calculations across different frameworks/implementations and discuss the results. For reference, we are considering the following problem, the Poisson Equation with Dirichlet Boundary Conditions on the unit square (denoted as $D$), although arbitrary domains can be handled. This also matches tutorial 1 provided by FEniCS.

We present timings of FEniCS, FEniCS.jl and two Julia implementations, one of which has been partially optimized for speed. To do this, we have used macros such as @inbounds when performing array calculations and removing the zeros from our sparse matrix before solving the linear system. The two Julia implementations rely on FEniCS.jl for its meshing capabilities, although other software could provide the same functionality. This also demonstrates the extensibility of our currently implemented framework, as a basis for other software packages. For the setup, we have run each calculation 5 times, and taken the minimum runtime of each calculation. This is to provide more consistent results, and to reduce any noise present. If more computing power was available, we could take more calculations for an even more accurate estimate.

Finite Element Timings FEniCS FEniCS.jl Julia_fast Julia_slow Number of Vertices 121 0.015142 0.017137 0.002164 0.002577 441 0.016227 0.018098 0.003406 0.003428 2601 0.027649 0.029884 0.012169 0.016549 10201 0.075338 0.085519 0.061790 0.065591 40401 0.337121 0.377015 0.302269 0.304789 90601 0.947638 1.051601 0.800105 0.816946 160801 1.915226 2.073858 1.466550 1.943771 251001 3.604929 3.770259 2.324034 3.009125 361201 6.400061 6.895863 3.527538 4.335571 491401 10.268067 11.076036 5.034412 6.155228 641601 13.118438 13.834172 6.684176 8.873229 811801 19.112446 19.436559 8.956013 10.391539 1002001 26.547864 27.664045 11.291894 14.542494

By examining the data in the above table, one can see that the FEniCS and FEniCS.jl timings are extremely close to each other, with a small overhead due to PyCall.jl. This demonstrates, that from a performance point of view, there is no significant downside in using FEniCS.jl over FEniCS. The pure Julia implementations are much faster, particularly the optimized one, which in some cases, has an over factor two speedup compared to FEniCS. At the same time, some care must be taken. We have only provided data for one class of problems, namely the Poisson Equation stated in [Equation:Poisson], which is fairly straightforward to describe and solve. While our currently implemented Julia code can handle arbitrary boundary conditions and forcing functions it cannot support other equations without some changes, whereas for FEniCS this is fairly straightforward.

Furthermore, some work has also been done on cleaning up code, especially regarding type aliases, and some small fixes regarding some snippets of code, which could (and probably should) be regarded as type piracy. Finally work has been done on direct Julia plotting capabilities. We currently rely on PyPlot, but other plotting backends, such as Makie.jl will be investigated.