Skip to content

Commit a7b90b2

Browse files
authored
Some code clean-up (#4806)
1 parent 120d7ad commit a7b90b2

38 files changed

+122
-127
lines changed

src/AbstractOperations/AbstractOperations.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ using Oceananigans.BoundaryConditions
1515
using Oceananigans.Fields
1616
using Oceananigans.Utils
1717

18-
using Oceananigans: location, AbstractModel
18+
using Oceananigans: location
1919
using Oceananigans.Operators: interpolation_operator
20-
using Oceananigans.Architectures: device
2120

2221
import Adapt
2322

src/AbstractOperations/binary_operations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function define_binary_operator(op)
6767
local ConstantField = Oceananigans.Fields.ConstantField
6868
local AF = AbstractField
6969

70-
@inline $op(i, j, k, grid::AbstractGrid, ▶a, ▶b, a, b) =
70+
@inline $op(i, j, k, grid::AbstractGrid, ▶a, ▶b, a, b) =
7171
@inbounds apply_op($op, ▶a(i, j, k, grid, a), ▶b(i, j, k, grid, b))
7272

7373
# These shenanigans seem to help / encourage the compiler to infer types of objects

src/AbstractOperations/conditional_operations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using Oceananigans.Fields: OneField, ReducedAbstractField, filltype, reduced_location, initialize_reduced_field!
1+
using Oceananigans.Fields: OneField
22
using Oceananigans.Grids: architecture
33
using Base: @propagate_inbounds
44

5-
import Base: minimum, maximum, sum, all, any, prod
5+
import Base: sum
66
import Oceananigans.Architectures: on_architecture
77
import Oceananigans.Fields: condition_operand, conditional_length, set!, compute_at!, indices
88

src/AbstractOperations/metric_field_reductions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Statistics: mean!, sum!
1+
using Statistics: sum!
22

33
using Oceananigans.Utils: tupleit
44
using Oceananigans.Grids: regular_dimensions

src/Advection/centered_reconstruction.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Centered(FT::DataType=Oceananigans.defaults.FloatType; order = 2)
1717
else
1818
buffer_scheme = nothing
1919
end
20-
20+
2121
return Centered{N, FT}(buffer_scheme)
2222
end
2323

@@ -47,7 +47,7 @@ for buffer in advection_buffers, FT in fully_supported_float_types
4747
@inline symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :x, false))
4848
@inline symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :y, false))
4949
@inline symmetric_interpolate_zᵃᵃᶠ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :z, false))
50-
50+
5151
@inline symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ::Callable, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :x, true))
5252
@inline symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ::Callable, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :y, true))
5353
@inline symmetric_interpolate_zᵃᵃᶠ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ::Callable, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :z, true))

src/Advection/upwind_biased_reconstruction.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,28 @@ const AUAS = AbstractUpwindBiasedAdvectionScheme
5959
# Uniform upwind biased reconstruction
6060
for buffer in advection_buffers, FT in fully_supported_float_types
6161
@eval begin
62-
@inline biased_interpolate_xᶠᵃᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ, args...) =
63-
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :x, false)),
62+
@inline biased_interpolate_xᶠᵃᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ, args...) =
63+
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :x, false)),
6464
$(calc_reconstruction_stencil(FT, buffer, :right, :x, false)))
6565

66-
@inline biased_interpolate_xᶠᵃᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ::Callable, args...) =
67-
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :x, true)),
66+
@inline biased_interpolate_xᶠᵃᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ::Callable, args...) =
67+
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :x, true)),
6868
$(calc_reconstruction_stencil(FT, buffer, :right, :x, true)))
69-
70-
@inline biased_interpolate_yᵃᶠᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ, args...) =
71-
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :y, false)),
69+
70+
@inline biased_interpolate_yᵃᶠᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ, args...) =
71+
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :y, false)),
7272
$(calc_reconstruction_stencil(FT, buffer, :right, :y, false)))
73-
74-
@inline biased_interpolate_yᵃᶠᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ::Callable, args...) =
75-
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :y, true)),
73+
74+
@inline biased_interpolate_yᵃᶠᵃ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ::Callable, args...) =
75+
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :y, true)),
7676
$(calc_reconstruction_stencil(FT, buffer, :right, :y, true)))
77-
78-
@inline biased_interpolate_zᵃᵃᶠ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ, args...) =
79-
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :z, false)),
77+
78+
@inline biased_interpolate_zᵃᵃᶠ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ, args...) =
79+
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :z, false)),
8080
$(calc_reconstruction_stencil(FT, buffer, :right, :z, false)))
8181

