Skip to content
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

Building WENO advection with immersed grid fails due to grid size #3137

Closed
tomchor opened this issue Jun 6, 2023 · 3 comments · May be fixed by #3138
Closed

Building WENO advection with immersed grid fails due to grid size #3137

tomchor opened this issue Jun 6, 2023 · 3 comments · May be fixed by #3138

Comments

@tomchor
Copy link
Collaborator

tomchor commented Jun 6, 2023

The following snippet fails:

using Oceananigans
grid_base = RectilinearGrid(size=(8, 8, 8), extent = (1,1,1), halo=(4,4,4))
bathymetry(x, y) = -0.5
grid = ImmersedBoundaryGrid(grid_base, GridFittedBottom(bathymetry))
WENO(grid=grid)

The error is

julia> WENO(grid=grid)
ERROR: ArgumentError: The dimensions of the immersed boundary (16, 16) do not match the grid size (18, 18)
Stacktrace:
 [1] validate_ib_size(grid::RectilinearGrid{Float64, Periodic, Periodic, Bounded, Float64, Float64, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, CPU}, ib::GridFittedBottom{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, Oceananigans.ImmersedBoundaries.CenterImmersedCondition})
   @ Oceananigans.ImmersedBoundaries ~/.julia/packages/Oceananigans/9znTg/src/ImmersedBoundaries/grid_fitted_immersed_boundaries.jl:92
 [2] ImmersedBoundaryGrid(grid::RectilinearGrid{Float64, Periodic, Periodic, Bounded, Float64, Float64, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, CPU}, ib::GridFittedBottom{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, Oceananigans.ImmersedBoundaries.CenterImmersedCondition})
   @ Oceananigans.ImmersedBoundaries ~/.julia/packages/Oceananigans/9znTg/src/ImmersedBoundaries/grid_fitted_immersed_boundaries.jl:85
 [3] with_halo(halo::Tuple{Int64, Int64, Int64}, ibg::ImmersedBoundaryGrid{Float64, Periodic, Periodic, Bounded, RectilinearGrid{Float64, Periodic, Periodic, Bounded, Float64, Float64, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, CPU}, GridFittedBottom{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, Oceananigans.ImmersedBoundaries.CenterImmersedCondition}, Nothing, CPU})
   @ Oceananigans.ImmersedBoundaries ~/.julia/packages/Oceananigans/9znTg/src/ImmersedBoundaries/ImmersedBoundaries.jl:136
 [4] #compute_reconstruction_coefficients#26
   @ ~/.julia/packages/Oceananigans/9znTg/src/Advection/reconstruction_coefficients.jl:224 [inlined]
 [5] WENO(FT::DataType; order::Int64, grid::ImmersedBoundaryGrid{Float64, Periodic, Periodic, Bounded, RectilinearGrid{Float64, Periodic, Periodic, Bounded, Float64, Float64, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, CPU}, GridFittedBottom{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, Oceananigans.ImmersedBoundaries.CenterImmersedCondition}, Nothing, CPU}, zweno::Bool, bounds::Nothing)
   @ Oceananigans.Advection ~/.julia/packages/Oceananigans/9znTg/src/Advection/weno_reconstruction.jl:121
 [6] top-level scope
   @ REPL[5]:1

In order to work we need to call WENO as

WENO(grid=grid_base)

Is this by design or is it a bug?

@simone-silvestri
Copy link
Collaborator

It is not by design, because this is not a specific WENO problem. It's a problem with using with_halo on immersed boundaries (the bottom field does not have the same size as the new grid when trying to enlarge the halos). I thought it had been fixed already.

I ll fix it in a new PR

@tomchor
Copy link
Collaborator Author

tomchor commented Jun 6, 2023

Thanks @simone-silvestri! Should we add a test?

@tomchor
Copy link
Collaborator Author

tomchor commented Jan 26, 2024

This seems to not be an issue anymore:

julia> using Oceananigans
[ Info: Precompiling Oceananigans [9e8cae18-63c1-5223-a75c-80ca9d6e9a09]

julia> grid_base = RectilinearGrid(size=(8, 8, 8), extent = (1,1,1), halo=(4,4,4))
8×8×8 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 4×4×4 halo
├── Periodic x  [0.0, 1.0)  regularly spaced with Δx=0.125
├── Periodic y  [0.0, 1.0)  regularly spaced with Δy=0.125
└── Bounded  z  [-1.0, 0.0] regularly spaced with Δz=0.125

julia> bathymetry(x, y) = -0.5
bathymetry (generic function with 1 method)

julia> grid = ImmersedBoundaryGrid(grid_base, GridFittedBottom(bathymetry))
8×8×8 ImmersedBoundaryGrid{Float64, Periodic, Periodic, Bounded} on CPU with 4×4×4 halo:
├── immersed_boundary: GridFittedBottom(mean(z)=-0.5, min(z)=-0.5, max(z)=-0.5)
├── underlying_grid: 8×8×8 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 4×4×4 halo
├── Periodic x  [0.0, 1.0)  regularly spaced with Δx=0.125
├── Periodic y  [0.0, 1.0)  regularly spaced with Δy=0.125
└── Bounded  z  [-1.0, 0.0] regularly spaced with Δz=0.125

julia> WENO(grid=grid)
WENO reconstruction order 5 
 Smoothness formulation: 
    └── Z-weno 
 Boundary scheme: 
    └── WENO reconstruction order 3
 Symmetric scheme: 
    └── Centered reconstruction order 4
 Directions:
    ├── X regular 
    ├── Y regular 
    └── Z regular

So I'm closing this issue.

@tomchor tomchor closed this as completed Jan 26, 2024
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 a pull request may close this issue.

2 participants