Hi, I'd just like to add a few observations. If you plot your mesh, there's a cluster of points near bottom left arch. If you zoom into the cluster, you'll see hanging nodes. Further with
print V.dofmap().tabulate_all_coordinates(mesh).reshape((-1, 2))
you'll see that several dofs have same physical coordinates and some of them lie outside your intended domain. The problem is also visible if you plot the mesh and press v to get labels of the vertices. Finally if you try other domain
geom = Rectangle(0., 0., 5., 5.) - Rectangle(0., 0., 2, 2)
geom.set_subdomain(1, Rectangle(0, 0, 3, 3))
there's no more clustering or hanging nodes but vertex [0,0] is still part of the mesh. Dof associated with this vertex is a source of the PETSc error. I am not sure if this behaviour is unexpected. The CSG demos use A.set_subdomain(1, B)
with B a true subdomain of A in a sense that $B-A$ is an empty set and that's not what you are doing. So to make the example with rectangle work, you could try
geom = Rectangle(0., 0., 5., 5.) - Rectangle(0., 0., 2, 2)
diff = Rectangle(0, 0, 3, 3) - Rectangle(0, 0, 2, 2)
geom.set_subdomain(1, diff)
With the circle, it seems you have to leave some margin to make CGAL work
geom = Rectangle(0., 0., 5., 5.) - Circle(0., 0., 2.5)
diff = CSGIntersection(Circle(0., 0., 3.5) - Circle(0., 0., 2.51),
Rectangle(0.01, 0.01, 3.5, 3.5))
geom.set_subdomain(1, diff)