Skip to content

Fix velocity exchanges across tripolar seam #4487

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

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

Conversation

NoraLoose
Copy link
Collaborator

As @simone-silvestri noted in this comment, the streamfunction used to initialize the velocity field in our tracer conservation test on the tripolar grid had an incorrect magnitude, resulting in initial velocities on the order of 10⁻⁶ m/s. This PR corrects the streamfunction so that initial velocities are O(1) m/s.

With non-negligible initial velocities, tracer conservation breaks down, see failing test " TripolarGrid ZStar tracer conservation tests".

@NoraLoose
Copy link
Collaborator Author

Here is a visualization for how tracer conservation is broken in the modified test.
Screenshot 2025-05-08 at 10 45 00 AM

@NoraLoose
Copy link
Collaborator Author

@navidcy Just a heads-up — we probably don’t want to merge this PR yet. The TripolarGrid ZStar tracer conservation tests are currently failing, because this PR modifies the test in a way so that it exposes a deeper underlying issue. We're tracking that underlying issue in #4488. Probably best to resolve the underlying issue first before proceeding with this merge.

@NoraLoose NoraLoose added the 🚨 DO NOT MERGE 🚨 IN BIG BOLD RED CAPS WITH FLASHING SIRENS label May 8, 2025
@glwagner
Copy link
Member

glwagner commented May 8, 2025

We can merge if we get the tests to pass though right??

@NoraLoose
Copy link
Collaborator Author

We can merge if we get the tests to pass though right??

Yes, I just put that label there because @navidcy already approved the PR! Feel free to remove it.

@glwagner
Copy link
Member

glwagner commented May 8, 2025

For us "approve" means (good to merge IF tests pass) but we are maybe a little loose sometimes 😂

@NoraLoose NoraLoose removed the 🚨 DO NOT MERGE 🚨 IN BIG BOLD RED CAPS WITH FLASHING SIRENS label May 8, 2025
@NoraLoose NoraLoose changed the title Increase amplitude of streamfunction in conservation test Fix velocity exchanges across tripolar seam May 8, 2025
@navidcy
Copy link
Member

navidcy commented May 9, 2025

Indeed, my approval was on the basis that tests pass.
I added a small suggestion but feel free to ignore if; up to you.

@@ -93,7 +93,6 @@ end
end
end

@inbounds v[i, Ny, k] = ifelse(i > Nx ÷ 2, sign * v[i′, Ny + 1, k], v[i, Ny, k])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@simone-silvestri I think we need this line. Did you remove it on purpose?

Copy link
Collaborator

@simone-silvestri simone-silvestri May 9, 2025

Choose a reason for hiding this comment

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

Yes, why do we need this line? The v velocity is not duplicated across the seam as the tracer and u-velocity is

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're probably right — I think I was just confused.

Since we call

_fill_north_halo!(i, k, grid, v, bc::ZBC, ::CFLocation, args...) = fold_north_center_face!(i, k, grid, bc.condition, v)

across the full range of i (not just the first or second half of the i-range), the line that you removed was redundant. All good.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand. @NoraLoose's sketch showed that v is duplicated. What is the additional information that negates it?

Copy link
Member

Choose a reason for hiding this comment

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

Or ok, the point is actually that the right side of the seam is the prognostic field, and on the left side the cells at Ny+1 are not evolved. So therefore we have the opposite rule for v than for other fields, and we should be filling in the reverse direction (eg putting interior values from the right of the seam onto the left boundary).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or ok, the point is actually that the right side of the seam is the prognostic field, and on the left side the cells at Ny+1 are not evolved.

Why are the cells at Ny+1 on the left side not evolved? They are responsible for advecting tracers correctly into the row tracer[1:half_point, Nx], correct? Or are we overwriting these tracer values on the left side anyway? Looking at this line, I think we are overwriting the tracer values on the right side, not on the left side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh "evolved", not "involved"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So therefore we have the opposite rule for v than for other fields, and we should be filling in the reverse direction (eg putting interior values from the right of the seam onto the left boundary).

I think we are always taking values from the ride side, and copying them over to the left side (possibly with a sign change).

Copy link
Member

Choose a reason for hiding this comment

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

Basically, we compute tendencies only up to Ny, so the Ny+1 must be determined by filling halos

Co-authored-by: Navid C. Constantinou <[email protected]>
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.

4 participants