mesh.Mesh.lengths#
- Mesh.lengths()#
Return element or perimeter lengths for a Mesh of level 1 or 2.
Returns#
- array | None
For a level 1 Mesh, the length of the elements. For a level 2 Mesh, the length of the elements’ perimeter. If the elements or its edges are of eltype ‘line2’, the lengths are exact. For other eltypes, a conversion to ‘line2’ is done before computing the lengths. 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 lengths.
Returns None if the Mesh level is not 1 or 2, or the conversion to ‘line2’ does not succeed.
Examples#
>>> nx = 4 >>> M = Mesh(eltype='line2').subdivide(nx) >>> a = M.lengths() >>> print(a) # each equals 1. / nx [0.25 0.25 0.25 0.25] >>> print(a.sum()) 1.0
>>> nx, ny = 3, 2 >>> M = Mesh(eltype='quad4').subdivide(nx, ny) >>> a = M.lengths() >>> print(a) # each equals (nx + ny) * 2 / (nx * ny) [1.6667 1.6667 1.6667 1.6667 1.6667 1.6667] >>> print(a.sum()) # equals (nx + ny) * 2 10.0...