FacetFESpace loses DoFs after refining the mesh

Hi,

I am trying to use the 0th-order FacetFESpace grid function as an indicator function of edges. However, it seems that after refinements, the FacetFESpace loses some DoFs.
image

Does anyone know what is happening here? And if it does not work, I wonder how to write an indicator function that is 1 on an edge, and 0 everywhere else.

Thanks in advance!

Hi,

if you draw the refined mesh you will see only 16 edges (corresponding to the 16 dofs of the FacetFESpace). The mesh also safes the 5 edges from the coarse mesh (e.g. needed for multigrid). Therefore, mesh.nedge is 16+5=21, and the FacetFESpace should work.

An alternative approach for an indicator function is to use a BoundaryCF

indicator_cf = mesh.BoundaryCF( {"left" : 1}, default=0)

which is 1 at the left edges and 0 else. This approach requires that the edges are parts of the boundary.

Best,
Michael

That makes sense. Thank you so much!