Contact mechanics — almost exactly as written on paper!
LowLevelFEM.jl now supports 2D and 3D contact mechanics using penalty and Lagrange-multiplier formulations.
The framework also provides the building blocks for frictional contact, allowing more advanced contact laws to be implemented directly at notebook level.
The idea is simple: write the weak form, assemble the operator, solve the problem.
For penalty contact, the contact stiffness is
K_c = \int_{\Gamma_c} G^T c_n G\,d\Gamma
And in Julia:
C = contact(U, master="master", slave="slave", displacement=u)
G = ContactGap(C)
Kc = ∫(G ⋅ cn ⋅ G; updateFrom=u)
The nonlinear iteration is just as transparent:
R = K*u - f + Kc*(r+u)
Δu = solveField(K+Kc, -R, support=support_increment)
Prefer Lagrange multipliers? The same contact operator can be used directly in a mixed formulation:
B = ∫(Λ ⋅ ContactGap(C, active=:all))
A = SystemMatrix([K B'; B Zλ])
Simple syntax does not mean a simple implementation.
Under the hood, the contact machinery already includes multithreaded, memory-efficient sparse assembly, lightweight geometry updates for faster nonlinear iterations, and support for multiple contact pairs.
This is still a preview of a developing contact framework, but the foundations are already in place — including a path toward dynamic contact simulations.
Meanwhile, I’m continuing to refactor and optimize LowLevelFEM to make its components more consistent, efficient, and reusable.
Next major development: the Spectral Element Method (SEM).
The goal remains the same: bringing mathematical formulations as directly as possible into executable finite element code.
Full reproducible examples in LowLevelFEM.jl:
2D Hertz contact — Penalty method
https://github.com/perebalazs/LowLevelFEM.jl/blob/main/examples/2D-Hertz-penalty-minimal.ipynb
2D Hertz contact — Lagrange multipliers
https://github.com/perebalazs/LowLevelFEM.jl/blob/main/examples/2D-Hertz-lagrange-minimal.ipynb
3D contact — Penalty method
https://github.com/perebalazs/LowLevelFEM.jl/blob/main/examples/contact-3D-penalty-minimal.ipynb
Documentation:
https://perebalazs.github.io/LowLevelFEM.jl/stable/
Feedback, suggestions, and contributions are welcome!


