-
Notifications
You must be signed in to change notification settings - Fork 168
Structured grids barycentric coordinates #2037
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
8966dd3 to
85b0d10
Compare
|
@erikvansebille I'm not sure what the code at da87f9b does (in particular the Also insight on Happy to discuss irl, and will update here accordingly. |
|
@fluidnumerics-joe getting some failing tests now with This error makes sense, the current implementation is: ...
da = xr.DataArray(
data=np.full((1, 1, 1, 1), value),
dims=["time", "ZG", "YG", "XG"],
coords={
"ZG": (["ZG"], np.arange(1), {"axis": "Z"}),
"YG": (["YG"], np.arange(1), {"axis": "Y"}),
"XG": (["XG"], np.arange(1), {"axis": "X"}),
"lon": (["XG"], np.arange(1), {"axis": "X"}),
"lat": (["YG"], np.arange(1), {"axis": "Y"}),
"depth": (["ZG"], np.arange(1), {"axis": "Z"}),
"time": (["time"], np.arange(1), {"axis": "T"}),
},
)
breakpoint()
grid = XGrid(xgcm.Grid(da))
...Basically making a 1 point structured grid and then going forward with that. I think this implementation should change (it doesn't make sense for a constant field to have its own grid, especially now since grids now have the concepts of searching, raveling, and "out of bounds"). Not sure exactly how yet, having a think... |
|
@VeckoTheGecko - at a minimum, a single point grid would be a single tracer point, which would give 4 vorticity points that form the boundary of the tracer cell. If you have only one vorticity point, there are no tracer cells. |
Yes, that would get past the initialiser - but would fail on eval due to the index searching etc.. I'm also thinking about futureproofing (does this mean for a constant Field that an extra ei for each particle causing a |
I don't understand why it fails on index searching. An Arakawa-C grid is not completely defined in the example you've provided with just an |
Not sure if this is super-pertinent to this discussion, but note that in Parcels v3, we use 'one-dimensional fields' to represent e.g. horizontally uniform diffusivity or variables that would only depend on depth. See for an example e.g. It's quite useful (albeit a bit hacky?) to keep support for these one-dimensional fields? |
|
@fluidnumerics-joe full traceback Details
|
7cc9e02 to
3f453b3
Compare
|
Let's postpone this a couple days.... Working on a proposal that affects this |
78edab5 to
ef33429
Compare
|
I've just rebased this and updated the API to line up with #2048 - ready for review. |
Resolved with #2058 - all v4 tests are passing in that PR |
ef33429 to
de0a616
Compare
| yi -= 1 | ||
| elif eta > 1 + tol: | ||
| yi += 1 | ||
| (yi, xi) = _reconnect_bnd_indices(yi, xi, grid.ydim, grid.xdim, grid.mesh) |
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.
Is this needed if we don't do periodic grids anymore?
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.
I was wondering if this wasn't for periodic grids, but instead was to do with tripolar grids - would that make sense? I thought the edges/wrapping in that grid would result in the index search needing to be "reconnected" to the grid like this.
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.
Yes, you may indeed be right. Let's leave in for now and we can see whether this is still necessary when we test curvilinear NEMO grid in the Arctic
|
Just implemented the review changes. Still a couple pending items above that we didn't discuss during our meeting @erikvansebille - after that I think we're good to merge. |
|
Good to merge, as far as I'm concerned |
v4-devfor v4 changes)Changes:
Here is a diagram to help visualise what's happening here:
Diagram on NEMO/MITgcm indexing in general
Note that result from the
search()method is wrt. the red points (i.e.,yi, xi = 0, 0,eta, xsi = 0.5, 0.5means the particle is in the cell centre with lower left being red point at(0, 0).One thing to note: Particles on the edge of the model grid are not representable in the F-points (in the diagram, this is evident in the NEMO model for the lower left edge of the grid). In the periodic case, the grid has a halo anyway so this is a non-issue. The grid is not patched to be a "full grid" on initialisation - we instead work close to the original dataset.
If we have a particle in tracer cell
(yi, xi) = 0,0, then the relevant velocities for interpolation are:U[y, x] -> U[1,0] and U[1,1]V[y, x] -> V[0,1] and V[1,1]U[y, x] -> U[0,0] and U[0,1]V[y, x] -> V[0,0] and V[1,0]The lining up of these indices with on-disk representation will be handled in the interpolator itself (in a future PR).