Conventional wisdom tells us that magnetic field lines must either form closed loops, or shoot off to infinity. However, this leaves out the possibility that a magnetic field line, even if it stays confined inside a compact region of space, can in principle come back to close to its starting point but miss it, forming a quasi-loop that never quite closes.
In particular, I suspect it's possible to set this up using a twisted-torus magnetic field like the ones in a tokamak, where by controlling the relative strengths of the toroidal and poloidal components one can engineer situations where magnetic field lines close upon themselves after $N_\mathrm{t}$ toroidal loops around the torus and $N_\mathrm{p}$ poloidal loops about it, but one can also engineer things such that this never quite happens and the magnetic field line occupies a dense subset of a surface (or even a dense subset of space?).
Alas, in looking for an explicit expression for such a field I got drowned in technical results for tokamaks and magnetic fields in neutron stars, so I'll just leave this here in case someone wants to have a crack at it.
Is this possible? I'm for now mostly interested in results for this specific configuration, but if this configuration won't work (i.e. if some result guarantees that field lines in this setting do close upon themselves) then I'm also interested in examples from further afield.