Unexpected behaviour of FESpace defined on interface

Dear colleagues,

I am trying to solve an interface problem in mixed form with a Lagrange multiplier on the internal boundary. Using the finite element space

L = L2(mesh, order = order, definedon=“”, definedonbound=“interface”)

for the Lagrange multiplier I obtain the error (please see the attached file)

netgen(7069,0x7000061f6000) malloc: *** error for object 0x12b0e4140: pointer being freed was not allocated
netgen(7069,0x7000061f6000) malloc: *** set a breakpoint in malloc_error_break to debug
Caught SIGABRT: usually caused by abort() or assert()

However, with the choice

L = H1(mesh, order = order, definedon=“”, definedonbound=“interface”)

everything works fine.

Best regards,
Salim

Attachment: transmissionPb_mixed.py

The standard L2 space does not have degrees of freedom at BND elements. You need to use the SurfaceL2 space for this:

L = SurfaceL2(mesh, order=order, definedon="", definedonbound="interface")

note that you can compute the error against the coefficientfunction itself and you do not need to interpolate it:

upe = CoefficientFunction([p_top if mat == "top" else p_bottom for mat in mesh.GetMaterials()])

# L2 error
err = sqrt(Integrate((upe-glob)*(upe-glob),mesh))

if you want to compare it to the interpolation an easier way would be:

upe = GridFunction(Vpost, name="exact")
upe.Set(CoefficientFunction([p_top if mat == "top" else p_bottom for mat in mesh.GetMaterials()]))

Best
Christopher

Dear Christopher,

Thank you very much for your help and for the trick that simplifies the calculation of the error.

I take this opportunity to congratulate the entire NGsolve team for the formidable tool they have created. Thank you for making it available to the community.

Best,
Salim