Skip to content

Integrate cubed sphere functionality with halo filling and core infrastructure updates #4538

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

Merged
merged 65 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0a9ac05
Make necessary modifications
siddharthabishnu May 21, 2025
485c9b2
Update multi_region_split_explicit_free_surface.jl
siddharthabishnu May 22, 2025
7883b96
Fix bug
siddharthabishnu May 22, 2025
f7fbd9f
Update src/Utils/multi_region_transformation.jl
siddharthabishnu May 23, 2025
43a3299
Update src/Models/HydrostaticFreeSurfaceModels/pcg_implicit_free_surf…
siddharthabishnu May 23, 2025
184349c
Merge origin/main into cubed-sphere-integration
siddharthabishnu May 23, 2025
c63b09f
Fix bug
siddharthabishnu May 23, 2025
c1ad7c8
Compact code
siddharthabishnu May 23, 2025
234b0ca
Specialize difference operators for CCSPanelGrid
siddharthabishnu May 23, 2025
dce1de7
Fix bug
siddharthabishnu May 23, 2025
d45843e
Extend tupled_fill_halo_regions!
siddharthabishnu May 23, 2025
c3fdf26
Fix bug
siddharthabishnu May 23, 2025
12d3429
Remove replace_horizontal_vector_halos!
siddharthabishnu May 23, 2025
c3554fd
Add explanatory comments and fix bug
siddharthabishnu May 23, 2025
f44de9d
Update src/Models/HydrostaticFreeSurfaceModels/pcg_implicit_free_surf…
siddharthabishnu May 26, 2025
8ebdbba
Update src/Models/HydrostaticFreeSurfaceModels/pcg_implicit_free_surf…
siddharthabishnu May 26, 2025
c6735e9
Update src/MultiRegion/unified_implicit_free_surface_solver.jl
siddharthabishnu May 26, 2025
f324fa7
Fix bug
siddharthabishnu May 27, 2025
c954455
Remove auxiliary_actions!
siddharthabishnu May 27, 2025
4c4f53e
Fix bugs
siddharthabishnu May 27, 2025
a452ee4
Update src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_fre…
simone-silvestri May 29, 2025
20c76b0
comment the todo
simone-silvestri May 29, 2025
e451f35
FieldBoundaryBuffers --> CommunicationBuffers
siddharthabishnu May 29, 2025
6e702fe
Remove unused parameter in fill_halo_size function
siddharthabishnu May 30, 2025
2d4a938
Fix bug
siddharthabishnu May 30, 2025
cc88318
Remove hardcoded situation-specific logic
siddharthabishnu May 30, 2025
dbb9d07
Merge 'origin/main' into cubed-sphere-integration
siddharthabishnu May 30, 2025
6cf9e66
Incorporate modifications from PR #4566
siddharthabishnu May 30, 2025
a5456f0
Incorporate modifications from PR #4568
siddharthabishnu May 30, 2025
9c6f27b
Fix typo
siddharthabishnu May 30, 2025
2cbedfd
Enhance code
siddharthabishnu May 30, 2025
5cad195
Reinstate unused parameter for consistency
siddharthabishnu Jun 1, 2025
6a92f67
Fix out-of-bounds memory access bug
siddharthabishnu Jun 1, 2025
b7dbf3e
Fix typo
siddharthabishnu Jun 1, 2025
5dc7e0f
Fix bug
siddharthabishnu Jun 2, 2025
eadc403
Remove commented-out line
siddharthabishnu Jun 2, 2025
d81bc83
Fix typo
siddharthabishnu Jun 2, 2025
3d59c83
Fix bug
siddharthabishnu Jun 3, 2025
23f5a24
Merge branch 'main' into sb/cubed-sphere-integration
simone-silvestri Jun 3, 2025
579e7f6
correct getregion for an immersed boundary grid
simone-silvestri Jun 3, 2025
8b8c1b7
fix show for a multiregion grid
simone-silvestri Jun 3, 2025
9711037
active cells map for CSG
simone-silvestri Jun 3, 2025
29b793c
add a small test for IBG construction on CSG
simone-silvestri Jun 3, 2025
5de105c
Merge remote-tracking branch 'origin/ss/fix-getregion-for-multi-immer…
simone-silvestri Jun 3, 2025
9dce5d5
including Immersed boundary grids in the PCG solver
simone-silvestri Jun 3, 2025
0bb2f79
Fix out-of-bounds memory allocation error
siddharthabishnu Jun 3, 2025
a76bb7b
Update test_multi_region_cubed_sphere.jl
siddharthabishnu Jun 4, 2025
f7a4521
Use ConformalCubedSphereGridOfSomeKind
siddharthabishnu Jun 5, 2025
832595d
Fix out-of-bounds error
siddharthabishnu Jun 5, 2025
a4b210e
Update test_multi_region_cubed_sphere.jl
siddharthabishnu Jun 5, 2025
77c871c
Fix out-of-bounds error
siddharthabishnu Jun 5, 2025
62ec81d
Update test_multi_region_cubed_sphere.jl
siddharthabishnu Jun 5, 2025
9f23ffd
Leverage reduced_dimensions for kernel launches
siddharthabishnu Jun 6, 2025
6522112
add a function inside apply regionally
simone-silvestri Jun 6, 2025
aa40552
Enhance code
siddharthabishnu Jun 6, 2025
24e2632
Compact code
siddharthabishnu Jun 6, 2025
b7135f2
switch the apply regionally inside the linear operation
simone-silvestri Jun 9, 2025
45a39c3
revert
simone-silvestri Jun 9, 2025
ac630d6
Update src/MultiRegion/multi_region_split_explicit_free_surface.jl
simone-silvestri Jun 9, 2025
d7a1a21
Update src/MultiRegion/multi_region_boundary_conditions.jl
simone-silvestri Jun 9, 2025
0b9548a
Update src/MultiRegion/multi_region_boundary_conditions.jl
simone-silvestri Jun 9, 2025
ceed343
Fix GPU error
siddharthabishnu Jun 9, 2025
a53bf07
Merge 'origin/main' into cubed-sphere-integration
siddharthabishnu Jun 9, 2025
a8cb979
Define ConformalCubedSpherePanelGridOfSomeKind
siddharthabishnu Jun 10, 2025
3118f46
Fix GPU kernel type instability bug
siddharthabishnu Jun 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/BoundaryConditions/BoundaryConditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ using Oceananigans.Grids

