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

Remove Immersed map from Adapting the ImmersedBoundaryGrid #3690

Merged
merged 38 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
58bd4da
add new branch
simone-silvestri Aug 7, 2024
d970dc6
add some comments
simone-silvestri Aug 7, 2024
5632474
add comments
simone-silvestri Aug 7, 2024
93f579a
adapt non hydrostatic model
simone-silvestri Aug 7, 2024
1f31ce4
add inbounds where needed
simone-silvestri Aug 7, 2024
edbc06d
adapt barotropic kernel
simone-silvestri Aug 7, 2024
cacb022
last bugfix?
simone-silvestri Aug 7, 2024
512c0c1
Merge branch 'main' into ss/remove-immersed-map-from-adapt
simone-silvestri Aug 7, 2024
b6d65f3
add some explanation and name changes
simone-silvestri Aug 7, 2024
cfe4618
Merge branch 'ss/remove-immersed-map-from-adapt' of github.com:CliMA/…
simone-silvestri Aug 7, 2024
c407fdb
adding some explanation
simone-silvestri Aug 7, 2024
f0153ee
typo
simone-silvestri Aug 7, 2024
3cc5f12
better naming
simone-silvestri Aug 7, 2024
7b04eb0
better comment
simone-silvestri Aug 7, 2024
21bd603
add comments
simone-silvestri Aug 7, 2024
827080b
add comments
simone-silvestri Aug 7, 2024
7ada6d3
add another explanation
simone-silvestri Aug 7, 2024
9974ac4
change names
simone-silvestri Aug 7, 2024
7a5ac3a
some more explanation
simone-silvestri Aug 7, 2024
dca93d2
add some more explanation
simone-silvestri Aug 7, 2024
28870a6
better naming
simone-silvestri Aug 7, 2024
694ac10
more description
simone-silvestri Aug 7, 2024
be3d3f5
Merge branch 'main' into ss/remove-immersed-map-from-adapt
simone-silvestri Aug 7, 2024
e04eee8
change some naming
simone-silvestri Aug 7, 2024
43e9f96
Merge branch 'ss/remove-immersed-map-from-adapt' of github.com:CliMA/…
simone-silvestri Aug 7, 2024
428610d
typo
simone-silvestri Aug 7, 2024
f9a8200
bugfix
simone-silvestri Aug 7, 2024
d012f05
Update src/ImmersedBoundaries/active_cells_map.jl
simone-silvestri Aug 8, 2024
f7bce0f
Update src/ImmersedBoundaries/active_cells_map.jl
simone-silvestri Aug 8, 2024
79d8c5d
Merge branch 'main' into ss/remove-immersed-map-from-adapt
simone-silvestri Aug 8, 2024
0cd0e9c
Merge branch 'main' into ss/remove-immersed-map-from-adapt
simone-silvestri Aug 12, 2024
e1f2dc5
make sure synchronized architectures do not split the active map
simone-silvestri Aug 14, 2024
2795489
Merge branch 'main' into ss/remove-immersed-map-from-adapt
simone-silvestri Sep 4, 2024
1d481e5
Merge branch 'main' into ss/remove-immersed-map-from-adapt
simone-silvestri Sep 16, 2024
260e554
adding some immersed map tests
simone-silvestri Sep 16, 2024
4bce1fb
no active cells map for grid fitted boundary?
simone-silvestri Sep 16, 2024
68ccbda
active cells map for gridfitted boundary
simone-silvestri Sep 16, 2024
0d3fe7a
revert to previous implementation
simone-silvestri Sep 17, 2024
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
6 changes: 4 additions & 2 deletions src/Grids/Grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ const YZFlatGrid = AbstractGrid{<:Any, <:Any, Flat, Flat}
const XYZFlatGrid = AbstractGrid{<:Any, Flat, Flat, Flat}

isrectilinear(grid) = false
@inline active_surface_map(::AbstractGrid) = nothing
@inline active_interior_map(::AbstractGrid) = nothing

# Fallback
@inline active_surface_map(::AbstractGrid, any_map) = nothing
@inline active_interior_map(::AbstractGrid, any_map) = nothing

