Problem with dof_to_vertex_map


I encountered a problem with my code. When I do :

Vp = FunctionSpace(mesh, “Lagrange”, deg)
vtd_p = dof_to_vertex_map(Vp)

It gives me these errors :
*** Error: Unable to tabulate dof to vertex map.
*** Reason: Can only tabulate dofs on vertices.
*** Where: This error was encountered inside DofMap.cpp.
*** Process: 0 ***
*** DOLFIN version: 2019.1.0
*** Git changeset: unknown

Do you have any idea why it does not work ?

Thanks a lot for your help!

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()))

        vtd_p = dof_to_vertex_map(Vp)
        print("  Failed.")
    print("  Worked.")

Is just a utility function for simple P1 function spaces. Consider accessing the information you need directly from the DofMap

from dolfin import *

mesh = UnitSquareMesh(1, 1)

for p in range(1, 4):
	V = FunctionSpace(mesh, "CG", p)
	dm = V.dofmap()

	info("Polynomial order: %d" % p)
	info("DoF range owned by this process: %s" % str(dm.ownership_range()))
	info("DoFs block size: %s" % str(dm.block_size()))
	info("Vertex dofs: %s" % str(dm.entity_dofs(mesh, 0)))
	info("Facet dofs: %s" % str(dm.entity_dofs(mesh, 1)))
	info("Cell dofs: %s" % str(dm.entity_dofs(mesh, 2)))
	info("All DoFs (Vertex, Facet, and Cell) associated with cell 0: %s" % str(dm.cell_dofs(0)))
	info("Local (process) to global DoF map: %s" % str(dm.tabulate_local_to_global_dofs()))
1 Like

Thanks a lot for your answers !