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

Function interface for extracting properties from models #2156

Closed
glwagner opened this issue Jan 19, 2022 · 3 comments
Closed

Function interface for extracting properties from models #2156

glwagner opened this issue Jan 19, 2022 · 3 comments

Comments

@glwagner
Copy link
Member

An important missing component of our user interface is a function-based API for extracting properties from models. For example, we often write

u, v, w = model.velocities

when we really should write something like

u, v, w = velocity_field(model)

A major advantage of a function-based interface is that it is more robust to changes to the underlying model implementation. For example, we will eventually need a VectorField implementation for velocities (eg for the cubed sphere, or non-orthogonal grids). We'll be sorry that we've written u, v, w = model.velocities everywhere when we need to change model.velocities to model.velocity_field. But with a function-based interface we only have to change velocity_field(model) = model.velocities to velocity_field(model) = model.velocity_field.

A few other functions besides velocity_field that we might want are

  • tracers(model)
  • free_surface_displacement(model)
  • kinematic_pressure(model)
  • buoyancy(model)

viscosity(model) and diffusivities(model) might be nice too. One challenge there is figuring out what to do when the viscosity or diffusivities are really tensors rather than scalars (eg we need VectorField but we also may need TensorField...)

@glwagner glwagner changed the title Function interface for extracting properties from HydrostaticFreeSurfaceModel and NonhydrostaticModel Function interface for extracting properties from models Jan 19, 2022
@francispoulin
Copy link
Collaborator

Great idea, but I admit I have no idea how much work this is going to be.

One minor comment is that if we don't have the word field for the 4 other fields, maybe we would just want velocity instead of velocity_field?

@glwagner
Copy link
Member Author

It's very little coding work! Most of the work is designing the interface.

That's true we don't use tracer_fields...

@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
Projects
None yet
Development

No branches or pull requests

2 participants