Skip to content
SciStack

Finite elements

Meshes, weak forms, and finite element solvers for PDEs on real geometries.

A circular hole in a wide plate under tension raises the stress at its edge to three times the stress far away. That factor comes from a closed-form solution, which exists for the circle and almost nothing else. In a real bracket the only way to the number is to cover the part with a mesh of triangles or tetrahedra and solve the equations of elasticity on it. On each element the solution is a simple polynomial, neighbors share their nodes, and the partial differential equation becomes one large sparse linear system: that is the finite element method. Engineers bring stresses in parts and heat flow in housings, geologists groundwater flow under a dam, physicists the field around an electrode, biologists the mechanics of bone.

In Python, scikit-fem assembles the matrices from a weak form, the equation multiplied by a test function and integrated over the domain, written as a decorated Python function. Gmsh, with its Python module gmsh, meshes real geometries. In Julia, Gridap.jl lets you write the weak form almost as on paper, and Ferrite.jl hands you the assembly loop to write yourself. Never trust a single mesh: solve again with elements half the size, and if the quantity you report moves, neither answer is converged. With linear elements and a smooth solution the error should fall by a factor of four each time. The stress at a sharp inner corner never settles, because in the equations it is infinite.

Start with the Poisson equation on a square, where an exact solution checks your code, then boundary conditions, then a real mesh from Gmsh, then elasticity or heat flow in time. Finite differences on regular grids belong to partial differential equations, the sparse solvers underneath to sparse and large linear systems.

What belongs here

Solving partial differential equations on unstructured meshes: weak forms, basis functions, assembly, boundary conditions, mesh generation, and error estimates, with libraries such as scikit-fem in Python and Gridap.jl in Julia. Finite differences on regular grids belong to pdes; the sparse linear solvers underneath to sparse-linear-algebra.

0 tutorials by type and language

PythonJulia
Concept – –
Tool – –
Recipe – –
Visualization – –
Project – –