File indexing completed on 2026-04-09 07:48:50
0001
0002
0003 import numpy as np
0004
0005 def make_record_cells(r):
0006 """
0007 :param r: step record array, eg with shape (1000, 10, 4, 4)
0008 :return cells: eg with shape (1000,10+1 )
0009
0010 * indices of the cells reference record points in flattened record array
0011
0012 In [1]: cells
0013 Out[1]:
0014 array([[ 5, 0, 1, 2, 3, 4],
0015 [ 5, 5, 6, 7, 8, 9],
0016 [ 5, 10, 11, 12, 13, 14],
0017 [ 5, 15, 16, 17, 18, 19],
0018 [ 5, 20, 21, 22, 23, 24],
0019 [ 5, 25, 26, 27, 28, 29],
0020 [ 5, 30, 31, 32, 33, 34],
0021 [ 5, 35, 36, 37, 38, 39]])
0022
0023 This is used for PolyData line connectivity arrays
0024
0025 https://docs.pyvista.org/version/stable/api/core/_autosummary/pyvista.PolyData.html
0026
0027 """
0028 assert r.ndim == 4
0029 assert r.shape[2:] == (4,4)
0030 num_pho, max_rec = r.shape[:2]
0031 cells = np.zeros( (num_pho,max_rec+1), dtype=np.int )
0032 offset = 0
0033 for i in range(num_pho):
0034 cells[i,0] = max_rec
0035 cells[i,1:] = np.arange( 0, max_rec ) + offset
0036 offset += max_rec
0037 pass
0038 return cells
0039
0040