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

Convenience constructors for 1 and 2D grids? #2292

Closed
glwagner opened this issue Mar 1, 2022 · 3 comments
Closed

Convenience constructors for 1 and 2D grids? #2292

glwagner opened this issue Mar 1, 2022 · 3 comments
Labels
good first issue 🐤 Let us know if you're interested in working on this! user interface/experience 💻

Comments

@glwagner
Copy link
Member

glwagner commented Mar 1, 2022

Some time ago I told @simone-silvestri I wanted to show a "simple 2D example" in a tutorial, to which he responded

It's actually harder to construct a 2D grid than a 3D grid

@simone-silvestri's point, I think, is that to reduce the dimension of a grid we have to pass topology with Flat elements. It's easier to construct a grid with the default topology (Periodic, Periodic, Bounded).

This has been haunting me ever since. I think one way we can solve this issue is to introduce convenience constructors like

grid = ZRectilinearGrid(size=16, z=(0, 1), topology=Bounded)
grid = XYRectilinearGrid(size=(64, 64), x=(0, 1), y=(0, 1), topology=(Periodic, Periodic))

These are relatively simple to implement since they're one-liners:

XYRectilinearGrid(args...; topology=(Periodic, Periodic), kw...) = XYRectilinearGrid(args...; kw..., topology=tuple(topology[1:2]..., Flat))

et cetera. We can also define the appropriate type aliases:

const XYRectilinearGrid{FT, TX, TY} = RectilinearGrid{FT, TX, TY, Flat} where {FT, TX, TY}

and change show (if we desire).

Is this friendly / a good idea?

@glwagner glwagner changed the title Convenience constructors for 1 and 2D cases? Convenience constructors for 1 and 2D grids? Mar 1, 2022
@glwagner glwagner added the good first issue 🐤 Let us know if you're interested in working on this! label Mar 1, 2022
@simone-silvestri
Copy link
Collaborator

simone-silvestri commented Mar 1, 2022

I Think it is a good idea.

While we are at it, we can also introduce Flat directions for a the LatitudeLongitudeGrid

@francispoulin
Copy link
Collaborator

This is intuitive and a good idea moving forward. I like it!

@glwagner
Copy link
Member Author

I'm closing this issue because I'm judging that it's not of current, timely relevance to Oceananigans development. If you would like to make it a higher priority or if you think the issue was closed in error please feel free to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue 🐤 Let us know if you're interested in working on this! user interface/experience 💻
Projects
None yet
Development

No branches or pull requests

3 participants