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:
- Returns:
- (L’’, M’’, N’’, 3)
ndarray Center points array with new resolution. Each axis corresponds to the radial, poloidal, toroidal, and XYZ coordinates, respectively.
- (L’’, M’’, N’’, 3)
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]]]])