(0.105.5) Add unit test for zero momentum flux at immersed peripheral nodes#5402
(0.105.5) Add unit test for zero momentum flux at immersed peripheral nodes#5402
Conversation
Tests that all 9 advective momentum flux kernels return zero at immersed peripheral nodes, for Centered(2), UpwindBiased(3), and WENO(5). This documents the expected behavior after PR #4987 removed the explicit conditional_flux zeroing from _advective_momentum_flux_* on ImmersedBoundaryGrid, relying instead on velocity masking in immersed cells and the no-penetration BC at the boundary face. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
I would make it a little more stressful, something like a random bottom boundary and then create a test field and then check if everywhere we have an immersed node, the flux is zero. Something like c = Center()
f = Face()
@kernel function _populate_test!(tuu, tuv, tuw, tvu, tvv, tvw, twu, twv, tww grid, u, v, w)
i, j, k = @index(Global, NTuple)
Fuu = _advective_momentum_flux_Uu(i, j, k, grid, scheme, u, u)
Fuv = _advective_momentum_flux_Uv(i, j, k, grid, scheme, u, v)
Fuw = _advective_momentum_flux_Uw(i, j, k, grid, scheme, u, w)
Fvu = _advective_momentum_flux_Vu(i, j, k, grid, scheme, v, u)
Fvv = _advective_momentum_flux_Vv(i, j, k, grid, scheme, v, v)
Fvw = _advective_momentum_flux_Vw(i, j, k, grid, scheme, v, w)
Fwu = _advective_momentum_flux_Wu(i, j, k, grid, scheme, w, u)
Fwv = _advective_momentum_flux_Wv(i, j, k, grid, scheme, w, v)
Fww = _advective_momentum_flux_Ww(i, j, k, grid, scheme, w, w)
@inbounds begin
tuu[i, j, k] = (Fuu == 0) & immersed_peripheral_node(i, j, k, grid, c, c, c)
tuv[i, j, k] = (Fuv == 0) & immersed_peripheral_node(i, j, k, grid, f, f, c)
tuw[i, j, k] = (Fuw == 0) & immersed_peripheral_node(i, j, k, grid, f, c, f)
tvu[i, j, k] = (Fvu == 0) & immersed_peripheral_node(i, j, k, grid, f, f, c)
tvv[i, j, k] = (Fvv == 0) & immersed_peripheral_node(i, j, k, grid, c, c, c)
tvw[i, j, k] = (Fvw == 0) & immersed_peripheral_node(i, j, k, grid, c, f, f)
twu[i, j, k] = (Fwu == 0) & immersed_peripheral_node(i, j, k, grid, f, c, f)
twv[i, j, k] = (Fwv == 0) & immersed_peripheral_node(i, j, k, grid, c, f, f)
tww[i, j, k] = (Fww == 0) & immersed_peripheral_node(i, j, k, grid, c, c, c)
end
endthen you can check @test all(Array(interior(tuu))and so on. |
|
@simone-silvestri can you double check? Locally those tests fail for me. But they also fail when I include the conditional momentum fluxes back so maybe I misunderstood what you're trying to check? Feel free to modify this PR directly also if that's easier. |
|
We needed to include boundaries. Btw, it looks like we indeed need the conditional fluxes |
|
cc @glwagner |
|
Changed the title since apparently this is a bugfix. Although we could wait before this PR and #5366 are merged before registering a new version. |
…gans.jl into tc/test-advective-forcing
Added fallback functions for 'nothing' advection in immersed advective fluxes.
Sounds good. I reviewed and approved it already. I'd appreciate it if you could also review #5366 when you have a chance. And then maybe we can register a new version with all three PRs sooner rather than later. |
|
Also I took the liberty to fix the test that was failing. Hopefully tests pass now. |
* glw/prescribed-free-surface: Clean up update_prescribed_∂t_σ! method signatures Fix ∂t_σ = 0 bug for PrescribedFreeSurface + ZStarCoordinate Revise citation for De Abreu and Timmermans (CliMA#5411) Add benchmarking package with earth_ocean case (CliMA#5317) (0.105.5) Add unit test for zero momentum flux at immersed peripheral nodes (CliMA#5402) (0.105.5) Fix `initialize_closure_fields!()` use with `DynamicSmagorinsky` (CliMA#5366) Fix the reference list in the Langmuir example (CliMA#5400)
Tests that all 9 advective momentum flux kernels return zero at immersed peripheral nodes, for Centered(2), UpwindBiased(3), and WENO(5). This documents the expected behavior after PR #4987 removed the explicit conditional_flux zeroing from advective_momentum_flux* on ImmersedBoundaryGrid, relying instead on velocity masking in immersed cells and the no-penetration BC at the boundary face.
cc @simone-silvestri