aPriori.DNS.compute_cell_volumes¶

aPriori.DNS.compute_cell_volumes(x, y, z)¶

Compute the volumes of the cells in a 3D mesh grid.

This function calculates the cell volumes for a given set of x, y, and z coordinates. The coordinates are provided as 1D vectors. The function computes the distances between consecutive points in each direction, constructs a 3D meshgrid of these distances, and then calculates the volume of each cell.

Parameters:¶

xarray-like

A 1D array of x coordinates.

yarray-like

A 1D array of y coordinates.

zarray-like

A 1D array of z coordinates.

Returns:¶

: cell_volumes : ndarray

A 3D array where each element represents the volume of a cell in the mesh grid.

Example:¶

>>> x = np.array([0, 1, 2, 3])
>>> y = np.array([0, 1, 2])
>>> z = np.array([0, 1, 2, 3, 4])
>>> volumes = compute_cell_volumes(x, y, z)
>>> print(volumes.shape)
(4, 3, 5)
>>> print(volumes)
array([[[1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1]],
       [[1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1]],
       [[1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1]],
       [[1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1]]])