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

PolarBoundaryCondition for tracer + views for AbstractOperations #3953

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

simone-silvestri
Copy link
Collaborator

@simone-silvestri simone-silvestri commented Nov 22, 2024

A FluxBoundaryCondition is not correct on a latitude-longitude grid that covers the whole earth, i.e. when latitude = (-90, 90).

The actual boundary condition (for tracers) should be a value boundary condition that holds the average of the last / first row.

Vectors are a little more complicated because we need to account for the frame of reference.
(We can probably do that in a new PR)

This is required mainly for input data define on a LatitudeLongitudeGrid that needs interpolation on full spherical grids for global ocean simulations.

As part of this PR, to allow reducing on the last / first row of the LatitudeLongitudeGrid I needed to implement reductions on windowed reduced fields, which required extending views for AbstractOperations

The implementation is not final since it does not account for the case of an array (non-field) being part of an AbstractOperation. But I guess we can tackle that case when we encounter it.

@simone-silvestri simone-silvestri changed the title PolarBoundaryCondition for LatitudeLongitudeGrids that reach the poles PolarBoundaryCondition for tracer Fields on LatitudeLongitudeGrids that reach the poles Nov 22, 2024

if φmin == - 90
_, LY, LZ = loc
field = Field{Nothing, LY, LZ}(grid; indices = (:, 1, :))
Copy link
Member

Choose a reason for hiding this comment

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

This does seem right

Copy link
Member

Choose a reason for hiding this comment

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

But should LY actually be flipped? Eg this is Face for a Center location. (It may not matter)

Copy link
Collaborator Author

@simone-silvestri simone-silvestri Nov 23, 2024

Choose a reason for hiding this comment

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

Probably you are right. I have found out unfortunately that reductions on windowed fields do not work. I ll try to make it work so here we can do

mean!(windowed_field, full_field)

@simone-silvestri simone-silvestri changed the title PolarBoundaryCondition for tracer Fields on LatitudeLongitudeGrids that reach the poles PolarBoundaryCondition for tracer + Reductions on reduced windowed field Nov 27, 2024
@simone-silvestri simone-silvestri changed the title PolarBoundaryCondition for tracer + Reductions on reduced windowed field PolarBoundaryCondition for tracer + views for AbstractOperations Nov 27, 2024
@simone-silvestri
Copy link
Collaborator Author

In the end, using fields in boundary conditions is a bit too complicated because fields are defined after boundary conditions making it a bit of a mess. For this reason, I just wrote a very simple averaging kernel in the polar boundary conditions file.

The improvements for reductions on windowed fields still stand though, so I have added some tests also to make sure that reductions on windowed fields work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants