From ac86c3af3a5ecec00b220a8cfbea58f74913b323 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 18 Dec 2024 23:07:02 +0100 Subject: [PATCH] (0.95.5) Bugfix in immersed phi-node (#4010) * correct immersed nodes * added a test --- Project.toml | 2 +- src/ImmersedBoundaries/immersed_boundary_nodes.jl | 2 +- test/test_grids.jl | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index deac47dc33..69f41143dd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Oceananigans" uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09" authors = ["Climate Modeling Alliance and contributors"] -version = "0.95.4" +version = "0.95.5" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/ImmersedBoundaries/immersed_boundary_nodes.jl b/src/ImmersedBoundaries/immersed_boundary_nodes.jl index 20335c9df5..ac883ce6d4 100644 --- a/src/ImmersedBoundaries/immersed_boundary_nodes.jl +++ b/src/ImmersedBoundaries/immersed_boundary_nodes.jl @@ -9,7 +9,7 @@ const f = Face() @inline znode(k, ibg::IBG, ℓz) = znode(k, ibg.underlying_grid, ℓz) @inline λnode(i, ibg::IBG, ℓx) = λnode(i, ibg.underlying_grid, ℓx) -@inline φnode(j, ibg::IBG, ℓy) = φnode(i, ibg.underlying_grid, ℓy) +@inline φnode(j, ibg::IBG, ℓy) = φnode(j, ibg.underlying_grid, ℓy) @inline xnode(i, j, ibg::IBG, ℓx, ℓy) = xnode(i, j, ibg.underlying_grid, ℓx, ℓy) diff --git a/test/test_grids.jl b/test/test_grids.jl index 5ba9e5ca97..c82fb76c90 100644 --- a/test/test_grids.jl +++ b/test/test_grids.jl @@ -649,6 +649,7 @@ function test_lat_lon_xyzλφ_node_nodes(FT, arch) zᵣ = (-10, 0) grid = LatitudeLongitudeGrid(CPU(), FT, size=grid_size, halo=halo, latitude=lat, longitude=lon, z=zᵣ) + ibg = ImmersedBoundaryGrid(grid, GridFittedBottom((x, y) -> y < 20 && y > -20 ? -50 : -0)) @info " Testing grid utils on LatitudeLongitude grid...." @@ -658,15 +659,19 @@ function test_lat_lon_xyzλφ_node_nodes(FT, arch) @test ynode(2, 1, 2, grid, Face(), Face(), Face()) / grid.radius ≈ -FT(π/3) @test znode(2, 1, 2, grid, Face(), Face(), Face()) ≈ -5 + @test λnode(3, 1, 2, ibg, Face(), Face(), Face()) ≈ -120 + @test φnode(3, 2, 2, ibg, Face(), Face(), Face()) ≈ -30 + @test xnode(5, 1, 2, ibg, Face(), Face(), Face()) / ibg.radius ≈ -FT(π/6) + @test ynode(2, 1, 2, ibg, Face(), Face(), Face()) / ibg.radius ≈ -FT(π/3) + @test znode(2, 1, 2, ibg, Face(), Face(), Face()) ≈ -5 + @test minimum_xspacing(grid, Face(), Face(), Face()) / grid.radius ≈ FT(π/6) * cosd(60) @test minimum_xspacing(grid) / grid.radius ≈ FT(π/6) * cosd(45) @test minimum_yspacing(grid) / grid.radius ≈ FT(π/6) @test minimum_zspacing(grid) ≈ 5 - grid = ImmersedBoundaryGrid(grid, GridFittedBottom((x, y) -> y < 20 && y > -20 ? -50 : -0)) - - @test minimum_xspacing(grid, Face(), Face(), Face()) / grid.radius ≈ FT(π/6) * cosd(30) - @test minimum_xspacing(grid) / grid.radius ≈ FT(π/6) * cosd(15) + @test minimum_xspacing(ibg, Face(), Face(), Face()) / ibg.radius ≈ FT(π/6) * cosd(30) + @test minimum_xspacing(ibg) / ibg.radius ≈ FT(π/6) * cosd(15) return nothing end