import Adapt: adapt_structure

# Switch around halos for cubed sphere by exchanging buffer informations
replace_horizontal_vector_halos!(velocities, grid::AbstractGrid; signed=true) = nothing

include("boundary_condition_classifications.jl")
include("boundary_condition.jl")
include("discrete_boundary_function.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/ImmersedBoundaries/immersed_boundary_grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ end
const IBG = ImmersedBoundaryGrid

@inline Base.getproperty(ibg::IBG, property::Symbol) = get_ibg_property(ibg, Val(property))
@inline get_ibg_property(ibg::IBG, ::Val{property}) where property = getfield(getfield(ibg, :underlying_grid), property)
@inline get_ibg_property(ibg::IBG, ::Val{property}) where property = getproperty(getfield(ibg, :underlying_grid), property)
@inline get_ibg_property(ibg::IBG, ::Val{:immersed_boundary}) = getfield(ibg, :immersed_boundary)
@inline get_ibg_property(ibg::IBG, ::Val{:underlying_grid}) = getfield(ibg, :underlying_grid)
@inline get_ibg_property(ibg::IBG, ::Val{:interior_active_cells}) = getfield(ibg, :interior_active_cells)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function initialize_free_surface!(sefs::SplitExplicitFreeSurface, grid, velociti
grid, u, v, sefs.η)

fill_halo_regions!((barotropic_velocities.U, barotropic_velocities.V))
fill_halo_regions!(sefs.η)

return nothing
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Oceananigans.Architectures
using Oceananigans.Grids: with_halo, isrectilinear, halo_size
using Oceananigans.Architectures: device

import Oceananigans.Solvers: solve!, precondition!
import Oceananigans.Solvers: solve!, precondition!, auxiliary_actions!
import Oceananigans.Architectures: architecture

"""
Expand Down Expand Up @@ -50,7 +50,12 @@ function PCGImplicitFreeSurfaceSolver(grid::AbstractGrid, settings, gravitationa
vertically_integrated_lateral_areas = (xᶠᶜᶜ = ∫ᶻ_Axᶠᶜᶜ, yᶜᶠᶜ = ∫ᶻ_Ayᶜᶠᶜ)

@apply_regionally compute_vertically_integrated_lateral_areas!(vertically_integrated_lateral_areas)
fill_halo_regions!(vertically_integrated_lateral_areas)

u = vertically_integrated_lateral_areas.xᶠᶜᶜ
v = vertically_integrated_lateral_areas.yᶜᶠᶜ

grid isa ConformalCubedSphereGrid ? fill_halo_regions!((u, v); signed=false) :
fill_halo_regions!(vertically_integrated_lateral_areas)

# Set some defaults
settings = Dict{Symbol, Any}(settings)
Expand Down Expand Up @@ -134,16 +139,16 @@ function implicit_free_surface_linear_operation!(L_ηⁿ⁺¹, ηⁿ⁺¹, ∫
grid = L_ηⁿ⁺¹.grid
arch = architecture(L_ηⁿ⁺¹)

# Note: because of `fill_halo_regions!` below, we cannot use `PCGImplicitFreeSurface` on a
# multi-region grid; `fill_halo_regions!` cannot be used within `@apply_regionally`
fill_halo_regions!(ηⁿ⁺¹)

launch!(arch, grid, :xy, _implicit_free_surface_linear_operation!,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
launch!(arch, grid, :xy, _implicit_free_surface_linear_operation!,
@apply_regionally launch!(arch, grid, :xy, _implicit_free_surface_linear_operation!,

L_ηⁿ⁺¹, grid, ηⁿ⁺¹, ∫ᶻ_Axᶠᶜᶜ, ∫ᶻ_Ayᶜᶠᶜ, g, Δt)

return nothing
end

ImplicitFreeSurfaceOperation = typeof(implicit_free_surface_linear_operation!)

auxiliary_actions!(::ImplicitFreeSurfaceOperation, L_ηⁿ⁺¹, ηⁿ⁺¹, args...) = fill_halo_regions!(ηⁿ⁺¹)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is used in the solver module right? I am not sure this is very clear. Is there a way to maybe write it in a more streamlined way? Like, for example, by removing the @apply_regionally from line 202 of conjugate_gradient_solver.jl and write a function which in the body:

@inline function mylinearoperation(...)
    @apply_regionally my_actual_linear_operation(...)
    fill_halo_regions!()
end

Copy link
Contributor Author

@siddharthabishnu siddharthabishnu May 27, 2025

Choose a reason for hiding this comment

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

Please see the modifications here: f324fa7...4c4f53e.


# Kernels that act on vertically integrated / surface quantities
@inline ∫ᶻ_Ax_∂x_ηᶠᶜᶜ(i, j, k, grid, ∫ᶻ_Axᶠᶜᶜ, η) = @inbounds ∫ᶻ_Axᶠᶜᶜ[i, j, k] * ∂xᶠᶜᶠ(i, j, k, grid, η)
@inline ∫ᶻ_Ay_∂y_ηᶜᶠᶜ(i, j, k, grid, ∫ᶻ_Ayᶜᶠᶜ, η) = @inbounds ∫ᶻ_Ayᶜᶠᶜ[i, j, k] * ∂yᶜᶠᶠ(i, j, k, grid, η)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,8 @@ function hydrostatic_velocity_fields(velocities::PrescribedVelocityFields, grid,
v = wrap_prescribed_field(Center, Face, Center, velocities.v, grid; clock, parameters)
w = wrap_prescribed_field(Center, Center, Face, velocities.w, grid; clock, parameters)

fill_halo_regions!(u)
fill_halo_regions!(v)
fill_halo_regions!((u, v))
fill_halo_regions!(w)
prescribed_velocities = (; u, v, w)
@apply_regionally replace_horizontal_vector_halos!(prescribed_velocities, grid)

return PrescribedVelocityFields(u, v, w, parameters)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ using Oceananigans.BoundaryConditions

using Oceananigans: UpdateStateCallsite
using Oceananigans.Biogeochemistry: update_biogeochemical_state!
using Oceananigans.BoundaryConditions: update_boundary_condition!, replace_horizontal_vector_halos!
using Oceananigans.BoundaryConditions: update_boundary_condition!
using Oceananigans.TurbulenceClosures: compute_diffusivities!
using Oceananigans.ImmersedBoundaries: mask_immersed_field!, mask_immersed_field_xy!, inactive_node
using Oceananigans.Models: update_model_field_time_series!
using Oceananigans.Models.NonhydrostaticModels: update_hydrostatic_pressure!, p_kernel_parameters
using Oceananigans.MultiRegion: ConformalCubedSphereGrid
using Oceananigans.Fields: tupled_fill_halo_regions!

import Oceananigans.Models.NonhydrostaticModels: compute_auxiliaries!
Expand Down Expand Up @@ -39,9 +40,20 @@ function update_state!(model::HydrostaticFreeSurfaceModel, grid, callbacks; comp
# Update the boundary conditions
@apply_regionally update_boundary_condition!(fields(model), model)

tupled_fill_halo_regions!(prognostic_fields(model), grid, model.clock, fields(model), async=true)
if grid isa ConformalCubedSphereGrid
if model.tracers != nothing
for tracer in model.tracers
fill_halo_regions!(tracer)
end
end
if model.free_surface != nothing
fill_halo_regions!(model.free_surface.η)
end
fill_halo_regions!((model.velocities.u, model.velocities.v))
else
tupled_fill_halo_regions!(prognostic_fields(model), model.clock, fields(model); async = true)
end

@apply_regionally replace_horizontal_vector_halos!(model.velocities, model.grid)
@apply_regionally compute_auxiliaries!(model)

fill_halo_regions!(model.diffusivity_fields; only_local_halos = true)
Expand Down
Loading
Loading