Skip to content

Commit

Permalink
(0.94.2) Support interpolation from triple-Flat grids (#3928)
Browse files Browse the repository at this point in the history
* Simplify interpolation for triply-flat grids

* Generalize flatten_node

* Bump version
  • Loading branch information
glwagner authored Nov 15, 2024
1 parent cb9e6d2 commit 6a95ceb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Oceananigans"
uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
authors = ["Climate Modeling Alliance and contributors"]
version = "0.94.1"
version = "0.94.2"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
6 changes: 6 additions & 0 deletions src/Fields/interpolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ end
@inline flatten_node(x, ::Nothing, z) = flatten_node(x, z)
@inline flatten_node(x, y, ::Nothing) = flatten_node(x, y)

@inline flatten_node(x, ::Nothing, ::Nothing) = tuple(x)
@inline flatten_node(::Nothing, y, ::Nothing) = tuple(y)
@inline flatten_node(::Nothing, ::Nothing, z) = tuple(z)

@inline flatten_node(::Nothing, ::Nothing, ::Nothing) = tuple()

@inline flatten_node(x, y) = (x, y)
@inline flatten_node(::Nothing, y) = flatten_node(y)
@inline flatten_node(x, ::Nothing) = flatten_node(x)
Expand Down
18 changes: 11 additions & 7 deletions src/OutputReaders/field_time_series_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,17 @@ end

to_time = to_time_index.time

# Build space interpolators
to_node = flatten_node(to_node...)
ii, jj, kk = fractional_indices(to_node, from_grid, from_loc...)

ix = interpolator(ii)
iy = interpolator(jj)
iz = interpolator(kk)
if topology(from_grid) === (Flat, Flat, Flat)
ix = iy = iz = (1, 1, 0)
else
# Build space interpolators
to_node = flatten_node(to_node...)
ii, jj, kk = fractional_indices(to_node, from_grid, from_loc...)

ix = interpolator(ii)
iy = interpolator(jj)
iz = interpolator(kk)
end

ñ, n₁, n₂ = interpolating_time_indices(time_indexing, times, to_time)

Expand Down

2 comments on commit 6a95ceb

@glwagner
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/119512

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.94.2 -m "<description of version>" 6a95cebcfd9493ecaeb783c19ca0f599c0299511
git push origin v0.94.2

Please sign in to comment.