How to extract mesh cell data from xdmf file?

Hi, I am interested in knowing how to extract a specific data from xdmf file ?
My xdmf file stores a function named phi which lives on FunctionSpace of ('CG', 1) now when I visualize it in paraview, it looks like this -

I want to know how I can extract the cell index of those mesh cells whose cell midpoint is red which is 1, if I explain more about phi, it is a damage variable which stores 1 when the material is damaged and 0 when the material in undamaged with continuous spectrum between 0 and 1.

I would appreciate any inputs on the above.
Thanks
PS: Here is my xdmf file.

Hi,

If you only need to do this for visualisation. I think Paraview has the threshold function where you can plot the solution for a particular value. It can even take ranges of value.

1 Like

Hi @adeebkor, thanks for the reply, I appreciate the threshold method of Paraview and I will look more into it how to do that, but my first choice would be to extract the phi function values at each node of the mesh elements.