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

Fix ConjugateGradientPoissonSolver construction with default pre-conditioner #3830

Closed
wants to merge 3 commits into from

Conversation

ali-ramadhan
Copy link
Member

@ali-ramadhan ali-ramadhan commented Oct 7, 2024

I added a test that fails due to #3829. I should also test the non-FFT case and test that the proper pre-conditioner was initialized. So the test could be better but it does fail as it should.

What we need is a using Oceananigans.ImmersedBoundaries but the solvers module is defined well before the immersed boundaries module.

So for a solver to depend on the immersed boundaries module, and really just the ImmersedBoundaryGrid type then the immersed boundaries module needs to be included first.

Based on these comments maybe it's desirable to change the order of inclusion? But maybe it'll take some work. So otherwise we probably need to define another abstract type in src/Oceananigans.jl but this solution isn't ideal.

# TODO: move here
#include("ImmersedBoundaries/ImmersedBoundaries.jl")
#include("MultiRegion/MultiRegion.jl")
# Physics, time-stepping, and models
include("Coriolis/Coriolis.jl")
include("BuoyancyModels/BuoyancyModels.jl")
include("StokesDrifts.jl")
include("TurbulenceClosures/TurbulenceClosures.jl")
include("Forcings/Forcings.jl")
include("Biogeochemistry.jl")
# TODO: move above
include("ImmersedBoundaries/ImmersedBoundaries.jl")
include("Models/Models.jl")

Resolves #3829

@testset "ConjugateGradientSolver" begin
for arch in archs
@info "Testing ConjugateGradientSolver [$(typeof(arch))]..."
grid = RectilinearGrid(arch, size=(4, 8, 4), extent=(1, 3, 1))
run_identity_operator_test(grid)
run_poisson_equation_test(grid)
construct_conjugate_gradient_poisson_solver_with_default_preconditioner(grid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
construct_conjugate_gradient_poisson_solver_with_default_preconditioner(grid)
solver = ConjugateGradientPoissonSolver(grid)
@test solver isa ConjugateGradientPoissonSolver

Comment on lines +64 to +67
function construct_conjugate_gradient_poisson_solver_with_default_preconditioner(grid)
solver = ConjugateGradientPoissonSolver(grid)
return true
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function construct_conjugate_gradient_poisson_solver_with_default_preconditioner(grid)
solver = ConjugateGradientPoissonSolver(grid)
return true
end

@glwagner
Copy link
Member

glwagner commented Oct 8, 2024

Oof, good catch. Thanks for adding the test.

As a temporary fix, we could add a special constructor for ImmersedBoundaryGrid (ie use dispatch rather than the if-statement).

I suspect re-ordering the imports will be a larger piece of work that will probably require some work from @simone-silvestri . Technical debt is entrenched.

@simone-silvestri
Copy link
Collaborator

simone-silvestri commented Oct 8, 2024

To do this, we need to shift the definitions of

This will make the ImmersedBoundaries module very light weight and the others a bit more complicated but it something we discussed already and I think it's a positive change now that immersed boundaries are less "experimental". @ali-ramadhan I can help on this PR if you want.

@glwagner
Copy link
Member

glwagner commented Oct 8, 2024

It'd be easier to understand the suggestions if you put the links to the source code in your comment.

@ali-ramadhan
Copy link
Member Author

Thanks for the suggestions @simone-silvestri! And I noticed you started doing some refactoring in PR #3847 so I'll close this in favor of your PR.

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 this pull request may close these issues.

Cannot construct a ConjugateGradientPoissonSolver with a default preconditioner
3 participants