This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

list of new cells when adapting/refining mesh

+2 votes

Hi,

is there any convenient way to get a list or array of newly created cells after refining a mesh? For example via

mesh2 = adapt(mesh, cells_for_refinement)

It would be very practical to have something like cells_for_refinement, but on the "output" side.

Thanks
Jonas

asked Feb 18, 2015 by EliminatorJR FEniCS Novice (140 points)

1 Answer

0 votes

As far as I know, the only information which is available is the parent-child relationship
between cells.

mesh2.data().array("parent_cell", mesh2.topology().dim())

which is a list of cell indices in the original mesh. I guess you could use that to iterate through
the parent mesh, and work out how many children each cell has:

count = CellFunction("size_t", mesh, 0)
for idx in mesh2.data().array("parent_cell", mesh2.topology().dim()):
     count[idx] += 1

Now you have a CellFunction on the original mesh. You can go through the new mesh,
and check the count for your parent... if it is more than 1, then it is a refined cell.

answered Feb 18, 2015 by chris_richardson FEniCS Expert (31,740 points)
...