mesh.Mesh.volume#

Mesh.volume()#

Return the total volume of a volumetric Mesh.

Returns#

float

For a volumetric Mesh (level=3), the total volume of all elements (see Notes). For a Mesh of level < 3, returns 0.

Notes#

The total volume of the Mesh is computed by taking its border surface (see to_surface()) and computing the volume inside that surface. It is equivalent with:

self.to_surface().volume()

This is far more efficient than:

self.volumes().sum().

Examples#

>>> nx, ny, nz = 4, 3, 2
>>> M = Mesh(eltype='hex8').subdivide(nx, ny, nz)
>>> print(f"{M.volume():.6f}", f"{M.volumes().sum():.6f}")
1.000000 1.000000