Problems with GetParentElement

Hello everybody,

I’m new to netgen/ngsolve and I have some troubles with the mesh.GetParentElement function. For my purpose, for each element in a fine mesh, I need the number of the parent element in the coarse grid (the fine mesh is constructed by mesh.Refine() from the coarse mesh). I wrote a simple function which should return me the wanted number:

def SimpleGetParentElementNr(element, CoarseGridElemNr, mesh):
if < CoarseGridElemNr:
ParentElemNr = mesh.GetParentElement(element).nr
if ParentElemNr < CoarseGridElemNr:
return ParentElemNr
return mesh.GetParentElement(mesh[ElementId(VOL,ParentElemNr)]).nr

Do you think this function will work?