I'll answer my own question.
Just convert the vtk mesh to hdf5 with gmsh/meshio, dolfin-convert and a fenics script for xml->hdf5. Setting parameters['reorder_dofs_serial'] = False
retains the dof ordering of the mesh and the (now matching!) VTK node data can simply be written into a P1 function u
with u.vector()[:] = data
, assuming that data
is an array with a scalar value in every node. If you have a vector function, data
needs to be reshape
d and flatten
ed correspondingly. (Say $u=(u_1, u_2, u_3)$, then u.vector()
has the entries $[u_{1_1},u_{1_2},...,u_{1_N}, u_{2_1},u_{2_2},...,u_{2_N}, u_{3_1},u_{3_2},...,u_{3_N}]$.)