Hi,
you have to add a FaceDescriptor before you can add 2D elements (a 2D mesh is handled as a single face).
When adding a FaceDescriptor you get it's number as return value. Use this value as first argument of your Element2D.
Code:
fd = ngmesh.Add (FaceDescriptor(surfnr=1,domin=1,bc=1))
ngmesh.Add(Element2D(fd,[...]))
You could also use an hp-refinement when generating a SplineGeometry from python. If you append a segment to your geometry, just add "hpref=1" to mark the segment.
Code:
geom.Append([...],hpref=1)
After converting the mesh to an ngsolve mesh you can call the RefineHP function like this:
Code:
mesh = ngsolve.Mesh(ngmesh)
mesh.RefineHP(levels=3,factor=0.5)
Regards,
Christoph