Correspondence between faces and elements

Hi, I have a two dimensional mesh Omega and if I compute len(Omega.faces) and len(list(Omega.Elements())) I get the same number.

Furthermore if I do

for e in Omega.Elements():
    print(f' Element {} has {len(e.faces)} faces')

I get that every (volumetric) element is conected to a single face. What I do not understand is why if I do:

for f in Omega.faces:
    print(f' face {} belongs to {len(f.elements)} elements')

I get that some faces belong to one element and some to none. What am I missing?

Thank you very much!

Hi Manuel,

I guess you have a refined mesh ?

faces from coarser meshes are kept with unique numbers, but all elements are enumerated on the current level.


I don’t, my mesh construction consists of the following lines:

from netgen import SplineGeometry
from ngsolve import Mesh

R = 2 
H = 1
geo = SplineGeometry()
geo.AddRectangle( p1 = (-R,0), 
                  p2 =( R, H), 
                  bcs  =["Gamma","Sigma_R","Gamma","Sigma_L"], 
geo.SetMaterial (1, "Omega_e")
c = (0,H/2)
r = H/4

geo.AddCircle(c=c, r=r, leftdomain=2, rightdomain=1)
geo.SetMaterial (2, "Omega_i")

h_max = 0.1*H
Omega = Mesh( geo.GenerateMesh(maxh= h_max))

No refinement after that.

you are right, this was buggy. Fixed in the coming nightly and pre-release,

Thank you very much for confirming it was a but, I was already questioning my existence XD