The standard L2 space does not have degrees of freedom at BND elements. You need to use the SurfaceL2 space for this:
Code:
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:
Code:
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:
Code:
upe = GridFunction(Vpost, name="exact")
upe.Set(CoefficientFunction([p_top if mat == "top" else p_bottom for mat in mesh.GetMaterials()]))
Best
Christopher