82-
@inline biased_interpolate_zᵃᵃᶠ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ::Callable, args...) =
83-
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :z, true)),
84-
$(calc_reconstruction_stencil(FT, buffer, :right, :z, true)))
82+
@inline biased_interpolate_zᵃᵃᶠ(i, j, k, grid, ::UpwindBiased{$buffer, $FT}, bias, ψ::Callable, args...) =
83+
@inbounds @muladd ifelse(bias isa LeftBias, $(calc_reconstruction_stencil(FT, buffer, :left, :z, true)),
84+
$(calc_reconstruction_stencil(FT, buffer, :right, :z, true)))
8585
end
8686
end

src/Advection/weno_interpolants.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ while for `buffer == 4` unrolls into
259259
# Smoothness indicators for stencil `stencil` for left and right biased reconstruction
260260
for buffer in advection_buffers[2:end] # WENO{<:Any, 1} does not exist
261261
@eval @inline smoothness_operation(scheme::WENO{$buffer}, ψ, C) = @inbounds @muladd $(metaprogrammed_smoothness_operation(buffer))
262-
262+
263263
for stencil in 0:buffer-1, FT in fully_supported_float_types
264264
@eval @inline smoothness_indicator(ψ, scheme::WENO{$buffer, $FT}, ::Val{$stencil}) =
265265
smoothness_operation(scheme, ψ, $(smoothness_coefficients(Val(FT), Val(buffer), Val(stencil))))

src/Biogeochemistry.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module Biogeochemistry
22

33
using Oceananigans.Grids: Center, xnode, ynode, znode
4-
using Oceananigans.Advection: div_Uc, Centered
5-
using Oceananigans.Architectures: device, architecture
64
using Oceananigans.Fields: ZeroField
75

86
import Oceananigans.Fields: CenterField

src/BoundaryConditions/field_boundary_conditions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ on_architecture(arch, fbcs::FieldBoundaryConditions) =
9797
on_architecture(arch, fbcs.north),
9898
on_architecture(arch, fbcs.bottom),
9999
on_architecture(arch, fbcs.top),
100-
on_architecture(arch, fbcs.immersed),
100+
on_architecture(arch, fbcs.immersed),
101101
fbcs.kernels,
102102
on_architecture(arch, fbcs.ordered_bcs))
103103

@@ -251,7 +251,7 @@ function regularize_field_boundary_conditions(bcs::FieldBoundaryConditions,
251251
loc::Tuple,
252252
prognostic_names=nothing,
253253
field_name=nothing)
254-
254+
255255
west = regularize_west_boundary_condition(bcs.west, grid, loc, 1, LeftBoundary, prognostic_names)
256256
east = regularize_east_boundary_condition(bcs.east, grid, loc, 1, RightBoundary, prognostic_names)
257257
south = regularize_south_boundary_condition(bcs.south, grid, loc, 2, LeftBoundary, prognostic_names)

