Subgrid diffusive fluxes for from closure for tracers#255
Conversation
|
Hey @tomchor -- Just a heads up that I will be on vacation and unresponsive for the next ~week, but I wanted to get out for review before I left. Thanks! |
That's alright, I'll also be out of office next week so that's pretty good timing lol I'll try to review it tomorrow. Thanks for the PR! |
| const DiffusiveFluxX = CustomKFO{<:typeof(diffusive_flux_x)} | ||
| const DiffusiveFluxY = CustomKFO{<:typeof(diffusive_flux_y)} | ||
| const DiffusiveFluxZ = CustomKFO{<:typeof(diffusive_flux_z)} |
There was a problem hiding this comment.
Can we name these to XDiffusiveFlux etc? It matches previous notation in the repo and it sounds more like how one would say these in plain english
There was a problem hiding this comment.
My rational for this naming convention was to match the diffusive_flux_* kernels from Oceananigans. If you still want it changed, I don't mind.
There was a problem hiding this comment.
I see your reasoning, but we made the decision a while ago to standard the user interfaces like this even though the underlying kernels might be different. For example:
Oceanostics.jl/src/TurbulentKineticEnergyEquation.jl
Lines 270 to 276 in c678675
| DIFF_FLUX = TracerEquation.DiffusiveFluxX(model, model.grid, model.closure, model.closure_fields, | ||
| Val(:a), model.tracers.a, model.clock, fields(model), model.buoyancy) |
There was a problem hiding this comment.
Can we align these? I think the suggestion below does it but it's kinda hard to tell on github
| DIFF_FLUX = TracerEquation.DiffusiveFluxX(model, model.grid, model.closure, model.closure_fields, | |
| Val(:a), model.tracers.a, model.clock, fields(model), model.buoyancy) | |
| DIFF_FLUX = TracerEquation.DiffusiveFluxX(model, model.grid, model.closure, model.closure_fields, | |
| Val(:a), model.tracers.a, model.clock, fields(model), model.buoyancy) |
There was a problem hiding this comment.
Happy to fix this as well, but wanted to check if you wanted all similar lines in this file changed similarly? It looks like the existing function calls are also indented like this.
There was a problem hiding this comment.
Yeah, usually we align all these lines to improve readability. I'm open to other ways of alignment as well, but I think before it wasn't aligned with anything
No problem at all! Happy to contribute! As for tests passing, just copying this here for myself: Probably a typo somewhere -- I will update you when I track it down : ) |
|
@jeremy-lilly if it's easier I can also add you to the repo. That way you can run the tests yourself online and don't have to be running them locally (I assumed that's what the last post was about?) |
There was a problem hiding this comment.
Pull request overview
This PR extends Oceanostics.TracerEquation with new diagnostic kernel-function operations for computing closure-determined subgrid diffusive tracer fluxes (diffusive_flux_x/y/z), and adds corresponding unit tests.
Changes:
- Add
DiffusiveFluxX,DiffusiveFluxY, andDiffusiveFluxZdiagnostics backed by Oceananigans’diffusive_flux_x/y/zkernels. - Introduce tracer-specific aliases
TracerDiffusiveFluxX/Y/Z. - Extend tracer diagnostics tests to cover the new diffusive flux diagnostics and their
Fieldwrapping.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
src/TracerEquation.jl |
Adds diffusive-flux diagnostic constructors, type aliases, and docstrings for tracer subgrid fluxes. |
test/test_tracer_diagnostics.jl |
Adds tests asserting the new diffusive-flux diagnostics construct correctly and can be wrapped as Fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Val(:a), model.tracers.a, model.clock, fields(model), model.buoyancy) | ||
| DIFF_FLUX_field = Field(DIFF_FLUX) | ||
| @test DIFF_FLUX isa TracerEquation.DiffusiveFluxX | ||
| @test DIFF_FLUX isa TracerDiffusiveFluxX | ||
| @test DIFF_FLUX_field isa Field |
There was a problem hiding this comment.
The convention in Oceanostics is that diagnostics can be available in the namespace as
Oceanostics.TracerEquation.TracerDiffusiveFluxX
Oceanostics.TracerEquation.DiffusiveFluxXor
Oceanostics.TracerDiffusiveFluxXfor all diagnostics.
But you can't do
Oceanostics.DiffusiveFluxXbecause then it's ambiguous what is being fluxed.
So I suggest reviewing the exports to make sure they're in line.
| function DiffusiveFluxX(model, tracer_name; kwargs...) | ||
| tracer_index = findfirst(x -> x == tracer_name, keys(model.tracers)) | ||
| tracer = model.tracers[tracer_index] | ||
| return DiffusiveFluxX(model, model.grid, model.closure, model.closure_fields, Val(tracer_index), tracer, model.clock, fields(model), model.buoyancy; kwargs...) | ||
| end |
There was a problem hiding this comment.
I agree with this comment! (And same for the other directions)
| function DiffusiveFluxX(model, grid, closure, closure_fields, val_tracer_index, tracer, clock, model_fields, buoyancy; location = (Face, Center, Center)) | ||
| validate_location(location, "DiffusiveFluxX", (Face, Center, Center)) | ||
| return KernelFunctionOperation{Face, Center, Center}(diffusive_flux_x, grid, closure, closure_fields, val_tracer_index, tracer, clock, model_fields, buoyancy) | ||
| end |
There was a problem hiding this comment.
I think I agree with this too. Can you please double check @jeremy-lilly ?
|
Asked copilot to give a review but I guess it went a little crazy lol |
|
Resolved the comments by copilot that were repetitive and that I didn't agree with. The remainder comments are the relevant ones |
Thank you @tomchor! I will look through these comments and resolve them as I have time -- I will ping you when ready for another look : ) |
This should be fixed by 24fb64c. The |
This PR adds diagnostic functions for calculating subgrid fluxes for tracers that are determined by the configured closure.
The user exposed routines
DiffusiveFluxX,DiffusiveFluxY, andDiffusiveFluxZuse the native Oceananigans kernelsdiffusive_flux_x,diffusive_flux_y, anddiffusive_flux_zrespectively.