FEA with Gridap.jl

The Finite Element Method part writes every loop by hand, which is how the method is learned, but a model with a few hundred thousand degrees of freedom in three dimensions needs a faster code. Gridap is a finite element library written in Julia by Santiago Badia and Francesc Verdugo [1]. A model is written as its weak form, nearly as it appears on paper, and Julia’s just-in-time compiler turns that description into machine code [2]. The same language serves for the readable model and the fast assembly, so the two-language problem of Python with a compiled core does not arise.

Each chapter in this part solves one problem with three tools. Gmsh [3] builds the geometry and the mesh, Gridap solves the weak form, and ParaView shows the result. Wherever a hand solution exists, we compare it with the finite element result before trusting the model.

Installing the tools

Julia is installed with juliaup, which also keeps it up to date. On Linux and macOS

curl -fsSL https://install.julialang.org | sh

and on Windows

winget install --id Julialang.Juliaup -e

The finite element packages are installed from Julia’s package manager. GridapGmsh reads gmsh meshes into Gridap, and Gmsh gives Julia the gmsh library itself, so no separate gmsh installation is needed to build a mesh:

using Pkg
Pkg.add(["Gridap", "GridapGmsh", "Gmsh"])

The gmsh program with its graphical interface, for looking at a mesh, is downloaded from gmsh.info, and ParaView from paraview.org. On Linux the gmsh binary needs the system’s GLU library (sudo apt install libglu1-mesa on Ubuntu). ParaView ships pvpython and pvbatch, which run ParaView scripts without opening a window, and the images in this part are made that way.

References

[1]
Badia S, Verdugo F. Gridap: An extensible finite element toolbox in Julia. Journal of Open Source Software 2020;5:2520. https://doi.org/10.21105/joss.02520.
[2]
Verdugo F, Badia S. The software design of Gridap: A finite element package based on the Julia JIT compiler. Computer Physics Communications 2022;276:108341. https://doi.org/10.1016/j.cpc.2022.108341.
[3]
Geuzaine C, Remacle J-F. Gmsh: A 3-D finite element mesh generator with built-in pre- and post-processing facilities. International Journal for Numerical Methods in Engineering 2009;79:1309–31. https://doi.org/10.1002/nme.2579.