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

determine parent of refined cells (dolfin interface change)

+2 votes

In order to determine the parents for the cells of a refined mesh, the following code used to work.

newmesh = refine(mesh)
# determine parent cell association map
pc = newmesh.data().mesh_function("parent_cell")

Unfortunately, this now raises the following error.

pc = newmesh.data().mesh_function("parent_cell")
RuntimeError:
[...]
*** -------------------------------------------------------------------------
*** Error: Unable to access a MeshFunction via mesh data.
*** Reason: MeshFunctions can no longer be stored in MeshData. Use arrays instead.
*** Where: This error was encountered inside MeshData.cpp.
*** Process: 0
*** -------------------------------------------------------------------------

Could someone please point out how this can be done with a current version (I am using the nightly snapshot ppa).

Cheers, Martin

asked Jun 10, 2013 by meigel FEniCS User (1,520 points)

1 Answer

+3 votes
 
Best answer

Try:

marker = MeshFunction("bool", mesh, mesh.topology().dim(), True)
newmesh = refine(mesh, marker)
pc = newmesh.data().array("parent_cell", newmesh.topology().dim())

which should just be an array with the parent cell data.

If you refine without using markers, the parent cell data is not recorded...

answered Jun 10, 2013 by chris_richardson FEniCS Expert (31,740 points)
selected Jun 10, 2013 by meigel

Thanks. This results in

NotImplementedError: Wrong number or type of arguments for overloaded function 'MeshData_array'.
Possible C/C++ prototypes are:
dolfin::MeshData::array(std::string,std::size_t)
dolfin::MeshData::array(std::string,std::size_t) const

Looks like some of the functions need to be ignored in the Swig interface.

Sorry, my mistake, I think you have to specify the dimension of the array, i.e.

pc = newmesh.data().array("parent_cell", newmesh.topology().dim())

for cell based arrays.

I've edited my reply above...

That seems to work. Much appreciated.

...