Skip to content

Fix: Loading of polyhedral VTU with different size polyhedra #1463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/meshio/vtu/_vtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def _polyhedron_cells_from_data(offsets, faces, faceoffsets, cell_data_raw):
# cell. Switch faceoffsets to give start points, not end points
faceoffsets = np.append([0], faceoffsets[:-1])

# order of sizes needs to be tracked to preserver cell-cell data correspondence
sizes = []
# Double loop over cells then faces.
# This will be slow, but seems necessary to cover all cases
for cell_start in faceoffsets:
Expand All @@ -74,6 +76,8 @@ def _polyhedron_cells_from_data(offsets, faces, faceoffsets, cell_data_raw):
# Done with this cell
# Find number of nodes for this cell
num_nodes_this_cell = np.unique(np.hstack([v for v in faces_this_cell])).size
if num_nodes_this_cell not in sizes:
sizes.append(num_nodes_this_cell)

key = f"polyhedron{num_nodes_this_cell}"
if key not in cells.keys():
Expand All @@ -90,7 +94,7 @@ def _polyhedron_cells_from_data(offsets, faces, faceoffsets, cell_data_raw):

# Loop over all cell sizes, find all cells with this size, and store
# cell data.
for sz in np.unique(size):
for sz in sizes:
# Cells with this number of nodes.
items = np.where(size == sz)[0]

Expand Down