Skip to content

Add on_input_mesh to write_mesh and write_function - #94

Open
finsberg wants to merge 1 commit into
finsberg/opencarp-backendfrom
finsberg/on-input-mesh-write
Open

finsberg wants to merge 1 commit into
finsberg/opencarp-backendfrom
finsberg/on-input-mesh-write

Conversation

@finsberg

@finsberg finsberg commented Nov 2, 2026

Copy link
Copy Markdown
Member

Summary

write_mesh and write_function get an on_input_mesh: bool = False argument, the same as write_meshtags, write_cell_data and write_point_data already have. Writing everything in the input ordering is now one flag on every call:

io4dolfinx.write_mesh(filename, mesh, on_input_mesh=True)
io4dolfinx.write_function(filename, u, on_input_mesh=True)
io4dolfinx.write_meshtags(filename, mesh, tags, on_input_mesh=True)
io4dolfinx.write_cell_data(filename, f0, 0.0, mode, args, backend, on_input_mesh=True)

Before, the mesh and function needed separate functions (write_mesh_input_order, write_function_on_input_mesh), while tags and data used a flag.

Changes

  • write_mesh(..., on_input_mesh=True) builds the mesh data with create_original_mesh_data, and write_function(..., on_input_mesh=True) builds the function data with create_function_data_on_original_mesh. These are the same builders the old functions use. mesh_name now works in both orderings.
  • write_mesh(..., on_input_mesh=True, store_partition_info=True) raises a ValueError, because partition info has no meaning for a mesh in the input ordering.
  • Deprecation: write_mesh_input_order and write_function_on_input_mesh keep their signatures and are still exported from io4dolfinx. They now call the new keyword and emit a DeprecationWarning, following the pattern of reconstruct_mesh.
  • The old functions moved from original_checkpoint.py to checkpointing.py, to avoid a circular import. original_checkpoint.py keeps the data builders. Only code that imports the old functions from io4dolfinx.original_checkpoint directly is affected; nothing in the repo does.
  • Tests, docs (quickstart, input-order tutorial, openCARP backend) and docstrings now use the new keyword.

Testing

  • The existing original-checkpoint tests, which run under MPI through ipyparallel, now use write_mesh/write_function with on_input_mesh=True, and pass.
  • The openCARP tests write the mesh with write_mesh(on_input_mesh=...) in both orderings, and pass serially and on 3 ranks.
  • Checked by hand:
    • the old and new calls write byte-identical files;
    • the deprecation warnings point at the caller's line;
    • store_partition_info=True with on_input_mesh=True raises.
  • Full suite: 2646 passed. The 4 failures in test_legacy_readers.py also fail without these changes and come from the local legacy data. ruff and mypy pass.

🤖 Generated with Claude Code

write_mesh and write_function take on_input_mesh, like write_meshtags,
write_cell_data and write_point_data, so a file in the input ordering is
written with one flag passed to every call. write_mesh_input_order and
write_function_on_input_mesh call them with on_input_mesh=True and are
deprecated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@finsberg
finsberg requested a review from jorgensd November 2, 2026 16:41

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant