Skip to content

Fix Exodus encode treating every face as full width - #1752

Draft
cmdupuis3 wants to merge 1 commit into
mainfrom
cmd/exodus_encode_fill_value
Draft

Fix Exodus encode treating every face as full width#1752
cmdupuis3 wants to merge 1 commit into
mainfrom
cmd/exodus_encode_fill_value

Conversation

@cmdupuis3

@cmdupuis3 cmdupuis3 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Closes #1753

Overview

_encode_exodus finds the end of each face with np.where(row == -1), but connectivity padding is stored as INT_FILL_VALUE. The comparison never matches, so every face is counted at the maximum width. Two things follow: a mixed mesh collapses into a single element block carrying the wrong element type (triangles and quads all written as SHELL4), and the padding itself is written out as INT_FILL_VALUE + 1 in a slot where a node index belongs.

The fix matches INT_FILL_VALUE. Element blocks then split by face size, which is what Exodus requires — blocks are homogeneous.

One note for reviewers: because blocks now genuinely split, a mixed mesh is regrouped by face size on write, and nothing yet records that permutation, so the mesh reloads reordered. Two existing round-trip tests therefore compare the Exodus faces as a set in this PR instead of element-wise — test_mixed_exodus (on the mixed.exo fixture) and test_grid_ugrid_exodus_roundtrip (on outRLL1deg, which has polar triangles among its quads). The follow-up (cmd/exodus_block_reorder) records the ordering and restores both strict comparisons. This PR is green on its own, but it does temporarily loosen those two assertions.

Expected Usage

import uxarray as ux

grid_path = "/path/to/grid.nc"
data_path = "/path/to/data.nc"

uxds = ux.open_dataset(grid_path, data_path)

# this is how you use this function
some_output = uxds.some_function()

# this is another way to use this function
other_output = uxds.some_function(some_param = True)

PR Checklist

General

  • An issue is created and linked
  • Added appropriate labels (if your uxarray repo permissions allow it)
  • Filled out Overview and Expected Usage (if applicable) sections

Testing & Benchmarking

  • There is adequate test coverage of changes from this PR (add new tests if needed)

Documentation and Examples

  • Docstrings updated with any function changes, and included in all new functions
  • User (public) functions added to docs/api.rst; internal (private) function names start with an underscore (_)

AI Disclosure

AI Usage: Claude Opus 5

  • I have tested and take responsibility for all AI-generated content in my PR.

`_encode_exodus` looked for padding with `row == -1`, but connectivity is
padded with `INT_FILL_VALUE`. The match never fired, so every face was
counted at the maximum width: a mixed mesh collapsed into a single block
with the wrong element type, and the padding itself was written out as
`INT_FILL_VALUE + 1` where a node index belongs.

Match `INT_FILL_VALUE` instead. Blocks now split by face size, which is what
Exodus requires -- element blocks are homogeneous -- so a mixed mesh is
genuinely regrouped on write and reloads permuted. Two existing round-trip
tests, `test_mixed_exodus` and `test_grid_ugrid_exodus_roundtrip`, compare
the Exodus faces as a set for now; recording and restoring the original
order is a separate fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cmdupuis3 cmdupuis3 self-assigned this Sep 10, 2026
@cmdupuis3 cmdupuis3 added bug Something isn't working accuracy Related to mathematical accuracy of operations, such as numerical precision or rounding errors labels Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accuracy Related to mathematical accuracy of operations, such as numerical precision or rounding errors bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exodus encode treating every face as full width

1 participant