include("grid_utils.jl")
include("nodes_and_spacings.jl")
Expand Down
6 changes: 3 additions & 3 deletions src/ImmersedBoundaries/ImmersedBoundaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const IBG = ImmersedBoundaryGrid
@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)
@inline get_ibg_property(ibg::IBG, ::Val{:active_z_columns}) = getfield(ibg, :active_z_columns)
@inline get_ibg_property(ibg::IBG, ::Val{:active_z_columns}) = getfield(ibg, :active_z_columns)

@inline architecture(ibg::IBG) = architecture(ibg.underlying_grid)

Expand All @@ -146,8 +146,8 @@ const IBG = ImmersedBoundaryGrid
Adapt.adapt_structure(to, ibg::IBG{FT, TX, TY, TZ}) where {FT, TX, TY, TZ} =
ImmersedBoundaryGrid{TX, TY, TZ}(adapt(to, ibg.underlying_grid),
adapt(to, ibg.immersed_boundary),
adapt(to, ibg.interior_active_cells),
adapt(to, ibg.active_z_columns))
nothing,
nothing)

with_halo(halo, ibg::ImmersedBoundaryGrid) =
ImmersedBoundaryGrid(with_halo(halo, ibg.underlying_grid), ibg.immersed_boundary)
Expand Down
40 changes: 10 additions & 30 deletions src/ImmersedBoundaries/active_cells_map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,16 @@ A constant representing an immersed boundary grid, where active columns in the Z
"""
const ActiveZColumnsIBG = ImmersedBoundaryGrid{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:AbstractArray}

struct InteriorMap end
struct ZColumnMap end
@inline active_surface_map(grid::ActiveZColumnsIBG) = grid.active_z_columns

struct WestMap end
struct EastMap end
struct SouthMap end
struct NorthMap end

@inline active_surface_map(::ActiveZColumnsIBG) = ZColumnMap()

@inline active_interior_map(::Val{:west}) = WestMap()
@inline active_interior_map(::Val{:east}) = EastMap()
@inline active_interior_map(::Val{:south}) = SouthMap()
@inline active_interior_map(::Val{:north}) = NorthMap()

@inline active_interior_map(::ActiveCellsIBG) = InteriorMap()
@inline active_interior_map(::DistributedActiveCellsIBG) = InteriorMap()
@inline active_interior_map(grid::ArrayActiveCellsIBG, ::Val{:interior}) = grid.interior_active_cells
@inline active_interior_map(grid::NamedTupleActiveCellsIBG, ::Val{:interior}) = grid.interior_active_cells.interior
@inline active_interior_map(grid::NamedTupleActiveCellsIBG, ::Val{:west}) = grid.interior_active_cells.west
@inline active_interior_map(grid::NamedTupleActiveCellsIBG, ::Val{:east}) = grid.interior_active_cells.east
@inline active_interior_map(grid::NamedTupleActiveCellsIBG, ::Val{:south}) = grid.interior_active_cells.south
@inline active_interior_map(grid::NamedTupleActiveCellsIBG, ::Val{:north}) = grid.interior_active_cells.north
@inline active_interior_map(grid::ActiveZColumnsIBG, ::Val{:surface}) = grid.active_z_columns
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the purpose of this system of functions or what a "named tuple active cells ibg" means, for example.

Also the function is called "map", but the object is called "cells". Which is it -- a map, or cells?


"""
active_cells_work_layout(group, size, map_type, grid)
Expand All @@ -52,19 +45,12 @@ Compute the work layout for active cells based on the given map type and grid.
# Arguments
- `group`: The previous workgroup.
- `size`: The previous worksize.
- `map_type`: The type of map (e.g., `InteriorMap`, `WestMap`, `EastMap`, `SouthMap`, `NorthMap`).
- `grid`: The grid containing the active cells.

# Returns
- A tuple `(workgroup, worksize)` representing the work layout for active cells.
"""
@inline active_cells_work_layout(group, size, ::InteriorMap, grid::ArrayActiveCellsIBG) = min(length(grid.interior_active_cells), 256), length(grid.interior_active_cells)
@inline active_cells_work_layout(group, size, ::InteriorMap, grid::NamedTupleActiveCellsIBG) = min(length(grid.interior_active_cells.interior), 256), length(grid.interior_active_cells.interior)
@inline active_cells_work_layout(group, size, ::WestMap, grid::NamedTupleActiveCellsIBG) = min(length(grid.interior_active_cells.west), 256), length(grid.interior_active_cells.west)
@inline active_cells_work_layout(group, size, ::EastMap, grid::NamedTupleActiveCellsIBG) = min(length(grid.interior_active_cells.east), 256), length(grid.interior_active_cells.east)
@inline active_cells_work_layout(group, size, ::SouthMap, grid::NamedTupleActiveCellsIBG) = min(length(grid.interior_active_cells.south), 256), length(grid.interior_active_cells.south)
@inline active_cells_work_layout(group, size, ::NorthMap, grid::NamedTupleActiveCellsIBG) = min(length(grid.interior_active_cells.north), 256), length(grid.interior_active_cells.north)
@inline active_cells_work_layout(group, size, ::ZColumnMap, grid::ActiveZColumnsIBG) = min(length(grid.active_z_columns), 256), length(grid.active_z_columns)
@inline active_cells_work_layout(group, size, active_cells_map) = min(length(active_cells_map), 256), length(active_cells_map)

"""
active_linear_index_to_tuple(idx, map, grid)
Expand All @@ -79,13 +65,7 @@ Converts a linear index to a tuple of indices based on the given map and grid.
# Returns
A tuple of indices corresponding to the linear index.
"""
@inline active_linear_index_to_tuple(idx, ::InteriorMap, grid::ArrayActiveCellsIBG) = Base.map(Int, grid.interior_active_cells[idx])
@inline active_linear_index_to_tuple(idx, ::InteriorMap, grid::NamedTupleActiveCellsIBG) = Base.map(Int, grid.interior_active_cells.interior[idx])
@inline active_linear_index_to_tuple(idx, ::WestMap, grid::NamedTupleActiveCellsIBG) = Base.map(Int, grid.interior_active_cells.west[idx])
@inline active_linear_index_to_tuple(idx, ::EastMap, grid::NamedTupleActiveCellsIBG) = Base.map(Int, grid.interior_active_cells.east[idx])
@inline active_linear_index_to_tuple(idx, ::SouthMap, grid::NamedTupleActiveCellsIBG) = Base.map(Int, grid.interior_active_cells.south[idx])
@inline active_linear_index_to_tuple(idx, ::NorthMap, grid::NamedTupleActiveCellsIBG) = Base.map(Int, grid.interior_active_cells.north[idx])
@inline active_linear_index_to_tuple(idx, ::ZColumnMap, grid::ActiveZColumnsIBG) = Base.map(Int, grid.active_z_columns[idx])
@inline active_linear_index_to_tuple(idx, active_cells_map) = @inbounds Base.map(Int, active_cells_map[idx])

function ImmersedBoundaryGrid(grid, ib; active_cells_map::Bool = true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ function compute_boundary_tendency_contributions!(grid::DistributedActiveCellsIB
maps = grid.interior_active_cells

for (name, map) in zip(keys(maps), maps)
compute_boundary = (name != :interior) && !isnothing(map)

# If there exists a boundary map, then we compute the boundary contributions
# If there exists a boundary map, then we compute the boundary contributions. If not, the
# boundary contributions have already been calculated. We exclude the interior because it has
# already been calculated
compute_boundary = (name != :interior) && !isnothing(map)

if compute_boundary
active_boundary_map = active_interior_map(Val(name))
compute_hydrostatic_free_surface_tendency_contributions!(model, tuple(:xyz);
active_cells_map = active_boundary_map)
active_cells_map = active_interior_map(grid, Val(name))
compute_hydrostatic_free_surface_tendency_contributions!(model, tuple(:xyz); active_cells_map)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using Oceananigans.Biogeochemistry: update_tendencies!
using Oceananigans.TurbulenceClosures.TKEBasedVerticalDiffusivities: FlavorOfCATKE, FlavorOfTD

using Oceananigans.ImmersedBoundaries: active_interior_map, ActiveCellsIBG,
InteriorMap, active_linear_index_to_tuple
active_linear_index_to_tuple

"""
compute_tendencies!(model::HydrostaticFreeSurfaceModel, callbacks)
Expand All @@ -24,9 +24,10 @@ function compute_tendencies!(model::HydrostaticFreeSurfaceModel, callbacks)
kernel_parameters = tuple(interior_tendency_kernel_parameters(model.grid))

# Calculate contributions to momentum and tracer tendencies from fluxes and volume terms in the
# interior of the domain
compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_parameters;
active_cells_map = active_interior_map(model.grid))
# interior of the domain. The active cells map restricts the computation to the active cells in the
# interior if the grid is _immersed_ and the `active_cells_map` kwarg is active
active_cells_map = active_interior_map(model.grid, Val(:interior))
compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_parameters; active_cells_map)

complete_communication_and_compute_boundary!(model, model.grid, model.architecture)

Expand Down Expand Up @@ -201,26 +202,26 @@ end
#####

""" Calculate the right-hand-side of the u-velocity equation. """
@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, map, args)
@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, ::Nothing, args)
i, j, k = @index(Global, NTuple)
@inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args...)
end

@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid::ActiveCellsIBG, map, args)
@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, active_cells_map, args)
idx = @index(Global, Linear)
i, j, k = active_linear_index_to_tuple(idx, map, grid)
i, j, k = active_linear_index_to_tuple(idx, active_cells_map)
@inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args...)
end

""" Calculate the right-hand-side of the v-velocity equation. """
@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, map, args)
@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, ::Nothing, args)
i, j, k = @index(Global, NTuple)
@inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args...)
end

@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid::ActiveCellsIBG, map, args)
@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, active_cells_map, args)
idx = @index(Global, Linear)
i, j, k = active_linear_index_to_tuple(idx, map, grid)
i, j, k = active_linear_index_to_tuple(idx, active_cells_map)
@inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args...)
end

Expand All @@ -229,14 +230,14 @@ end
#####

""" Calculate the right-hand-side of the tracer advection-diffusion equation. """
@kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid, map, args)
@kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid, ::Nothing, args)
i, j, k = @index(Global, NTuple)
@inbounds Gc[i, j, k] = hydrostatic_free_surface_tracer_tendency(i, j, k, grid, args...)
end

@kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid::ActiveCellsIBG, map, args)
@kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid, active_cells_map, args)
idx = @index(Global, Linear)
i, j, k = active_linear_index_to_tuple(idx, map, grid)
i, j, k = active_linear_index_to_tuple(idx, active_cells_map)
@inbounds Gc[i, j, k] = hydrostatic_free_surface_tracer_tendency(i, j, k, grid, args...)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Oceananigans.BoundaryConditions
using Oceananigans.Operators
using Oceananigans.Architectures: convert_args
using Oceananigans.ImmersedBoundaries: peripheral_node, immersed_inactive_node, GFBIBG
using Oceananigans.ImmersedBoundaries: inactive_node, IBG, c, f, ZColumnMap
using Oceananigans.ImmersedBoundaries: inactive_node, IBG, c, f
using Oceananigans.ImmersedBoundaries: mask_immersed_field!, active_surface_map, active_interior_map
using Oceananigans.ImmersedBoundaries: active_linear_index_to_tuple, ActiveCellsIBG, ActiveZColumnsIBG
using Oceananigans.DistributedComputations: child_architecture
Expand Down Expand Up @@ -195,7 +195,7 @@ end

# Barotropic Model Kernels
# u_Δz = u * Δz
@kernel function _barotropic_mode_kernel!(U, V, grid, u, v)
@kernel function _barotropic_mode_kernel!(U, V, grid, ::Nothing, u, v)
i, j = @index(Global, NTuple)
k_top = grid.Nz+1

Expand All @@ -210,9 +210,9 @@ end

