CliMA / Oceananigans.jl

🌊 Julia software for fast, friendly, flexible, ocean-flavored fluid dynamics on CPUs and GPUs
https://clima.github.io/OceananigansDocumentation/stable
MIT License
986 stars 193 forks source link

Nonhydrostatic pressure solver does not accept a horizontally irregular grid. #2940

Closed m3azevedo closed 1 year ago

m3azevedo commented 1 year ago

Hello, I noticed a vertically irregular grid can be passed to a nonhydrostatic model and seems to run without a problem, but when the same formulation is applied to the horizontal, a method error is returned by the PressureSolver. The error persists if either the FFTBasedPoissonSolver or the FourierTridiagonalPoissonSolver are called. Is this a known issue?

A MWE follows. Notice the MWE is a reduction of the example given in the grid documentation, which also gives back the same error when passed to a nonhydrostatic model.

using Oceananigans

Lx, Ly, Lz = 1e4, 1e4, 1e3;
Nx, Ny, Nz = 64, 64, 32;
chebychev_spaced_y_faces(j) = - Ly/2 * cos(π * (j - 1) / Ny)

grid = RectilinearGrid(size = (Nx, Ny, Nz),
topology = (Periodic, Bounded, Bounded),
                              x = (0, Lx),
                              y = chebychev_spaced_y_faces,
                              z = (-Lz,0)
                              )

model = NonhydrostaticModel(; grid)

Gives:

ERROR: MethodError: no method matching PressureSolver(::CPU, ::RectilinearGrid{Float64, Periodic, Bounded, Bounded, Float64, OffsetArrays.OffsetVector{Float64, Vector{Float64}}, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, 
Int64}}, OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, CPU})
Closest candidates are:
  PressureSolver(::Any, ::RectilinearGrid{<:Any, <:Any, <:Any, <:Any, <:Number, <:Number, <:Number}) at C:\Users\.julia\packages\Oceananigans\MDeEL\src\Models\NonhydrostaticModels\NonhydrostaticModels.jl:23
  PressureSolver(::Any, ::RectilinearGrid{<:Any, <:Any, <:Any, <:Any, <:Number, <:Number}) at C:\Users\.julia\packages\Oceananigans\MDeEL\src\Models\NonhydrostaticModels\NonhydrostaticModels.jl:24
  PressureSolver(::Any, ::ImmersedBoundaryGrid) at C:\Users\.julia\packages\Oceananigans\MDeEL\src\Models\NonhydrostaticModels\NonhydrostaticModels.jl:27
Stacktrace:
 [1] NonhydrostaticModel(; grid::RectilinearGrid{Float64, Periodic, Bounded, Bounded, Float64, OffsetArrays.OffsetVector{Float64, Vector{Float64}}, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, CPU}, clock::Clock{Float64}, advection::Centered{1, Float64, Nothing, Nothing, Nothing, Nothing}, buoyancy::Nothing, coriolis::Nothing, stokes_drift::Nothing, forcing::NamedTuple{(), Tuple{}}, closure::Nothing, boundary_conditions::NamedTuple{(), Tuple{}}, tracers::Tuple{}, timestepper::Symbol, background_fields::NamedTuple{(), Tuple{}}, particles::Nothing, velocities::Nothing, pressures::Nothing, diffusivity_fields::Nothing, pressure_solver::Nothing, immersed_boundary::Nothing, auxiliary_fields::NamedTuple{(), Tuple{}}, calculate_only_active_cells_tendencies::Bool)
   @ Oceananigans.Models.NonhydrostaticModels C:\Users\.julia\packages\Oceananigans\MDeEL\src\Models\NonhydrostaticModels\nonhydrostatic_model.jl:184
 [2] top-level scope
   @ d:\Documentos\Oceananigans\inertial-instability\Minimum_notworking_example.jl:17

All the best.

glwagner commented 1 year ago

Yes, this is known --- we don't have support for horizontally irregular / curvilinear grids with NonhydrostaticModel.

navidcy commented 1 year ago

Let's add an info/warning so that users don't think that this is a bug.