-
Notifications
You must be signed in to change notification settings - Fork 16
Fix conservation of split divergence #2432
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
Conversation
2531bcc to
fe36c79
Compare
| u -> Geometry.contravariant1(u, local_geometry), | ||
| get_node(space, arg1, ij, slabidx), | ||
| ) | ||
| psi[slab_index(i)] = get_node(space, arg2, ij, slabidx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: I find these 6 lines harder to read than the pattern it replaces. What's the advantage of writing it this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I did this was to enforce consistency with the rest of the code in this file, so future PRs that refactor RecursiveApply and DataLayouts will not be behavior changing. But I totally agree that this is harder to read and needs to be refactored soon.
The RecursiveApply functions in this file allow iteration over multiple mass fluxes and/or multiple scalar quantities within the same fused operation. I'm working on removing the RecursiveApply module entirely from ClimaCore while maintining this behavior in #2417, which should eliminate most of the complexity introduced here.
As for the convoluted indexing required by DataLayouts, I'm honestly not sure why that is used throughout this file. The original intent of DataLayouts was to rearrange values in global memory so that L1/L2 caching could be improved, but it's not clear to me how this is useful for MArrays that are already cached in register memory. I will explore this more carefully in a future PR that refactors the DataLayouts module. If I don't end up finding any benefit to wrapping register caches in IF and IJF DataLayouts, I will remove these wrappers from psi, out, and all other register caches in ClimaCore.
|
@dennisYatunin Is there anything in the way of merging this? (Aside from making sure it passes unit tests.) |
fe36c79 to
9ad3aab
Compare
9ad3aab to
a50be8a
Compare
|
No, I just needed to update the CUDA extension code. Hopefully the unit tests pass now. |
This PR updates the
SplitDivergenceoperator to make it discretely conservative for discontinuous fields. The current version is already conservative for fields that have been DSSed, but it includes additional terms at element boundaries that violate conservation for discontinuous quantities (e.g., velocities reconstructions on a cubed sphere).The first commit in this PR removes the erroneous terms at element boundaries and updates the unit tests to demonstrate improved conservation properties. The unit tests are also simplified to avoid unnecessary checks and repetitive code.
The second commit in this PR makes the implementation of
SplitDivergencemore similar to the other spectral operators, ensuring correct use ofRecursiveApplyand consistent caching/indexing. Although this makes the code somewhat harder to read, it should simplify the process of removingRecursiveApplyin #2417, with identical changes required forSplitDivergenceand other spectral operators. (The convoluted cache indexing will also be removed from all operators in a future PR.) In addition, the docstring forSplitDivergenceis updated to improve formatting and correct errors.TODO: Update
SplitDivergencein CUDA extension.