Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[breaking] output more topological elements #1019

Merged
merged 67 commits into from
Apr 3, 2024
Merged

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented Mar 11, 2024

PR Summary

What it says on the can

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
  • (@lanl.gov employees) Update copyright on changed files

@Yurlungur Yurlungur requested a review from bprather March 11, 2024 22:21
@Yurlungur Yurlungur self-assigned this Mar 11, 2024
@bprather
Copy link
Collaborator

So many feature PRs with net negative lines! Approach looks great, can test/debug later this week. This is a super important piece of putting KHARMA back on Parthenon develop. I'll have another interesting little piece to push upstream in the next week too, and then I can stop frankenbranching! Exciting.

@Yurlungur
Copy link
Collaborator Author

I'm not done yet. This is currently just cleanup. But the feature will be in soon. Hopefully before you look. :)

Copy link
Collaborator

@pgrete pgrete left a comment

Choose a reason for hiding this comment

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

Just had quick look at the PR following our discussion on Thursday and it looks like a nice cleanup (though I didn't review the code in great detail yet).
Note, that I'm about to make the RestartReader a base class so that I can derive for hdf5 and OpenPMD.
Do you expect to touch the restart parts (beyond the removed legacy code)?

@Yurlungur
Copy link
Collaborator Author

Just had quick look at the PR following our discussion on Thursday and it looks like a nice cleanup (though I didn't review the code in great detail yet). Note, that I'm about to make the RestartReader a base class so that I can derive for hdf5 and OpenPMD. Do you expect to touch the restart parts (beyond the removed legacy code)?

I will need to touch the utility functions called by the restart reader, such as the pack/unpack variables. I will also need to change ReadBlocks in restart.hpp.

@pgrete
Copy link
Collaborator

pgrete commented Mar 18, 2024

Just had quick look at the PR following our discussion on Thursday and it looks like a nice cleanup (though I didn't review the code in great detail yet). Note, that I'm about to make the RestartReader a base class so that I can derive for hdf5 and OpenPMD. Do you expect to touch the restart parts (beyond the removed legacy code)?

I will need to touch the utility functions called by the restart reader, such as the pack/unpack variables. I will also need to change ReadBlocks in restart.hpp.

Right, but this is all going to be "internal" to restarting from hdf5, correct?
The OpenPMD logic will a little bit different, so I'm mostly interested if you expect changes to the interface that's being called (not what happens within the functions themselves).

@Yurlungur
Copy link
Collaborator Author

Just had quick look at the PR following our discussion on Thursday and it looks like a nice cleanup (though I didn't review the code in great detail yet). Note, that I'm about to make the RestartReader a base class so that I can derive for hdf5 and OpenPMD. Do you expect to touch the restart parts (beyond the removed legacy code)?

I will need to touch the utility functions called by the restart reader, such as the pack/unpack variables. I will also need to change ReadBlocks in restart.hpp.

Right, but this is all going to be "internal" to restarting from hdf5, correct? The OpenPMD logic will a little bit different, so I'm mostly interested if you expect changes to the interface that's being called (not what happens within the functions themselves).

Ah I see... I'm not sure. I was thinking of trying to loop the VarInfo through reading restarts too, to re-use that code... but it might be more trouble than it's worth.

@pgrete
Copy link
Collaborator

pgrete commented Mar 18, 2024

Just had quick look at the PR following our discussion on Thursday and it looks like a nice cleanup (though I didn't review the code in great detail yet). Note, that I'm about to make the RestartReader a base class so that I can derive for hdf5 and OpenPMD. Do you expect to touch the restart parts (beyond the removed legacy code)?

I will need to touch the utility functions called by the restart reader, such as the pack/unpack variables. I will also need to change ReadBlocks in restart.hpp.

Right, but this is all going to be "internal" to restarting from hdf5, correct? The OpenPMD logic will a little bit different, so I'm mostly interested if you expect changes to the interface that's being called (not what happens within the functions themselves).

Ah I see... I'm not sure. I was thinking of trying to loop the VarInfo through reading restarts too, to re-use that code... but it might be more trouble than it's worth.

Alright, as far as I can tell right now my refactor won't be that intrusive, so I'll just go ahead and then we can mix/match later (especially as I'll probably use more from the change you implement here than the other way around).

@Yurlungur Yurlungur changed the base branch from pgrete/refactor-restart to develop March 28, 2024 18:17
@Yurlungur Yurlungur changed the title output more topological elements [breaking] output more topological elements Mar 28, 2024
@Yurlungur
Copy link
Collaborator Author

OK this is now ready for merge after sufficient approval/testing. Plotted below is the z-component of the vector potential for a rotor problem.
0030

@Yurlungur
Copy link
Collaborator Author

@pgrete @bprather this is fully ready for merge with 1 more review.

@Yurlungur Yurlungur disabled auto-merge March 29, 2024 15:49
@Yurlungur Yurlungur mentioned this pull request Mar 29, 2024
12 tasks
Copy link
Collaborator

@pgrete pgrete left a comment

Choose a reason for hiding this comment

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

Quite a rabbit hole, which came out nicely clean wrt to the changes to the hdf5 piece alone.
I'm done with the code review (with a couple of minor comments), and will approve tomorrow once I confirmed things are working (particularly restarting version 3 outputs) in AthenaPK.

@@ -212,7 +217,7 @@ class ParticleVariable {

KOKKOS_FORCEINLINE_FUNCTION
auto GetDim(const int i) const {
PARTHENON_DEBUG_REQUIRE(0 < i && i <= 6, "ParArrayNDGenerics are max 6D");
PARTHENON_DEBUG_REQUIRE(0 < i && i <= 6, "Index out of bounds");
Copy link
Collaborator

Choose a reason for hiding this comment

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

But it's also std::array<int, MAX_VARIABLE_DIMENSION> dims_; below, isn't it?

Comment on lines 214 to 216
print("value error!", len(components), ntensors, q.shape)
raise ValueError(
"Tensor rank not the same as number of specified components"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for the separate preceding print statement rather than putting everything in the raised error message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The exceptions raised within a thread (since the code is thread-parallel) were not being propagated, so the script was just failing silently. This was my hacky way of dealing with it.

I just went back in and fixed it properly, by forcing python to raise exceptions.

Comment on lines +218 to +219
for c in components:
if c > (q.shape[1] - 1):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's exactly happening here (in combination with the q = q[:, c] below.
The for c in ... make me believe there's more than one component, but then it's checked against a fixed index in q.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the intent here is that q always has the shape [blocks, some number of tensor components, k, j, i] so q[1] is always the index of the slowest-moving tensor component. Then q = q[:,c] sets the slowest moving tensor-component to c but leaves the block index free floating. If you iterate with this, q keeps changing shape, so you can walk throw all tensor components, slowest first. I added a comment in the code to explain.

Comment on lines 108 to 109
If variable is a vector, each element of the returned numpy
array is a vector of that length.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm having trouble parsing that statement. Does "length" here refer to the flattened length, i.e. you get a 2D numpy array back with [c,TotalCells] with c being the vector.
In that case, how about moving this statement after the first sentence of the following paragraph as (so that there's an explanation for "length".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think I wrote this line. I just moved it/reformated it. I also don't understand what it means. I've deleted it and modified the passage below it to explain.

src/outputs/restart_hdf5.cpp Show resolved Hide resolved
src/parthenon_manager.cpp Show resolved Hide resolved
src/parthenon_manager.cpp Show resolved Hide resolved
tst/unit/test_output_utils.cpp Outdated Show resolved Hide resolved
tst/unit/test_output_utils.cpp Show resolved Hide resolved
Copy link
Collaborator

@pgrete pgrete left a comment

Choose a reason for hiding this comment

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

Thanks for the updates.
I also just verified that things work in AthenaPK.
Ready to merge!

@Yurlungur Yurlungur disabled auto-merge April 3, 2024 16:49
@Yurlungur Yurlungur enabled auto-merge April 3, 2024 16:49
@Yurlungur Yurlungur merged commit b9ed698 into develop Apr 3, 2024
49 checks passed
@Yurlungur Yurlungur deleted the jmm/output-nodes-2 branch April 3, 2024 22:03
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.

6 participants