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 (0x7fd1c002f0a8)
  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 (0x7fd1c002f1c8)
  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()
append cell centers

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.722 seconds)

Gallery generated by Sphinx-Gallery