Ill-conditioning (?) on 2^n structured meshes

Hello,

I am encountering a strange problem on structured meshes. As an example, consider the Maxwell-like problem
∇ × ∇ × u + ∇p = f
∇ · u = 0
with boundary conditions
n × (∇ × u) = g
u · n = 0
I am using type1 order 2 Nédélec elements for u and order 2 Lagrange elements for p.

When I use structured triangular meshes generated with the function “MakeStructured2DMesh” with 2^l elements on each side starting from l = 7 (i.e. 128 x 128) the solution “explodes” as if the matrix is very ill conditioned :


But the problem does not appear for 127x127 and 129x129 meshes and so on:

Even more strangely, if instead of MakeStructured2DMesh, I manually construct a structured mesh as in the i-tutorial of Section 4.3, the problem appears for 129x129 meshes and not for 128x128 ones, and I checked that the two approaches yield the same number of elements.

I attach a code to reproduce the results. The flag myMesh allows to swich between a manually generated structured mesh and the function MakeStructured2DMesh.

StructuredMeshes.ipynb (6.1 KB)