How to link every dof with its coordinate and import it to matlab

Hi,
I would like to get the dof and their coordinate and import them to matlab
I’ve been trying to use
d2v = mesh_coordinates[dof_to_vertex_map(W)]
for a mixed finite element space but I failed as I get the below error


Error: Unable to tabulate vertex to dof map.
*** Reason: Cannot tabulate vertex_to_dof_map for a subspace.
*** Where: This error was encountered inside fem_utils.cpp.
*** Process: 0


*** DOLFIN version: 2019.2.0.dev0
*** Git changeset: unknown


I have then tried using

element = W.element()
dofmap = W.dofmap()
for cell in cells(mesh):
element_coordinates = element.tabulate_dof_coordinates(cell)
RT_CG_coordinates.append(element_coordinates)
element_dof = dofmap.cell_dofs(cell.index())
RT_CG_dof.append(element_dof)
and I have succeed to get each alone.

Can anyone guide me on how to link each dof to its coordinate so I can import them and plot them in matlab.

Please add a proper minimal working code example, so that one can reproduce your error. I would also recommend you to encapsulate your code and terminal output with 3x` so that it formats properly:

from dolfin import *
mesh = UnitSquareMesh(10,10)

I am not entirely sure what you want to do, but you can get the dof coordinates like this:

from dolfin import *
import tabulate

mesh = UnitSquareMesh(2,2)
W = FunctionSpace(mesh, MixedElement([VectorElement('CR', mesh.ufl_cell(), 1), FiniteElement('DG', mesh.ufl_cell(), 0)]))

dof_coordinates = W.tabulate_dof_coordinates()

print(tabulate.tabulate([[i, coord] for i, coord in enumerate(dof_coordinates)], headers=['Global dof index', 'dof coordinate']))

Thanks , it was very helpful.

Hello, I have a same demande, whatif I have a mixed element and high order (degree >1) shape function