src/BoundaryConditions/fill_halo_kernels.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using Oceananigans.Utils: configure_kernel
66
grid::AbstractGrid,
77
loc, indices)
88
9-
Construct preconfigured boundary condition kernels for a given `data` array, `grid`,
9+
Construct preconfigured boundary condition kernels for a given `data` array, `grid`,
1010
and the provided `bcs` (a FieldBoundaryConditions` object).
1111
Return a new `FieldBoundaryConditions` object with the preconfigured kernels and
1212
ordered boundary conditions.
@@ -48,7 +48,7 @@ construct_boundary_conditions_kernels(::Missing, data, grid, loc, indices) = mis
4848
for task in 1:length(sides)
4949
side = sides[task]
5050
bc = select_bc(ordered_bcs[task])
51-
51+
5252
size = fill_halo_size(data, side, indices, bc, loc, grid)
5353
offset = fill_halo_offset(size, side, indices)
5454
kernel! = fill_halo_kernel!(side, bc, grid, size, offset, data, reduced_dimensions)
@@ -84,26 +84,26 @@ fill_halo_kernel!(value, bc::NoBC, args...) = nothing
8484
##### Two-sided fill halo kernels
8585
#####
8686

87-
fill_halo_kernel!(::WestAndEast, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
87+
fill_halo_kernel!(::WestAndEast, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
8888
configure_kernel(architecture(grid), grid, kernel_parameters(size, offset), _fill_west_and_east_halo!; reduced_dimensions)[1]
8989

9090
fill_halo_kernel!(::SouthAndNorth, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
9191
configure_kernel(architecture(grid), grid, kernel_parameters(size, offset), _fill_south_and_north_halo!; reduced_dimensions)[1]
9292

93-
fill_halo_kernel!(::BottomAndTop, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
93+
fill_halo_kernel!(::BottomAndTop, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
9494
configure_kernel(architecture(grid), grid, kernel_parameters(size, offset), _fill_bottom_and_top_halo!; reduced_dimensions)[1]
9595

9696
#####
9797
##### One-sided fill halo kernels
9898
#####
9999

100-
fill_halo_kernel!(::West, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
100+
fill_halo_kernel!(::West, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
101101
configure_kernel(architecture(grid), grid, kernel_parameters(size, offset), _fill_only_west_halo!; reduced_dimensions)[1]
102102

103-
fill_halo_kernel!(::East, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
103+
fill_halo_kernel!(::East, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
104104
configure_kernel(architecture(grid), grid, kernel_parameters(size, offset), _fill_only_east_halo!; reduced_dimensions)[1]
105105

106-
fill_halo_kernel!(::South, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
106+
fill_halo_kernel!(::South, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
107107
configure_kernel(architecture(grid), grid, kernel_parameters(size, offset), _fill_only_south_halo!; reduced_dimensions)[1]
108108

109109
fill_halo_kernel!(::North, bc::BoundaryCondition, grid, size, offset, data, reduced_dimensions) =
@@ -119,17 +119,17 @@ fill_halo_kernel!(::Top, bc::BoundaryCondition, grid, size, offset, data, reduce
119119
##### Periodic fill halo kernels (Always two-sided)
120120
#####
121121

122-
function fill_halo_kernel!(::WestAndEast, bc::PBC, grid, size, offset, data, reduced_dimensions)
122+
function fill_halo_kernel!(::WestAndEast, bc::PBC, grid, size, offset, data, reduced_dimensions)
123123
yz_size, offset = periodic_size_and_offset(data, 2, 3, size, offset)
124124
return configure_kernel(architecture(grid), grid, kernel_parameters(yz_size, offset), _fill_periodic_west_and_east_halo!)[1]
125125
end
126126

127-
function fill_halo_kernel!(::SouthAndNorth, bc::PBC, grid, size, offset, data, reduced_dimensions)
127+
function fill_halo_kernel!(::SouthAndNorth, bc::PBC, grid, size, offset, data, reduced_dimensions)
128128
xz_size, offset = periodic_size_and_offset(data, 1, 3, size, offset)
129129
return configure_kernel(architecture(grid), grid, kernel_parameters(xz_size, offset), _fill_periodic_south_and_north_halo!)[1]
130130
end
131131

132-
function fill_halo_kernel!(::BottomAndTop, bc::PBC, grid, size, offset, data, reduced_dimensions)
132+
function fill_halo_kernel!(::BottomAndTop, bc::PBC, grid, size, offset, data, reduced_dimensions)
133133
xy_size, offset = periodic_size_and_offset(data, 1, 2, size, offset)
134134
return configure_kernel(architecture(grid), grid, kernel_parameters(xy_size, offset), _fill_periodic_bottom_and_top_halo!)[1]
135135
end
@@ -149,7 +149,7 @@ for Side in (:WestAndEast, :SouthAndNorth, :BottomAndTop, :West, :East, :South,
149149
end
150150

151151
#####
152-
##### MultiRegion Boundary Conditions
152+
##### MultiRegion Boundary Conditions
153153
#####
154154

155155
# A struct to hold the side of the fill_halo kernel

0 commit comments

Comments
 (0)