-
Notifications
You must be signed in to change notification settings - Fork 9
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
Guarantee uniqueness of topologies and spaces #1120
Comments
One place where this could cause problems is when we extract levels or columns of extruded spaces. Will need to think about it. |
After a bit more thought, I think the solution is:
|
There is an important design choice on how to handle staggered grids. Currently we have a field So some possible ways to do this:
|
One advantage of option 2 is that it may make some aspects of the ClimaAtmos setup easier: cc @Sbozzolo |
Maybe this is a silly question, but is it really a significant risk to simply remove if space1 !== space2
error_mismatched_spaces(typeof(space1), typeof(space2))
end and let broadcasting over spaces be "unsafe"? I would prefer option 2, though. |
I'd note that the motivation for option 3 is that this corresponds to how people typically communicate about staggered grids; ie there is a single primal grid or space (the tracer / fully centered grid), and the "other grids" that are staggered with respect to the tracer grid are (somehow, implicitly) diagnostic to that grid. How is option 2 functionally different from 3? What else would the distinction between the two spaces be used for other than constructing fields? |
I don't follow the nuances, but a comment against 2. is that there's already a tower of types needed to define something that is directly useful to the end user ( |
@charleskawczynski there are two problems we're trying to solve:
|
I'd prefer option 2 over 1, just for symmetry sake. There's nothing special about center vs face grids, and as Greg was saying, one is a sort of dual grid to the other. Also, I'm not a fan of 3-- I like that fields just have values and a space. |
They're basically the same, but 3 would require larger interface changes (probably breaking) as they would modify how Fields work. That might be worthwhile though? |
That's a reasonable point. I was hoping to find an object that would allow us to avoid creating a wrapper object. |
One other option that avoids additional wrapper types/levels in the hierarchy is
I just found out while working on #1445 that |
@dennisYatunin the challenge is how to link the two, which we need for operators so what we know that the gradient of a field on a |
Is your feature request related to a problem? Please describe.
It's very easy to get the mismatched spaces warning, especially when loading data from multiple files. It will also become an issue
Related issues
Describe the solution you'd like
The basic idea would be to keep track of existing objects (spaces and below) in some sort of internal cache: if a constructor is called with the same arguments, we instead use the cached object.
The major challenge would be making sure that objects get GCed even if they're not referenced anywhere outside the cache. Julia provides
WeakRef
s for this purpose. See alsoWeakKeyDict
(unfortunately we can't use aWeakKeyDict
directly, as not all our objects are mutable).We may want to change some objects to be
mutable struct
s as that may make the table lookup easier.Describe alternatives you've considered
The alternative is to allow more operations on duplicate objects, but this will be less efficient in terms of memory usage (as we will end up with duplicate objects) and performance (as we will need to spend more time checking objects are actually the same).
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: