Skip to content

ParticleHeader: Grid Table, Species Discovery - #596

Open
ax3l wants to merge 2 commits into
AMReX-Codes:developmentfrom
ax3l:topic-read-particles-gridtable
Open

ParticleHeader: Grid Table, Species Discovery#596
ax3l wants to merge 2 commits into
AMReX-Codes:developmentfrom
ax3l:topic-read-particles-gridtable

Conversation

@ax3l

@ax3l ax3l commented Jul 23, 2026

Copy link
Copy Markdown
Member

Follow-up to #581 (stacked on its branch; the first commits shown here belong to #581).

Depends on:

Summary

  • Bind the particle grid table: amrex.ParticleHeader.grids exposes AMReX's per-level table locating each grid's binary particle data (GridEntry: data file index which, particle count, byte offset where) - same C++ parser as ParticleContainer::Restart, no duplicated format logic. Useful for standalone tools, e.g. format converters and parallel readers.
  • Species discovery: amrex.space3d.list_particle_species(plotfile) lists the particle sub-directories of a plotfile/checkpoint by their particle Header files.
  • Compat: disambiguate Redistribute for AMReX development (new IntVect nGrow overload).
  • Docs: both features added to the "Read Back Plotfiles" workflow page.

Testing

Built against AMReX development + AMReX-Codes/amrex#5577 + AMReX-Codes/amrex#5578 (-DpyAMReX_amrex_src=...):

python -m pytest tests/test_readparticles.py tests/test_plotfiledata.py -v

10 passed - including new test_read_particles_grid_table (table totals match num_particles) and test_list_particle_species, and per-level grid-table count assertions in test_read_particles_multilevel.

🤖 Generated with Claude Code

ax3l added a commit to AMReX-Codes/amrex that referenced this pull request Jul 29, 2026
## Summary

Extract the parsing of the per-level grid table (data file index,
particle count and byte offset for each grid) from
`ParticleContainer::Restart` into the shared `ParticleHeader` (follow-up
to #5476), so standalone consumers - e.g. language bindings and format
converters - can locate each grid's binary particle data without
duplicating the on-disk format logic.

- `ParticleHeader` gains a nested `GridEntry {which, count, where}` and
`Vector<Vector<GridEntry>> grids`, filled by the new
`parse_grid_table()`.
- `ParticleHeader::read()` now returns a fully parsed header including
the table; `parse()` still consumes exactly the metadata prefix, keeping
the existing stream contract.
- `Restart` consumes the shared parser instead of inline `HdrFile >>`
reads - one source of truth for the Header format.

Motivation: pyAMReX tools (runtime-SoA plotfile reading
AMReX-Codes/pyamrex#596,
AMReX-Codes/pyamrex#581, and a plotfile-to-openPMD converter
AMReX-Codes/pyamrex#597) need the grid table for
per-grid particle counts and parallel-read planning.

## Testing

```
cmake -S . -B build -DAMReX_ENABLE_TESTS=ON -DAMReX_TEST_TYPE=All -DAMReX_PARTICLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build -j6
ctest --test-dir build -R 'CheckpointRestart' -E 'HDF5|AsyncIO' --output-on-failure
```

All pass: `Particles_CheckpointRestart_3d`,
`Particles_CheckpointRestartDualGrid_3d`,
`Particles_CheckpointRestartDualGridSOA_3d`,
`Particles_CheckpointRestartSOA_3d` (plus `Particles_Redistribute_3d`
from the Small set).

## Checklist

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [x] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [x] include documentation in the code and/or rst files, if appropriate

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
ax3l added a commit that referenced this pull request Jul 29, 2026
Update to latest commit in AMReX `development`.

Needed for #596

---------

Signed-off-by: Axel Huebl <axel.huebl@plasma.ninja>
Expose ParticleHeader::GridEntry and the per-level grid table parsed by
AMReX (AMReX-Codes/amrex PR: ParticleHeader grid table), which locates
each grid's binary particle data: data file index, particle count and
byte offset. Useful for standalone tools, e.g. format converters and
parallel readers, without duplicating AMReX's format logic.

Requires an AMReX version that includes the grid-table refactor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ax3l
ax3l force-pushed the topic-read-particles-gridtable branch from 0b75091 to 65edd68 Compare July 29, 2026 18:35
@ax3l
ax3l marked this pull request as ready for review July 29, 2026 18:35
Add list_particle_species(plotfile) to discover the particle
sub-directories of a plotfile/checkpoint by their particle Header
files, re-export it from each dimension module, and document species
discovery and the grid table in the read-back workflow page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ax3l
ax3l force-pushed the topic-read-particles-gridtable branch from 65edd68 to 69c7694 Compare July 29, 2026 18:35
@ax3l
ax3l requested review from WeiqunZhang and atmyers July 29, 2026 18:36
@ax3l ax3l added the component: particles Particles label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants