Face list of vertex is empty

I already have the next question: I want to explore the mesh topology. Namely I need the faces, that are connected to a vertex. After reading i-tutorial 1.8 my hope was that something like the following would be possible:

from ngsolve import *
from netgen.occ import Z, Cylinder, OCCGeometry
from netgen.meshing import MeshingStep

cyl = Cylinder( (0,0,0), Z, r=1, h = 2)
cylf = cyl.MakeFillet(cyl.edges, 0.2)
mesh = Mesh(OCCGeometry(cylf).GenerateMesh(maxh=0.8,perfstepsend=MeshingStep.MESHSURFACE))

# is empty
mesh.vertices[0].faces

Unfortunately the returned tuple is empty. Do I need to polulate the face list before accessing it, or is this information not available and do I have to create own structures, that store this information?
Since faces store the correct vertices, e.g.

mesh.faces[0].vertices

returns the face vertices. So I could build a mapping in own data structures. I was just curious, why the face list is not directly available.
Maybe someone can give me a hint here?

Thanks in advance and many greetings
Mathias

Only the higher dim elements know which lower ones are included in them, so you can do:

[f for f in mesh.faces if mesh.vertices[0] in f.vertices]

Thanks for the explanation - and this loop works perfectly fine!

you can go both directions in the topology, also vertex → faces.
We have stored the vertex → elements table, which is used to build vertex → faces on the fly, in O(1) complexity. It was overseen to loop also over the vertex → surfaceelements, just added it.

In the other solution you get sub-optimal complexity O(N).

You are a good tester for surface-only pdes !

Hello Joachim,

thanks for this information. That is great. Indeed my idea was to build a map (hash table) on my own, to get good performance for the lookup. Great that this is already built in - I will give this a try!

now it’s on github, here is the updated code:

Thank you very much, that was really fast! I just checked out current master and can confirm that the functionality works now without any issues.