Hi,
the function "specialcf.mesh_size" is a CoefficientFunction. Therefore it needs an integration point to evaluate the mesh size. If you have an NGSolve mesh can call "mesh(x,y)" to get an integration point with the coordinates x,y.
But I would suggest an easier solution:
Code:
from netgen.geom2d import unit_square
h_max = 0.2
ngmesh = unit_square.GenerateMesh(maxh=h_max)
from ngsolve import *
mesh = Mesh(ngmesh)
elvol = Integrate(CoefficientFunction(1),mesh,element_wise=True)
h = [(2*vol)**(1/2) for vol in elvol]
print(min(h),max(h))
In the first step you calculate the volume of each element. Knowing that the volume of a simplex is connected to the Jacobian determinant (which scales h^dim) you get an estimate for the mesh size.
Best,
Christoph