# Meshtags\_from\_entities(), incompatible function arguments

**URL:** <https://fenicsproject.discourse.group/t/meshtags-from-entities-incompatible-function-arguments/15147>\
**Category:** dolfinx\
**Tags:** mesh, dolfinx\
**Created:** [July 3, 2024, 1:06pm UTC](https://fenicsproject.discourse.group/t/meshtags-from-entities-incompatible-function-arguments/15147 "2024-07-03T13:06:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![hherlyng](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/hherlyng/32/5843_2.png) [@hherlyng](https://fenicsproject.discourse.group/u/hherlyng)\
**Post date:** [July 4, 2024, 6:51am UTC](https://fenicsproject.discourse.group/t/meshtags-from-entities-incompatible-function-arguments/15147/2 "2024-07-04T06:51:08Z")

</div>

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

---

_[View the full topic](https://fenicsproject.discourse.group/t/meshtags-from-entities-incompatible-function-arguments/15147)._
