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

ArgumentError: halo must be ≤ size in ocean_simulation on coarse TripolarGrid #336

Open
glwagner opened this issue Feb 1, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@glwagner
Copy link
Member

glwagner commented Feb 1, 2025

The reason is that the default free_surface does not work when there are fewer than 70 points in a direction.

julia> using ClimaOcean, Oceananigans, OrthogonalSphericalShellGrids
Precompiling ClimaOcean finished.
  4 dependencies successfully precompiled in 21 seconds. 220 already precompiled.

julia> grid = TripolarGrid(CPU(); size=(90, 45, 2), halo=(7, 7, 7), z=(-1000, 0))
90×45×2 OrthogonalSphericalShellGrid{Float64, Periodic, Oceananigans.Grids.RightConnected, Bounded} on CPU with 7×7×7 halo and with precomputed metrics
├── centered at (λ, φ) = (71.8913, 1.8042)
├── longitude: Periodic  extent 360.16 degrees                           variably spaced with min(Δλ)=0.146465, max(Δλ)=4.21462
├── latitude:  Oceananigans.Grids.RightConnected  extent 174.524 degrees variably spaced with min(Δφ)=0.223895, max(Δφ)=4.61174
└── z:         Bounded  z  [-1000.0, 0.0]                               regularly spaced with Δz=500.0

julia> ocean = ocean_simulation(grid)
┌ Warning: Are you totally, 100% sure that you want to build a simulation on
│
│ 90×45×2 OrthogonalSphericalShellGrid{Float64, Periodic, Oceananigans.Grids.RightConnected, Bounded} on CPU with 7×7×7 halo and with precomputed metrics
│
│ rather than on an ImmersedBoundaryGrid?
└ @ ClimaOcean.OceanSimulations ~/Projects/ClimaOcean.jl/src/OceanSimulations/OceanSimulations.jl:132
┌ Warning: `ImmersedBoundaryCondition` is experimental.
└ @ Oceananigans.ImmersedBoundaries ~/Projects/Oceananigans.jl/src/ImmersedBoundaries/immersed_boundary_condition.jl:57
┌ Warning: `ImmersedBoundaryCondition` is experimental.
└ @ Oceananigans.ImmersedBoundaries ~/Projects/Oceananigans.jl/src/ImmersedBoundaries/immersed_boundary_condition.jl:57
┌ Warning: `ImmersedBoundaryCondition` is experimental.
└ @ Oceananigans.ImmersedBoundaries ~/Projects/Oceananigans.jl/src/ImmersedBoundaries/immersed_boundary_condition.jl:57
┌ Warning: `ImmersedBoundaryCondition` is experimental.
└ @ Oceananigans.ImmersedBoundaries ~/Projects/Oceananigans.jl/src/ImmersedBoundaries/immersed_boundary_condition.jl:57
ERROR: ArgumentError: halo must be  size for coordinate y
Stacktrace:
  [1] validate_halo(TX::Type, TY::Type, TZ::Type, size::Tuple{Int64, Int64, Int64}, halo::Tuple{Int64, Int64})
    @ Oceananigans.Grids ~/Projects/Oceananigans.jl/src/Grids/input_validation.jl:87
  [2] validate_rectilinear_grid_args(topology::Tuple{…}, size::Tuple{…}, halo::Tuple{…}, FT::Type, extent::Nothing, x::Tuple{…}, y::Tuple{…}, z::Nothing)
    @ Oceananigans.Grids ~/Projects/Oceananigans.jl/src/Grids/rectilinear_grid.jl:289
  [3] RectilinearGrid(architecture::CPU, FT::DataType; size::Tuple{…}, x::Tuple{…}, y::Tuple{…}, z::Nothing, halo::Tuple{…}, extent::Nothing, topology::Tuple{…})
    @ Oceananigans.Grids ~/Projects/Oceananigans.jl/src/Grids/rectilinear_grid.jl:264
  [4] RectilinearGrid (repeats 2 times)
    @ ~/Projects/Oceananigans.jl/src/Grids/rectilinear_grid.jl:250 [inlined]
  [5] (OrthogonalSphericalShellGrid{} where {})(arch::CPU, FT::DataType; size::Tuple{…}, southernmost_latitude::Int64, halo::Tuple{…}, radius::Float64, z::Tuple{…}, north_poles_latitude::Int64, first_pole_longitude::Int64)
    @ OrthogonalSphericalShellGrids ~/.julia/packages/OrthogonalSphericalShellGrids/LLaMu/src/tripolar_grid.jl:135
  [6] OrthogonalSphericalShellGrid
    @ ~/.julia/packages/OrthogonalSphericalShellGrids/LLaMu/src/tripolar_grid.jl:58 [inlined]
  [7] with_halo
    @ ~/.julia/packages/OrthogonalSphericalShellGrids/LLaMu/src/with_halo.jl:15 [inlined]
  [8] maybe_extend_halos
    @ ~/Projects/Oceananigans.jl/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl:287 [inlined]
  [9] materialize_free_surface(free_surface::SplitExplicitFreeSurface{…}, velocities::@NamedTuple{}, grid::Oceananigans.Grids.ZRegOrthogonalSphericalShellGrid{…})
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels.SplitExplicitFreeSurfaces ~/Projects/Oceananigans.jl/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl:171
 [10] HydrostaticFreeSurfaceModel(; grid::Oceananigans.Grids.ZRegOrthogonalSphericalShellGrid{…}, clock::Clock{…}, momentum_advection::VectorInvariant{…}, tracer_advection::@NamedTuple{}, buoyancy::SeawaterBuoyancy{…}, coriolis::HydrostaticSphericalCoriolis{…}, free_surface::SplitExplicitFreeSurface{…}, tracers::Tuple{…}, forcing::@NamedTuple{}, closure::Oceananigans.TurbulenceClosures.TKEBasedVerticalDiffusivities.CATKEVerticalDiffusivity{…}, timestepper::Symbol, boundary_conditions::@NamedTuple{}, particles::Nothing, biogeochemistry::Nothing, velocities::Nothing, pressure::Nothing, diffusivity_fields::Nothing, auxiliary_fields::@NamedTuple{}, vertical_coordinate::Oceananigans.Models.HydrostaticFreeSurfaceModels.ZCoordinate)
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels ~/Projects/Oceananigans.jl/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_model.jl:202
 [11] ocean_simulation(grid::Oceananigans.Grids.ZRegOrthogonalSphericalShellGrid{…}; Δt::Float64, closure::Oceananigans.TurbulenceClosures.TKEBasedVerticalDiffusivities.CATKEVerticalDiffusivity{…}, tracers::Tuple{…}, free_surface::SplitExplicitFreeSurface{…}, reference_density::Int64, rotation_rate::Float64, gravitational_acceleration::Float64, bottom_drag_coefficient::ClimaOcean.OceanSimulations.Default{…}, forcing::@NamedTuple{}, biogeochemistry::Nothing, timestepper::Symbol, coriolis::ClimaOcean.OceanSimulations.Default{…}, momentum_advection::VectorInvariant{…}, equation_of_state::SeawaterPolynomials.BoussinesqEquationOfState{…}, boundary_conditions::@NamedTuple{}, tracer_advection::FluxFormAdvection{…}, vertical_coordinate::Oceananigans.Models.HydrostaticFreeSurfaceModels.ZCoordinate, verbose::Bool)
    @ ClimaOcean.OceanSimulations ~/Projects/ClimaOcean.jl/src/OceanSimulations/OceanSimulations.jl:190
 [12] ocean_simulation(grid::Oceananigans.Grids.ZRegOrthogonalSphericalShellGrid{…})
    @ ClimaOcean.OceanSimulations ~/Projects/ClimaOcean.jl/src/OceanSimulations/OceanSimulations.jl:81
 [13] top-level scope
    @ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.

I recommend changing the default so that the number of substeps is computed based on the situations. In particular, the key assumption we have to make regards the time-step. We should encode this assumption explicitly, and then compute substeps based on g, H. Then we should limit these substeps by Nx, Ny. In the case of a limitation, we should print a warning that instability may occur if dt > something because the CFL will be violated for the free surface.

@glwagner glwagner added the bug Something isn't working label Feb 1, 2025
@glwagner glwagner changed the title ocean_simulation errors on coarse TripolarGrid ArgumentError: halo must be ≤ size for coordinate y in ocean_simulation on coarse TripolarGrid Feb 1, 2025
@glwagner glwagner changed the title ArgumentError: halo must be ≤ size for coordinate y in ocean_simulation on coarse TripolarGrid ArgumentError: halo must be ≤ size in ocean_simulation on coarse TripolarGrid Feb 1, 2025
@simone-silvestri
Copy link
Collaborator

right, there is a "heuristic" solution in #276.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants