Hi,

I want to compute the actual maxh of a given mesh after it is built. My idea was to iterate through the mesh and call specialcf.mesh_size.Norm(). Something along these lines:

```
from netgen.geom2d import unit_square
mesh = unit_square.GenerateMesh(maxh=h_max)
from ngsolve import *
for e in mesh.Elements2D():
print(specialcf.mesh_size)
```

This does not give me the desired result. I’d appreciate any help

Best wishes,

Henry

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:

```
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

Hi Christoph,

tank you for your help! Your easier solution, has worked well. For 3d I can similarly use

`h = [(3*vol)**(1/3) for vol in elvol]`

or have I messed something up in the constant?

Best wishes,

henry

Hi,

for 3d it should be

`h = [(6*vol)**(1/3) for vol in elvol]`

Here you can find the volume of a simplex. The constant is actually the factorial of the spatial dimension.

Best

Christoph

Hi Christoph,

thanks! Strangely however, using the constant = 6, consistently gives me a max(h) which is larger than the h_max I used to mesh a cube (of side length 2) by a factor of 2[sup]1/3[/sup] (i.e., constant =3). Do you have any idea why this would be the case?

Best wishes,

Henry

Hi Henry,

the maxh argument in GenerateMesh is not a strict upper bound.

Therefore the elements might be slightly larger than the defined maxh.

Best,

Christoph