Open liuchihl opened 2 days ago
That's a decent minimal example! Are you sure that the error requires advection=WENO()
and timestepper=:RungeKutta3
? The latter cannot be necessary since its the default (so omitting it has the same effect as including it).
I find I can reproduce the error without ImmersedBoundaryGrid
at all.
About the error. The top of the message says
ERROR: MethodError: no method matching cpu_fourier_tridiagonal_preconditioner_rhs!
This means that the kernel function fourier_tridiagonal_preconditioner_rhs!
is being called with the wrong arguments. For example:
julia> f(x, y) = x + y
f (generic function with 1 method)
julia> f(1)
ERROR: MethodError: no method matching f(::Int64)
Closest candidates are:
f(::Any, ::Any)
@ Main REPL[1]:1
Stacktrace:
[1] top-level scope
@ REPL[2]:1
The stacktrace shows
[8] compute_preconditioner_rhs!(solver::Oceananigans.Solvers.FourierTridiagonalPoissonSolver{…}, rhs::Field{…})
@ Oceananigans.Solvers ~/.julia/packages/Oceananigans/HPOLD/src/Solvers/conjugate_gradient_poisson_solver.jl:109
let's look at that line:
This uses the Oceananigans utility launch!
which launches the kernel fourier_tridiagonal_preconditioner_rhs!
with the arguments solver.storage, tridiagonal_dir, rhs
. However, looking at the function fourier_tridiagonal_preconditioner_rhs
a few lines above
we see that the function has 4 arguments, not 3. Hence the error.
To summarize the analysis method, the key is to find the function that causes the error in the source code (fourier_tridiagonal_preconditioner_rhs
) and then identify where it is called, and how it should be called.
Here's an updated MWE from your nice one @liuchihl :
using Oceananigans
using Oceananigans.Solvers: ConjugateGradientPoissonSolver, fft_poisson_solver
N = 2
x = y = (0, 1)
z = [0, 0.2, 1]
grid = RectilinearGrid(size=(N, N, N); x, y, z, halo=(2, 2, 2), topology=(Bounded, Periodic, Bounded))
fft_solver = fft_poisson_solver(grid)
pressure_solver = ConjugateGradientPoissonSolver(grid, preconditioner=fft_poisson_solver(grid))
model = NonhydrostaticModel(; grid, pressure_solver)
set!(model, u=1)
Using that MWE I fixed a number of bugs in this commit: https://github.com/CliMA/Oceananigans.jl/pull/3890/commits/aa0a43e8760558547b6592bce1d3bdaebd33908f
and the MWE now works.
That's a decent minimal example! Are you sure that the error requires advection=WENO() and timestepper=:RungeKutta3? The latter cannot be necessary since its the default (so omitting it has the same effect as including it).
I find I can reproduce the error without ImmersedBoundaryGrid at all.
You are absolutely right! Those are not needed.
Thank you so much for the detailed explanation, I get it now :)
I've received an error possibly related to the preconditioner, and it appears when I set the initial condition, e.g.,
set!(model, u=uᵢ)
:Here's a minimal working example (I tried to make it as minimal as possible, apologies if it's not minimal enough). I set the bottom topography to zero everywhere except for one grid cell, which is set to 0.2. Notably, when I change this value from 0.2 to 0.01, the error no longer appears. It is not clear to me what the issue might be.