Skip to content

(0.105.3) Fix interpolation of terms in chain horizontal derivatives for MutableVerticalDiscretization#5339

Merged
glwagner merged 4 commits intomainfrom
glw/fix-chain-rule
Mar 4, 2026
Merged

(0.105.3) Fix interpolation of terms in chain horizontal derivatives for MutableVerticalDiscretization#5339
glwagner merged 4 commits intomainfrom
glw/fix-chain-rule

Conversation

@glwagner
Copy link
Copy Markdown
Member

@glwagner glwagner commented Feb 26, 2026

Found by @briochemc, cc @simone-silvestri

discussion: #5101 (comment)

@glwagner
Copy link
Copy Markdown
Member Author

Are there regression tests for ZStarCoordinate? I am worried this issue affects the fidelity of zstar.

@briochemc
Copy link
Copy Markdown
Collaborator

Question relating to this PR as I am wondering if the misalignment happens elsewhere: Should there be a dispatch for operators such that if the argument is in the wrong location it throws?

Copy link
Copy Markdown
Collaborator

@briochemc briochemc left a comment

Choose a reason for hiding this comment

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

Staggering looks good to me!

@glwagner
Copy link
Copy Markdown
Member Author

glwagner commented Feb 27, 2026

Question relating to this PR as I am wondering if the misalignment happens elsewhere: Should there be a dispatch for operators such that if the argument is in the wrong location it throws?

Hmm. We could implement that. However, it would only throw an error on CPU beacuse on GPU, Field is adapted to Field.data. But as I write this, I think that your idea will still work because we would still get that error in tests, which is sufficient to prevent it. This would be a pretty simple PR (the code could be generated with metaprogramming). I think this is actually a great idea; we can't automatically infer which operator to use, but we can throw an error if the wrong operator is used on CPU and this effectively achieves the same thing!

@simone-silvestri
Copy link
Copy Markdown
Collaborator

Are there regression tests for ZStarCoordinate? I am worried this issue affects the fidelity of zstar.

There are tests for the conservation of tracers in z star and the fidelity of the implicit solve.

@glwagner
Copy link
Copy Markdown
Member Author

glwagner commented Mar 2, 2026

Are there regression tests for ZStarCoordinate? I am worried this issue affects the fidelity of zstar.

There are tests for the conservation of tracers in z star and the fidelity of the implicit solve.

Interesting. I think this change concerns whether the pressure gradient is correct. We may not be testing it.

@glwagner
Copy link
Copy Markdown
Member Author

glwagner commented Mar 2, 2026

I think we should merge this asap

@simone-silvestri
Copy link
Copy Markdown
Collaborator

simone-silvestri commented Mar 2, 2026

I am a bit afraid of the possible loss of performance, but ok let's merge it and keep it in mind

@simone-silvestri
Copy link
Copy Markdown
Collaborator

simone-silvestri commented Mar 2, 2026

maybe we can add a zstar option in the benchmarks PR, if we see there is a very large difference between zstar and static coordinate we can worry otherwise there is no issue.

@simone-silvestri
Copy link
Copy Markdown
Collaborator

We should also have immersed-boundary-aware interpolations for this derivative to be actually correct across immersed boundaries

@glwagner
Copy link
Copy Markdown
Member Author

glwagner commented Mar 3, 2026

We should also have immersed-boundary-aware interpolations for this derivative to be actually correct across immersed boundaries

should we do that in this PR?

@glwagner
Copy link
Copy Markdown
Member Author

glwagner commented Mar 3, 2026

I am a bit afraid of the possible loss of performance, but ok let's merge it and keep it in mind

we can add the pressure gradient calculation based on buoyancy back if needed. There is a trade-off; one is a derivative but the other requires evaluating TEOS10?

@glwagner
Copy link
Copy Markdown
Member Author

glwagner commented Mar 4, 2026

are the failing tests related? should we merge this?

@simone-silvestri
Copy link
Copy Markdown
Collaborator

They do not seem to be related. I think we can merge this. Distributed tests are acting up a bit

@glwagner glwagner changed the title Fix interpolation of terms in chain horizontal derivatives for MutableVerticalDiscretization (0.105.3) Fix interpolation of terms in chain horizontal derivatives for MutableVerticalDiscretization Mar 4, 2026
@glwagner glwagner merged commit 9d1b456 into main Mar 4, 2026
74 of 77 checks passed
@glwagner glwagner deleted the glw/fix-chain-rule branch March 4, 2026 23:30
briochemc added a commit to briochemc/Oceananigans.jl that referenced this pull request Mar 5, 2026
* glw/prescribed-free-surface:
  (0.105.3) Fix interpolation of terms in chain horizontal derivatives for MutableVerticalDiscretization (CliMA#5339)
  Fix ContinuousForcing field index mismatch in HydrostaticFreeSurfaceModel (CliMA#5370)
  Add dependency guardrail to Common Pitfalls (CliMA#5371)
  Fix typo SKR3 -> SRK3 (CliMA#5360)
  Add new reference to Zheng et al. (2025) in index (CliMA#5364)
  Add 9 missing papers to the reference list (CliMA#5363)
  Update papers section in index.md (CliMA#5362)
  Restructure AGENTS.md into multi-file agent configuration (CliMA#5350)
  (0.105.2) Fix `with_halo` for a `TripolarGrid` (CliMA#5353)
  (0.105.2) Fix and test checkpointing with open-domain simulations with a radiation `OpenBoundaryCondition` (CliMA#5347)
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.

3 participants