Create an iterator over mesh elements

Hi everyone,

I am finding a bit hard to iterate over every element of my mesh in FEniCSx. I understand how to do it legacy FEniCS where msh is my domain:

    midpoint = [cell.midpoint().array()[:] for cell in cells(msh)]

But I do struggle with the transaltion into FEniCSx, could someone help about that?

Thanks in advance

See: How to enumerate the cells of a mesh with dolfinx v0.6.0? - #2 by dokken
How to generate multiple subdomains based on each cell - #4 by dokken
and dolfinx.mesh — DOLFINx 0.7.0.0 documentation

2 Likes