Add support for uint64 swarm vars and add default ids#1253
Conversation
I don't think it hurts much, but may be hard to interpret in some cases, e.g., what about Monte Carlo packets, where many may be created and destroyed over the course of a simulation? Peristent IDs for these may be a pain. I say it's fine to always make them exist by default, but I would want some warning labels in the docs/comments. Others should chime in. @pdmullen?
The field can be named whatever we like so long as the XML calls it |
Yurlungur
left a comment
There was a problem hiding this comment.
LGTM. Though we may want to keep the ability to automatically set the IDs to the global ID in output somehow?
I'd echo @Yurlungur's thoughts. For Monte Carlo, we are constantly destroying and creating new particles... The gears are still spinning in my head re: if there are any edge cases where the current changeset leads to issues given the above. Meanwhile, I'd also like to test this changeset against our downstream code Also, XDMF outputs do now work for swarms... I added this functionality when We might want to change occurences of "id" to |
They do??? What was I doing wrong before? Have you tried this with both visit and paraview? |
#1079 |
I completely forgot about this lol. Thanks again for finding the magic incantation that worked. |
|
Alright, following the discussion I made some updates to the PR.
|
| // TODO(reviewers) Why are do we forcibly disallow writing particle xdmf for | ||
| // restarts? | ||
| op.write_swarm_xdmf = | ||
| (restart) ? false |
There was a problem hiding this comment.
Any reason for doing this? I'd like to be able to generate particle xdmf for restart outputs (as those are sometime the only type I write).
There was a problem hiding this comment.
@pdmullen ? My guess is it's fine to write particle xdmf for restarts but that since it's an extra file it's just a lot of output?
There was a problem hiding this comment.
You have my blessing.
If I had to guess (it has been a while...), I disabled this because I wanted the imprint of my swarm XDMF MR to be minimal since it requires a bunch of ugly geometry writes. That code is so ugly (but the only path I could find to make VisIt happy...)
There was a problem hiding this comment.
I was not suggesting to enable it by default I was suggest to allow enabling it.
Right now the write_swarm_xdmf parameter is ignored for restart outputs (i.e., it's impossible to write particle xdmf for restart files.
|
@mfournier01 discovered and correctly isolated a casting issue for the uint64 type (as we're always communicating packed With the latest commit I now use a @pdmullen were you able to test downstream and/or are there any other changes required? |
Thanks for the bug fix (i.e., thanks @mfournier01 !) @pgrete, I'll have an answer for you re: downstream by no later than tomorrow COB. |
Sorry for the delay on this... something pertinent came up. |
| general. Therefore, if swarms do not automatically contain a unique ID swarm | ||
| variable (because the ``Metadata::NoPersistentParticleIds`` has been passed when | ||
| creating the swarm), Parthenon will generate an ``id`` variable just for output | ||
| (i.e., it is still not available within the simulation itself) and write it to file. |
There was a problem hiding this comment.
Does the use still have to request that id be output?
| std::string swarm_name = "tracers"; | ||
| Metadata swarm_metadata({Metadata::Provides, Metadata::None}); | ||
| Metadata swarm_metadata( | ||
| {Metadata::Provides, Metadata::None, Metadata::NoPersistentParticleIds}); |
There was a problem hiding this comment.
Why is the id field being removed here when previously the example explicitly created an id field?
There was a problem hiding this comment.
I made this change to test the Metadata::NoPersistentParticleIds feature.
The particle_tracer regression test results in particles being in the same order, i.e., the automatically generated ids match, and it also tests accessing "id" via that string rather than swarm.id.
Given that this might be confusing I now added comments both here and in the test.
| // Always output id, x, y, and z for swarms so that they work with vis tools. | ||
| // Note, it's fine to add the id by default (even though it might not actually | ||
| // exist) because only variables that do exists are actually being written. | ||
| std::vector<std::string> coords = { | ||
| swarm_position::id::name(), swarm_position::x::name(), | ||
| swarm_position::y::name(), swarm_position::z::name()}; |
There was a problem hiding this comment.
This looks like it answers my question above.
* Add support for uint64 swarm vars and enforce ids * Provide known name for id field in xdmf. Always write ids * Allow disabling unique ids for particles (old default behavior) * Update Changelog * Fix doc format * Allow writing of swarm xdmf for rst outputs * Fix unsafe/errornous casting * Add comment on use of nonpersistnet ids in traces
* start * seemingly works * format * remove intermediate prints * print some solutions * small * remove comments * Increase MPI timeout counter by 10x (#1243) * cleanup output and add option of outputting a specific stage * docs * changelog and formatting * oops swarms are only in Base * formatting * lukes nicer cleanup * add compute asymmetry script * Add shebang to movie2d * document how to change output cadence from restart * changelog * CC * CC * add discussion of SMR to AMR doc * changelog * typo thanks patrick * Try to move all LogicalLocation related logic to class methods * fix bugs * make sure colorbar label generated * add resport_asymmetry * Update doc/sphinx/src/outputs.rst Co-authored-by: Philipp Grete <pgrete@hs.uni-hamburg.de> * Update doc/sphinx/src/outputs.rst Co-authored-by: Philipp Grete <pgrete@hs.uni-hamburg.de> * Add checks for `parthenon/mesh/multigrid = true` when using multigrid block lists (#1241) * add checks and move things to being private * changelog * [Bugfix]: Propagate flux `Metadata` correctly in `SparsePool` (#1249) * propagate flux metadata correctly in SparsePool * changelog * [Trivial] Fix leftover reference to old coords interface (#1251) * Fix leftover reference to old coords interface * Fix doc formatting * Release 25.05 (#1252) * Release 25.05 * Update CHANGELOG.md * Add support for uint64 swarm vars and add default ids (#1253) * Add support for uint64 swarm vars and enforce ids * Provide known name for id field in xdmf. Always write ids * Allow disabling unique ids for particles (old default behavior) * Update Changelog * Fix doc format * Allow writing of swarm xdmf for rst outputs * Fix unsafe/errornous casting * Add comment on use of nonpersistnet ids in traces * New CUDA CI+development Docker container (#1162) * update CI Docker container Update to CUDA 12.6, Ubuntu 24.04, and Clang 19. * update OpenMPI * revert to OpenMPI 4.1.4 * add ADIOS2+openPMD * add c-blosc ubuntu package * fix Dockerfile.nvcc * fix dockerfile * install python headers * install cmake from apt (required for aarch64) * remove duplicate cmake dep * disable ascent build * add newer ascent version * disable ascent build; fix openpmd build * downgrade to CUDA 12.0 * fix ascent build path * fix bug in build_ascent.sh * remove unneeded patches * ascent complains if MFEM is not built * control cuda support for ascent with env var * add MAKEOPTS=--output-sync=target * add comment to Dockerfile * Downgrade numpy * Fix ADIOS2 and OpenPMD versions * Directly use Ascent script with small patch * Use Cuda12.1 container and drop to local user * add emacs and vi * set build_jobs=`nproc` to avoid OOM kill * add developer tools for Codespaces/VSCode * add devcontainer.json * update to CUDA 12.8 and VTK-m 2.3 * update image ref * fetch BLT * extract BLT into correct dir * avoid uid 1000 * build and publish Docker image based on Dockerfiles in repo * Update CI image to be used * Fix python version used for linting * Bump opmd to stable release * Add changelog * Use updated clang for compiler check * remove docker-publish action * Fix C++20 build * Attempt to fix Parthenon Ascent dep * Try Ben's BLT build fix * Fix Ascent build * Include opmd in rocm image * Use actual image --------- Co-authored-by: Philipp Grete <pgrete@hs.uni-hamburg.de> * Fix -m (#1257) * Exit cleanly if -m is set after Mesh is constructed but before initialize * Update CHANGELOG.md * remove kokkos warning * add core dump output format * check that only one core dump file is requested * changelog * update docs and delete accidentally added files * output postfix -> .chdf * make sure to slurp in fluxes * add a 5 * CC * more CC * example CC * comment that ghost zones exist * seemingly working timeout capability * seemingly working * add timing option * format * changelog * Remove old receive try test * remove comm buffer hang check * use task collection for internal mesh communication * Add timeout parameter to doc * format * Update src/mesh/mesh.cpp * Update src/tasks/tasks.hpp * Fix auto-docs and typo * respond to Philipp's comments * check the task collection return status --------- Co-authored-by: Philipp Grete <pgrete@hs.uni-hamburg.de> Co-authored-by: Jonah Miller <jonahm@lanl.gov> Co-authored-by: Jonah Miller <jonah.maxwell.miller@gmail.com> Co-authored-by: Ben Wibking <ben@wibking.com> Co-authored-by: Adam M. Dempsey <adempsey@lanl.gov>
PR Summary
What it says on the tin.
I was about to add some logic to enforce globally unique ids (which can be added dynamically) based on MPI logic and then thought about a simpler way(which kind of requires a larger pool of numbers, i.e., uint64_t without being too restrictive.
Thus, I added support for that data type first.
When we add another data type to particles, we probably want to start working with additional template magic as I was touching way more code than anticipated.
As it stands right now, the new
swarm.idfield is added by default for all Swarms.Is this what we want? I kind of lean towards it as it adds little overhead and potentially solves some hassle down the road.
UPDATE: Seems that we want it. The old behavior (i.e., no
idfield) be recovered by adding a swarm with theMetadata::NoPersistentParticleIdsflagAnother item, I'm currently unsure about is the
idfield for postprocessing tools (like visit or Paraview).Do those tools require a field named
id(rather thanswarm.idor sth else)? We could add an override to the xdmf output.UPDATE: A default "id" field (with this exact name) is now always added to the xdmf file either pointing to the real unique ids or some automatically generated field (only existing in the output) as before
Last big question: What do we do about backwards compatibility? I imagine this could get a little bit ugly given that the underlying datatype changed.
UPDATE: Should not be an issue any more by adding
Metadata::NoPersistentParticleIdsto the swarm.Anything else I missed?
Breaking Changes
A unique particle id field is added by default to each swarm.
If this is not desired (and to recover the old behavior), the field can be disabled by passing the
Metadata::NoPersistentParticleIdsflag.PR Checklist