Skip to content

Ext: PatchBasedMeshRefinement - #252

Open
ax3l wants to merge 2 commits into
openPMD:upcoming-2.0.0from
ax3l:topic-MR
Open

Ext: PatchBasedMeshRefinement#252
ax3l wants to merge 2 commits into
openPMD:upcoming-2.0.0from
ax3l:topic-MR

Conversation

@ax3l

@ax3l ax3l commented Mar 9, 2021

Copy link
Copy Markdown
Member

Adds a simple convention for patch based mesh refinement.

Description

This adds a naming convention to efficiently identify levels of a refined mesh.

Affected Components

  • base (cosmetic)
  • EXT: PatchBasedMeshRefinement

Logic Changes

Adds a naming convention through record suffixes for meshes that can be used to identify refined meshes.

Allows two ways to store a refined mesh: through one record per refinement level (e.g. for ADIOS) or through one record per refinement level and patch (for non-contiguous refinements).

Writer Changes

A writer can suffix the meshes to express levels.

Reader Changes

A reader can group mesh-refined records visually or build an MR structure.

Good candidates:

Unaffected for now:

Data Updater

New functionality. No data update needed.

@franzpoeschel

franzpoeschel commented Jun 28, 2023

Copy link
Copy Markdown

I see two major issues with the current state of mesh refinement:

  1. The use of suffixes _lvl<N> and _<P> seems inconsistent in an otherwise hierarchical data standard, as it reimplements hierarchies at the naming level. Should we consider developing this in conjunction with Allow user to store non-openPMD information #115 (custom hierarchies)?
  2. The feature description in the standard should be more explicit on the required capabilities of the storage formats and maybe even reconsider them. Without mesh refinement, openPMD requires (roughly) a storage format that supports attributes, hierarchies and n-dimensional datasets. With mesh refinement, the backend is additionally required to allow querying written regions (in the API, the information returned by .available_chunks() is purely backend-specific and completely transparent to the actual openPMD standard).
    In my understanding, HDF5 chunking allows storing a sparsely written dataset without using disk space corresponding with the entire domain (rather, it will use disk space corresponding with the covered chunks). Explicitly encoding the written chunks in either the standard or the HDF5 schema would then enable mesh refinement in HDF5, too.
    To me, this seems like too small a detail for making mesh-refinement ADIOS-only over it.

@ax3l

ax3l commented Jul 26, 2023

Copy link
Copy Markdown
Member Author

Potential directions for HDF5 support of MR in openPMD:

@ursg

ursg commented Sep 28, 2023

Copy link
Copy Markdown

This is clearly motivated specifically with a patch-based refinement strategy in mind, and as such probably works very well.

However, I would like to point out that this structure would seem quite alien to other refined mesh approaches (tree-based or individuall-cell-based ones). Deliberately grouping mesh data by refinement level does not come natural to them!

Sorry about this nonproductive comment, as I do not have a suggestion for a suitable, more general approach. There certainly is merit in the proposal as it is specified here, but you might want to adapt a more specific name ("PatchBasedMeshRefinement"), as to not encumber future applications with different approaches.

@ax3l ax3l changed the title Ext: MeshRefinement Ext: PatchBasedMeshRefinement Dec 3, 2025
Comment thread EXT_MeshRefinement.md Outdated
Comment thread EXT_MeshRefinement.md Outdated
Comment thread EXT_MeshRefinement.md
The coarsest level of a record is implicitly assigned the level `0` of a simulation.
The record names of finer levels are suffixed with `_lvl<N>` where `<N>` is the integer of the refined level.

A patch of a refinemnet level shall be a spatially hyperrectangular subselection of the previous level.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A patch of a refinemnet level shall be a spatially hyperrectangular subselection of the previous level.
A patch of a refinement level shall be a spatially hyperrectangular subselection of the previous level.

Comment thread EXT_MeshRefinement.md

A mesh record describing a refined level shall add the following attribute:

- `refinementRatio`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is needed, because we already save the cell size at each level. So this would duplicate the same info.

Comment thread STANDARD.md
see [EXT_BeamPhysics.md](EXT_BeamPhysics.md).
- **ED-PIC**: electro-dynamic/static particle-in-cell codes,
see [EXT_ED-PIC.md](EXT_ED-PIC.md).
- **MeshRefinement**: mesh records refined over multiple levels of resolution,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **MeshRefinement**: mesh records refined over multiple levels of resolution,
- **PatchBasedMeshRefinement**: mesh records refined over multiple levels of resolution,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on the comment above, are there advantages to differentiate between patch-based refinement and other types of refinement?
Or could all types be covered by a very simple/basic extension?

Comment thread EXT_MeshRefinement.md
The coarsest level of a record is implicitly assigned the level `0` of a simulation.
The record names of finer levels are suffixed with `_lvl<N>` where `<N>` is the integer of the refined level.

A patch of a refinemnet level shall be a spatially hyperrectangular subselection of the previous level.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A patch of a refinemnet level shall be a spatially hyperrectangular subselection of the previous level.
A patch of a refinement level shall be a spatially hyperrectangular subselection of the previous level.

@BenWibking

BenWibking commented Jun 25, 2026

Copy link
Copy Markdown

This is supported by openpmd-visit-reader (https://github.com/BenWibking/openpmd-visit-reader) for VisIt, with an extension for how Parthenon (parthenon-hpc-lab/parthenon#1050) handles level suffixes for vector components. (Parthenon's octree AMR works fine in this representation.)

This plugin has also been tested with Quokka and WarpX outputs, which AFAIK adhere more strictly to this proposal.

@pgrete pgrete left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear all,
what would be required to push this across the finish line?
There are now multiple codes that use (some variant) of this extension plus some downstream tooling is available, too.
It seems like a good time to finalize the extension.

Comment thread EXT_MeshRefinement.md
Comment on lines +18 to +19
The coarsest level of a record is implicitly assigned the level `0` of a simulation.
The record names of finer levels are suffixed with `_lvl<N>` where `<N>` is the integer of the refined level.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the "implicit" imply that level 0 cannot (or may not) carry the _lvl suffix?

Comment thread EXT_MeshRefinement.md
Comment on lines +21 to +26
A patch of a refinemnet level shall be a spatially hyperrectangular subselection of the previous level.
Multiple patches might exist in a refined level.

If the implemented file format supports sparse data sets, i.e. through efficient chunking of patches, the refined level must over the previous level in extend and store multiple patches through its chunking mechanism.

File formats that do not support efficient storage a sparesly populated refinement level can store continguous patches on the same level with an additional suffix `_<P>` where `<P>` is the number of the (hyperrectangular) patch in the refinement level.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be specified at all?

For example, if I have a mesh where half of the domain is refined and the other is not, the current wording suggests a either a global mesh with sparse data or a patched based one.
I could imagine that a simpler logic (i..e, just the _lvlN without considering sparse or patches) could be enough as it would already allow a code to query if data at certain location (and a certain level) exist.

I would also consider keeping the _<P> suffix, but optional and allowing for overlapping region (without making guarantees on the data in the overlapping regions), as it would allow to write individual patches/blocks with individual ghost zones (e.g., for debugging or calculating derived quantity on fine levels without prolongation from coarser ones).

This should then also cover/provide flexibility other MR strategies without breaking the existing usage, doesn't it?

Comment thread STANDARD.md
see [EXT_BeamPhysics.md](EXT_BeamPhysics.md).
- **ED-PIC**: electro-dynamic/static particle-in-cell codes,
see [EXT_ED-PIC.md](EXT_ED-PIC.md).
- **MeshRefinement**: mesh records refined over multiple levels of resolution,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on the comment above, are there advantages to differentiate between patch-based refinement and other types of refinement?
Or could all types be covered by a very simple/basic extension?

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

Labels

EXT: New? possible new extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants