Skip to content

WIP: Towards Curvilinear Swarms - #1391

Open
pdmullen wants to merge 87 commits into
developfrom
pdmullen/towards-curv-swarm
Open

WIP: Towards Curvilinear Swarms#1391
pdmullen wants to merge 87 commits into
developfrom
pdmullen/towards-curv-swarm

Conversation

@pdmullen

@pdmullen pdmullen commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

PR Summary

Made in part with generative AI.

Swarm positions are now treated as native mesh coordinates x1, x2, and x3 rather than Cartesian x, y, and z. That change updates the default swarm variable names, the internal swarm coordinate accesses, output defaults, and
the touched examples/tests so the swarm infrastructure is expressed in coordinate-system-native terms.

On the remeshing side, the refinement branch now classifies particles against
the actual daughter split interfaces returned by the mesh topology, expressed
in x1/x2/x3. For the current uniform coordinate systems this is equivalent to
the old midpoint logic, but it is clearer and better aligned with the
generalized coordinate interpretation. We still emit a warning for non-
UniformCartesian swarms because broader curvilinear swarm behavior remains
mostly untested.

PR Checklist

  • Code passes cpplint
  • New features are documented.
  • Adds a test for any bugs fixed. Adds tests for new features.
  • Code is formatted
  • Changes are summarized in CHANGELOG.md
  • Change is breaking (API, behavior, ...)
    • Change is additionally added to CHANGELOG.md in the breaking section
    • PR is marked as breaking
    • Short summary API changes at the top of the PR (plus optionally with an automated update/fix script)
  • CI has been triggered on Darwin for performance regression tests.
  • Docs build
  • Any contribution that was created or modified with the assistance of generative AI must have a comment disclosing this such as // This file was made in part with generative AI.
  • (@lanl.gov employees) Update copyright on changed files

pdmullen and others added 30 commits March 25, 2026 14:46
Co-authored-by: Luke Roberts <lfroberts@lanl.gov>

@Yurlungur Yurlungur left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 Good change and good use of AI.

One possible suggestion below regarding the python API.

Comment thread CHANGELOG.md


### Incompatibilities (i.e. breaking changes)
- [[PR 1391]](https://github.com/parthenon-hpc-lab/parthenon/pull/1391) Towards Curvilinear Swarms

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

Comment on lines +65 to +68
def x(self):
return self.Get("swarm.x")
def x1(self):
return self.Get("swarm.x1")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's really easy to keep backwards compatibility for the python with maybe a try-catch block and overloading both sets of names for these functions. I think we might want to do that because otherwise phdf won't be backwards compatible with old output/dump files, which we may want to mitigate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

happy to do that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in 9842147.

Base automatically changed from pdmullen/particle-amr-v2 to develop May 6, 2026 06:47
@pgrete
pgrete requested a review from jdolence May 7, 2026 19:36
@pgrete
pgrete marked this pull request as draft May 7, 2026 19:39
@pgrete

pgrete commented May 7, 2026

Copy link
Copy Markdown
Collaborator

@pdmullen will look into backwards compatibilty (especialyl for outputs)

@pdmullen pdmullen changed the title Towards Curvilinear Swarms WIP: Towards Curvilinear Swarms May 21, 2026
@pdmullen pdmullen changed the title WIP: Towards Curvilinear Swarms Towards Curvilinear Swarms May 28, 2026
@pdmullen
pdmullen marked this pull request as ready for review May 28, 2026 16:52
@pgrete
pgrete self-requested a review June 4, 2026 19:03

@pgrete pgrete left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In general, the changes look good.
Given that OpenPMD outputs are now merged, the new changes need to be also implemented for those outputs (plus keeping hte logic to choose the restart reader).
Should I take a stab at this or do you @pdmullen ?
Also should we add safeguards again in functions that will definitely result in wrong results in non-cartesian coordinates (like SortParticlesByCell)?

@pdmullen

Copy link
Copy Markdown
Collaborator Author

In general, the changes look good. Given that OpenPMD outputs are now merged, the new changes need to be also implemented for those outputs (plus keeping hte logic to choose the restart reader). Should I take a stab at this or do you @pdmullen ? Also should we add safeguards again in functions that will definitely result in wrong results in non-cartesian coordinates (like SortParticlesByCell)?

I'm happy to take a stab at it!

@pdmullen

Copy link
Copy Markdown
Collaborator Author

In general, the changes look good. Given that OpenPMD outputs are now merged, the new changes need to be also implemented for those outputs (plus keeping hte logic to choose the restart reader). Should I take a stab at this or do you @pdmullen ?

Can you take a look at 834fdea and scream at me if I messed anything up?

Also should we add safeguards again in functions that will definitely result in wrong results in non-cartesian coordinates (like SortParticlesByCell)?

AFAIK, safeguards are not needed for SortParticlesByCell or other swarm functions in non-Cartesian coordinates—they should work correctly for UniformCartesian, UniformCylindrical, and UniformSpherical because all use uniform spacing in native coordinates and Xtoijk correctly uses Dx() which returns that uniform spacing. What would likely break the current design is a non-uniform mesh (e.g., logarithmically-spaced radial grid) where cell spacing varies, since Xtoijk assumes constant dx when computing, e.g., i = floor((x1 - x1_min) / dx). Hope I am not missing something obvious here.

@pgrete pgrete left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I still need to test this in practice, but I'm wondering what this make to restart old sims with the new interface with regard to also keep the old naming (so that outputs for a given simulations are consistent in the name being used).
This also applies to HDF5 outputs.
Otherwise, we might want/gave to bump the output format version to reflect those changes.

particle_record = "position";
particle_record_component = "x";
} else if (vname == swarm_position::y::name()) {
particle_record_component = "x1";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we may need to be more specific wrt coordinate component naming as the standard has specific names depending on the coordinate system (x,y,z or r,t,z), see https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#naming-conventions and geometry parameter in https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#required-attributes-for-each-mesh-record

Given that some pieces are still "reserved" my suggestion is to keep x,y,z for Cartesian, default to x1,x2,x3 for non-Cartesian with a warning that the output metadata is currently non-standard compliant and that people wanting to use it in production should get in touch to discuss next steps/a proper implementation.

@pdmullen pdmullen changed the title Towards Curvilinear Swarms WIP: Towards Curvilinear Swarms Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants