Skip to main content

compute_cell_centers

Function compute_cell_centers 

Source
pub fn compute_cell_centers(
    block: &Block,
) -> (Vec<Float>, Vec<Float>, Vec<Float>)
Expand description

Compute the geometric center of every cell as the arithmetic mean of its 8 corner node coordinates.

ยงReturns

A tuple (xc, yc, zc) of flat Vec<Float>, each of length (ni-1) * (nj-1) * (nk-1). Cell (i,j,k) is stored at flat index:

  cell_id = i + (ni-1)*j + (ni-1)*(nj-1)*k

where 0 <= i < ni-1, 0 <= j < nj-1, 0 <= k < nk-1.

The cell center is simply:

  x_c = (1/8) * sum of x-coordinates of the 8 corner nodes

(and analogously for y and z). This is exact for parallelepipeds and a reasonable approximation for mildly skewed hexahedra.