We present a Matlab code for modelling and topology optimization of hyperelastic structures, including contact modelled by the Third Medium Contact (TMC) approach. By using the so-called HuHu-regularization we penalize the skew distortion of the bilinear finite elements discretizing void regions, thus promoting convergence of the nonlinear solver. First, we show how this method is implemented in a compact code, allowing to simulate contact and force transfer in hyperelastic structures. We then solve two topology optimization problems for minimum end-compliance of structures exhibiting contact. In the first example, contact happens at the supported boundary, while the second features self-contact. The Matlab scripts that replicate the results are included, and we discuss some possible extensions to more general problems.
@article{arxiv.2512.00133,
title = {A Matlab code for analysis and topology optimization with Third Medium Contact},
author = {Andreas Henrik Frederiksen and Ole Sigmund and Federico Ferrari},
journal= {arXiv preprint arXiv:2512.00133},
year = {2026}
}