mesh.Mesh.areas#

Mesh.areas()#

Return the areas of all elements in a Mesh of level 2 or 3.

Returns#

array | None

For a level 2 Mesh, the area of the elements. For a level 3 Mesh, the area of the elements’ surface. If the elements or its faces are of eltype ‘tri3’, the areas are exact. For other eltypes, a conversion to ‘tri3’ is done before computing the areas. This can produce an exact result, an approximate result or no result (if the conversion fails). If successful, returns an (n_elems,) float array with the areas.

Returns None if the Mesh level is < 2, or the conversion to ‘tri3’ does not succeed.

Examples#

>>> nx, ny = 3, 2
>>> M = Mesh(eltype='quad4').subdivide(nx, ny)
>>> a = M.areas()
>>> print(a)        # each equals 1. / (nx * ny)
[0.1667 0.1667 0.1667 0.1667 0.1667 0.1667]
>>> print(a.sum())  # equals 1.
1.0
>>> nx, ny, nz = 4, 3, 2
>>> M = Mesh(eltype='hex8').subdivide(nx, ny, nz)
>>> a = M.areas()
>>> print(a)        # each equals (nx + ny + nz) * 2 / (nx * ny * nz)
[0.75 0.75 ...
>>> print(a.sum())  # equals (nx + ny + nz) * 2
18.0...