Wrong number of edges

Hi,

it appears that the number of edges is incorrect after calling a Refine() on an NGSolve mesh:

from ngsolve import *
mesh = Mesh(unit_square.GenerateMesh(maxh=1))
print(mesh.nv, mesh.nedge)
mesh.Refine(onlyonce=True)
print(mesh.nv, mesh.nedge)
Draw(mesh)

I get mesh.nedge as 9, while the mesh only has 8 edges. From other examples I’ve tried, it appears that the number reported is the sum of the edges plus the number of edges that have were split. I’m currently on the latest master branch.

Best,
Henry

Yes, for prolongation and restrictions the “old” edges of a refinement are kept in the mesh. It’s not a bug, it’s a feature!

Best,
Christoph

Hi Christoph,

Thank you for the clarification? Is there a way of getting the number of edges I expected (in c++)?

Best,
Henry

sum(HCurl(mesh, order=0).FreeDofs())

is a bit of a hacky way. depends how efficiently you need it

I need the number of edges to define the number of global degrees of freedom in an FE space, which I’d previously been doing with ma->GetNEdges();

you can do the same as the hcurl fespace and set the coupling type of the edge dofs of the coarse mesh to UNUSED_DOF. Then you can continue to use the numbering provided by the mesh topology for associating edge nrs to dof nrs

Have a look in hcurlhofespace.cpp and search for fine_edge

Thank you, Christopher!