# Barotropic Model Kernels
# u_Δz = u * Δz
@kernel function _barotropic_mode_kernel!(U, V, grid::ActiveZColumnsIBG, u, v)
@kernel function _barotropic_mode_kernel!(U, V, grid, active_cells_map, u, v)
idx = @index(Global, Linear)
i, j = active_linear_index_to_tuple(idx, ZColumnMap(), grid)
i, j = active_linear_index_to_tuple(idx, active_cells_map)
k_top = grid.Nz+1

@inbounds U[i, j, k_top-1] = Δzᶠᶜᶜ(i, j, 1, grid) * u[i, j, 1]
Expand All @@ -224,9 +224,13 @@ end
end
end

compute_barotropic_mode!(U, V, grid, u, v) =
launch!(architecture(grid), grid, :xy, _barotropic_mode_kernel!, U, V, grid, u, v;
active_cells_map = active_surface_map(grid))
@inline function compute_barotropic_mode!(U, V, grid, u, v)
active_cells_map = active_surface_map(grid)

launch!(architecture(grid), grid, :xy, _barotropic_mode_kernel!, U, V, grid, active_cells_map, u, v; active_cells_map)

return nothing
end

function initialize_free_surface_state!(state, η, timestepper)

Expand Down Expand Up @@ -411,7 +415,7 @@ function iterate_split_explicit!(free_surface, grid, Δτᴮ, weights, ::Val{Nsu
end

# Calculate RHS for the barotropic time step.
@kernel function _compute_integrated_ab2_tendencies!(Gᵁ, Gⱽ, grid, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ)
@kernel function _compute_integrated_ab2_tendencies!(Gᵁ, Gⱽ, grid, ::Nothing, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ)
i, j = @index(Global, NTuple)
k_top = grid.Nz + 1

Expand All @@ -425,9 +429,9 @@ end
end

# Calculate RHS for the barotropic time step.q
@kernel function _compute_integrated_ab2_tendencies!(Gᵁ, Gⱽ, grid::ActiveZColumnsIBG, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ)
@kernel function _compute_integrated_ab2_tendencies!(Gᵁ, Gⱽ, grid, active_cells_map, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ)
idx = @index(Global, Linear)
i, j = active_linear_index_to_tuple(idx, ZColumnMap(), grid)
i, j = active_linear_index_to_tuple(idx, active_cells_map)
k_top = grid.Nz+1

@inbounds Gᵁ[i, j, k_top-1] = Δzᶠᶜᶜ(i, j, 1, grid) * ab2_step_Gu(i, j, 1, grid, Gu⁻, Guⁿ, χ)
Expand Down Expand Up @@ -465,9 +469,14 @@ function setup_free_surface!(model, free_surface::SplitExplicitFreeSurface, χ)
return nothing
end

setup_split_explicit_tendency!(auxiliary, grid, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ) =
@inline function setup_split_explicit_tendency!(auxiliary, grid, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ)
active_cells_map = active_surface_map(grid)

launch!(architecture(grid), grid, :xy, _compute_integrated_ab2_tendencies!, auxiliary.Gᵁ, auxiliary.Gⱽ, grid,
Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ; active_cells_map = active_surface_map(grid))
active_cells_map, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ; active_cells_map)

return nothing
end

wait_free_surface_communication!(free_surface, arch) = nothing

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Oceananigans.Utils: work_layout
using Oceananigans.Models: complete_communication_and_compute_boundary!, interior_tendency_kernel_parameters

using Oceananigans.ImmersedBoundaries: active_interior_map, ActiveCellsIBG,
InteriorMap, active_linear_index_to_tuple
active_linear_index_to_tuple

import Oceananigans.TimeSteppers: compute_tendencies!

Expand All @@ -27,8 +27,9 @@ function compute_tendencies!(model::NonhydrostaticModel, callbacks)
# Calculate contributions to momentum and tracer tendencies from fluxes and volume terms in the
# interior of the domain
kernel_parameters = tuple(interior_tendency_kernel_parameters(model.grid))

compute_interior_tendency_contributions!(model, kernel_parameters; active_cells_map = active_interior_map(model.grid))
active_cells_map = active_interior_map(model.grid, Val(:interior))

compute_interior_tendency_contributions!(model, kernel_parameters; active_cells_map)
complete_communication_and_compute_boundary!(model, model.grid, model.architecture)

# Calculate contributions to momentum and tracer tendencies from user-prescribed fluxes across the
Expand Down Expand Up @@ -142,38 +143,38 @@ end
#####

""" Calculate the right-hand-side of the u-velocity equation. """
@kernel function compute_Gu!(Gu, grid, interior_map, args)
@kernel function compute_Gu!(Gu, grid, ::Nothing, args)
i, j, k = @index(Global, NTuple)
@inbounds Gu[i, j, k] = u_velocity_tendency(i, j, k, grid, args...)
end

@kernel function compute_Gu!(Gu, grid::ActiveCellsIBG, map::InteriorMap, args)
@kernel function compute_Gu!(Gu, grid, interior_map, args)
idx = @index(Global, Linear)
i, j, k = active_linear_index_to_tuple(idx, map, grid)
i, j, k = active_linear_index_to_tuple(idx, interior_map)
@inbounds Gu[i, j, k] = u_velocity_tendency(i, j, k, grid, args...)
end

""" Calculate the right-hand-side of the v-velocity equation. """
@kernel function compute_Gv!(Gv, grid, interior_map, args)
@kernel function compute_Gv!(Gv, grid, ::Nothing, args)
i, j, k = @index(Global, NTuple)
@inbounds Gv[i, j, k] = v_velocity_tendency(i, j, k, grid, args...)
end

@kernel function compute_Gv!(Gv, grid::ActiveCellsIBG, map::InteriorMap, args)
@kernel function compute_Gv!(Gv, grid, interior_map, args)
idx = @index(Global, Linear)
i, j, k = active_linear_index_to_tuple(idx, map, grid)
i, j, k = active_linear_index_to_tuple(idx, interior_map)
@inbounds Gv[i, j, k] = v_velocity_tendency(i, j, k, grid, args...)
end

""" Calculate the right-hand-side of the w-velocity equation. """
@kernel function compute_Gw!(Gw, grid, interior_map, args)
@kernel function compute_Gw!(Gw, grid, ::Nothing, args)
i, j, k = @index(Global, NTuple)
@inbounds Gw[i, j, k] = w_velocity_tendency(i, j, k, grid, args...)
end

@kernel function compute_Gw!(Gw, grid::ActiveCellsIBG, map, ::InteriorMap, args)
@kernel function compute_Gw!(Gw, grid, interior_map, args)
idx = @index(Global, Linear)
i, j, k = active_linear_index_to_tuple(idx, map, grid)
i, j, k = active_linear_index_to_tuple(idx, interior_map)
@inbounds Gw[i, j, k] = w_velocity_tendency(i, j, k, grid, args...)
end

Expand All @@ -182,14 +183,14 @@ end
#####

""" Calculate the right-hand-side of the tracer advection-diffusion equation. """
@kernel function compute_Gc!(Gc, grid, interior_map, args)
@kernel function compute_Gc!(Gc, grid, ::Nothing, args)
i, j, k = @index(Global, NTuple)
@inbounds Gc[i, j, k] = tracer_tendency(i, j, k, grid, args...)
end

@kernel function compute_Gc!(Gc, grid::ActiveCellsIBG, map::InteriorMap, args)
@kernel function compute_Gc!(Gc, grid, interior_map, args)
idx = @index(Global, Linear)
i, j, k = active_linear_index_to_tuple(idx, map, grid)
i, j, k = active_linear_index_to_tuple(idx, interior_map)
@inbounds Gc[i, j, k] = tracer_tendency(i, j, k, grid, args...)
end

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/kernel_launching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function configured_kernel(arch, grid, workspec, kernel!;
offset = offsets(workspec)

if !isnothing(active_cells_map)
workgroup, worksize = active_cells_work_layout(workgroup, worksize, active_cells_map, grid)
workgroup, worksize = active_cells_work_layout(workgroup, worksize, active_cells_map)
offset = nothing

# A non active domain!
Expand Down