compute_centers#

cherab.lhd.emc3.cython.utility.compute_centers(vertices, cells, indices)#

Compute center points of each cell.

Assume that each cell is formed by combining an identical number of sub-cells as specified by the indices array. Center points are calculated by averaging the vertices of each sub-cell, which are regarded as the average of barycenters of six tetrahedra.

Note

The overall resolution must be preserved when combining cells; localized variations in resolution are not permitted.

Parameters:
vertices(N, 3) ndarray

Grid vertices. N is the number of vertices, and 3 is the number of coordinates \((X, Y, Z)\).

cells(M, 8) ndarray

Grid cells. M is the number of cells, and 8 is the number of vertices for each cell.

indices(L’, M’, N’) ndarray[uint32]

Specific index array.

Returns:
(L’’, M’’, N’’, 3) ndarray

Center points array with new resolution. Each axis corresponds to the radial, poloidal, toroidal, and XYZ coordinates, respectively.

Examples

>>> import numpy as np
>>> verts = np.array([[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1],
...                   [0, 1, 0], [1, 1, 0], [1, 1, 1], [0, 1, 1]], dtype=float)
>>> cells = np.array([[0, 1, 2, 3, 4, 5, 6, 7]], dtype=np.uint32)
>>> indices = np.array([[[0]]], dtype=np.uint32)  # shape (1, 1, 1)
>>> compute_centers(verts, cells, indices)
array([[[[0.5, 0.5, 0.5]]]])