The problem is likely that deg
is greater than 1. In that case, there exist DoFs that are not located on mesh vertices, so it is not possible to map all DoFs to corresponding vertices. See the following example:
from dolfin import *
mesh = UnitIntervalMesh(10)
for deg in [1,2]:
print("------- "+str(deg)+" -------")
print(" Number of vertices = "+str(mesh.num_vertices()))
Vp = FunctionSpace(mesh, "Lagrange", deg)
print(" Number of dofs = "+str(Vp.dim()))
try:
vtd_p = dof_to_vertex_map(Vp)
except:
print(" Failed.")
exit()
print(" Worked.")