< Back

Explanation of Cell-Centered data when using NumPy Arrays in PyTecplot


Problem:

In PyTecplot, why is the length of my array of cell-centered data of an IJK ordered zone (Imax)*(Jmax)*(Kmax-1) instead of (Imax-1)*(Jmax-1)*(Kmax-1)?

For example, from a zone with 5x4x3 nodal values, I expect my cell-centered variable array to have a length of 4x3x2 = 24; however, the cell-centered variable array has a length of 40, (5x4x2 = 40). In other words:

zone.num_elements == 24
len(zone.values("CellCentered")) == 40

Shouldn’t these be the same? Why is there a difference?

Solution:

In Tecplot 360, for nodal ordered data, the number of nodes is the product of the I-, J-, and K-dimensions, i.e. (Imax)*(Jmax)*(Kmax). For cell-centered data, the number of data values is (Imax-1)*(Jmax-1)*(Kmax-1). However, when cell-centered data arrays are created, the first two dimensions are kept the same size as nodal data in the background and the final dimension is as expected, in this example: (Imax)*(Jmax)*(Kmax-1). This is what causes the inconsistency with the variable array lengths. The extra values of the array in the I and J dimensions are entered as zeros.

An analogous pattern holds for 2D ordered blocks with cell-centered data. For example, from a zone with 3×5 nodal values, I might expect my cell-centered variable array to have a length of 2×4 = 8. However, in PyTecplot, it’s actually 3×4= 12. Said another way:

zone.values("CellCentered").shape == (2,4) and zone.num_elements == 8
but,
len(zone.values("CellCentered")) == 12.

This is because the first dimension, I, is kept the same size as the nodal data in the background (Imax), and the final dimension is (Jmax-1). The array values for elements in the Imax column are equal to 0.

See the Jupyter Notebook on our GitHub that explains this and many FAQs related to cell-centered, IJ-ordered data arrays. Here’s a preview: