Meshtags_from_entities(), incompatible function arguments

Hi mnotazio,

The problem is in the shape of the values array in create_meshtags(). Changing line 72 to
values = np.zeros(len(cells), dtype=np.int32)
should do the trick, at least the plots generated by your code looks good when I run the code with this change. The reason this change is needed is that dolfinx.mesh.meshtags_from_entities() takes the meshtag values as an ndarray, and your syntax
values = np.zeros([len(cells), 1], dtype=np.int32)
creates and ndarray of ndarrays. I would recommend printing both of the two versions of creating the array to see this.

Additionally, I could not run the code with Dolfinx version 0.8.0 without changing
cells, types, x = plot.create_vtk_mesh(mesh)
to
cells, types, x = plot.vtk_mesh(mesh)
on line 86, and also
xdmf.write_meshtags(vt)
to
xdmf.write_meshtags(vt, mesh.geometry)
on line 136, since both of these syntaxes have changed.

Cheers,
Halvor

2 Likes