Is there a way to delete mesh cells with particular cell index?

Hello, I would like to know if I can delete some of the mesh cell either from their cell index or from their midpoint ?
Consider the mesh below, I would like to selectively delete some of the elements like with cell id 1, 5 and 10. Is there a way to do it ?

I went through this post, which makes a copy of the mesh and using MeshEditor() deletes the specific cells, is this the only way or I can change my mesh without making a copy of it ?

I would highly appreciate some pointers on the same.
Thanks.

As far as I know you need to make a copy if you want to delete a cell, as it would affect the dofmap of a corresponding FunctionSpace and the coefficients of a Function.

Why do you want to delete the cell? What is the usecase?

Actually, I want to use this mesh cell deletion to remove the mesh cells containing a specific value of the function say 1 and retain those mesh cells having another value of the function say 0. Kindly refer to my this post to get more understanding, in short I want to extract those mesh cell ids with say containing a particular value of function and deleting them.

Thanks.

I wouldn’t delete the cells, I would rather deactivate them (of course, adding additional boundary conditions for those cells that are now on the “activated” interface is not trivial).

2 Likes

Wow !! How does this activation, deactivation of cells with additional boundary conditions for activated cells work ? Can you please give me some resources on it to explore this method.
Thanks.