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

Grid metrics and differences as AbstractOperations #1452

Closed
glwagner opened this issue Mar 10, 2021 · 2 comments · Fixed by #1607
Closed

Grid metrics and differences as AbstractOperations #1452

glwagner opened this issue Mar 10, 2021 · 2 comments · Fixed by #1607
Labels
feature 🌟 Something new and shiny

Comments

@glwagner
Copy link
Member

It might be useful if grid metrics and differences (δx) were provided as abstract operations. For example:

struct GridMetric{M, G} <: AbstractOperation
    metric :: M
    grid :: G
end

getindex(gm::GridMetric, i, j, k) = gm.metric(i, j, k, grid)

We can then define operations for grid spacings and area, which would mean, for example, that an operation computing vertical vorticity could be constructed via

Δyᶜᶠᵃ = GridMetric(Oceananigans.Operators.Δyᶜᶠᵃ, grid)
Δxᶠᶜᵃ = GridMetric(Oceananigans.Operators.Δyᶠᶜᵃ, grid)
Axᶠᶠᵃ = GridMetric(Oceananigans.Operators.Axᶠᶠᵃ, grid)

Γ = δx(Δyᶜᶠᵃ * v) - δy(Δxᶠᶜᵃ * u)
ζ = Γ / Axᶠᶠᵃ

For this we also need

struct Difference{D} <: AbstractOperation
    δ :: D
    grid :: G
end

similar to Derivative for partial derivatives with respect to x, y, z.

@ali-ramadhan
Copy link
Member

This would be pretty sweet!

Are you opening a "wishlist" issue because you think a current implementation would hit issue #1241?

@glwagner
Copy link
Member Author

glwagner commented Mar 11, 2021

I just wanted to write down the details of the idea while it was in my head!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🌟 Something new and shiny
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants