Note
Click here to download the full example code
Append Cell Centers¶
This example will demonstrate how to append a dataset’s cell centers as a length 3 tuple array.
This example demonstrates PVGeo.filters.AppendCellCenters
from pyvista import examples
from PVGeo.filters import AppendCellCenters
Use an example mesh from pyvista
mesh = examples.load_rectilinear()
print(mesh)
Out:
RectilinearGrid (0x7f4faadda348)
N Cells: 16146
N Points: 18144
X Bounds: -3.500e+02, 1.350e+03
Y Bounds: -4.000e+02, 1.350e+03
Z Bounds: -8.500e+02, 0.000e+00
Dimensions: 27, 28, 24
N Arrays: 1
Run the PVGeo algorithm
centers = AppendCellCenters().apply(mesh)
print(centers)
Out:
RectilinearGrid (0x7f4faadda468)
N Cells: 16146
N Points: 18144
X Bounds: -3.500e+02, 1.350e+03
Y Bounds: -4.000e+02, 1.350e+03
Z Bounds: -8.500e+02, 0.000e+00
Dimensions: 27, 28, 24
N Arrays: 2
centers.plot()

Out:
[(3381.633746130961, 3356.633746130961, 2456.633746130961),
(500.0, 475.0, -425.0),
(0.0, 0.0, 1.0)]
Total running time of the script: ( 0 minutes 0.461 seconds)