@@ -9,95 +9,95 @@ using Oceananigans.Grids: AbstractGrid
9
9
# ####
10
10
11
11
# Unpack
12
- apply_x_bcs ! (Gc, c, args... ) = apply_x_bcs ! (Gc, Gc. grid, c, c. boundary_conditions. west, c. boundary_conditions. east, args... )
13
- apply_y_bcs ! (Gc, c, args... ) = apply_y_bcs ! (Gc, Gc. grid, c, c. boundary_conditions. south, c. boundary_conditions. north, args... )
14
- apply_z_bcs ! (Gc, c, args... ) = apply_z_bcs ! (Gc, Gc. grid, c, c. boundary_conditions. bottom, c. boundary_conditions. top, args... )
12
+ compute_x_bcs ! (Gc, c, args... ) = compute_x_bcs ! (Gc, Gc. grid, c, c. boundary_conditions. west, c. boundary_conditions. east, args... )
13
+ compute_y_bcs ! (Gc, c, args... ) = compute_y_bcs ! (Gc, Gc. grid, c, c. boundary_conditions. south, c. boundary_conditions. north, args... )
14
+ compute_z_bcs ! (Gc, c, args... ) = compute_z_bcs ! (Gc, Gc. grid, c, c. boundary_conditions. bottom, c. boundary_conditions. top, args... )
15
15
16
16
# Shortcuts for...
17
17
#
18
18
# Nothing tendencies.
19
- apply_x_bcs ! (:: Nothing , args... ) = nothing
20
- apply_y_bcs ! (:: Nothing , args... ) = nothing
21
- apply_z_bcs ! (:: Nothing , args... ) = nothing
19
+ compute_x_bcs ! (:: Nothing , args... ) = nothing
20
+ compute_y_bcs ! (:: Nothing , args... ) = nothing
21
+ compute_z_bcs ! (:: Nothing , args... ) = nothing
22
22
23
23
# Not-flux boundary conditions
24
24
const NotFluxBC = Union{PBC, MCBC, DCBC, VBC, GBC, OBC, ZFBC, Nothing}
25
25
26
- apply_x_bcs ! (Gc, :: AbstractGrid , c, :: NotFluxBC , :: NotFluxBC , :: AbstractArchitecture , args... ) = nothing
27
- apply_y_bcs ! (Gc, :: AbstractGrid , c, :: NotFluxBC , :: NotFluxBC , :: AbstractArchitecture , args... ) = nothing
28
- apply_z_bcs ! (Gc, :: AbstractGrid , c, :: NotFluxBC , :: NotFluxBC , :: AbstractArchitecture , args... ) = nothing
26
+ compute_x_bcs ! (Gc, :: AbstractGrid , c, :: NotFluxBC , :: NotFluxBC , :: AbstractArchitecture , args... ) = nothing
27
+ compute_y_bcs ! (Gc, :: AbstractGrid , c, :: NotFluxBC , :: NotFluxBC , :: AbstractArchitecture , args... ) = nothing
28
+ compute_z_bcs ! (Gc, :: AbstractGrid , c, :: NotFluxBC , :: NotFluxBC , :: AbstractArchitecture , args... ) = nothing
29
29
30
30
# The real deal
31
31
"""
32
32
Apply flux boundary conditions to a field `c` by adding the associated flux divergence to
33
33
the source term `Gc` at the left and right.
34
34
"""
35
- apply_x_bcs ! (Gc, grid:: AbstractGrid , c, west_bc, east_bc, arch:: AbstractArchitecture , args... ) =
36
- launch! (arch, grid, :yz , _apply_x_bcs !, Gc, instantiated_location (Gc), grid, west_bc, east_bc, Tuple (args))
35
+ compute_x_bcs ! (Gc, grid:: AbstractGrid , c, west_bc, east_bc, arch:: AbstractArchitecture , args... ) =
36
+ launch! (arch, grid, :yz , _compute_x_bcs !, Gc, instantiated_location (Gc), grid, west_bc, east_bc, Tuple (args))
37
37
38
38
"""
39
39
Apply flux boundary conditions to a field `c` by adding the associated flux divergence to
40
40
the source term `Gc` at the left and right.
41
41
"""
42
- apply_y_bcs ! (Gc, grid:: AbstractGrid , c, south_bc, north_bc, arch:: AbstractArchitecture , args... ) =
43
- launch! (arch, grid, :xz , _apply_y_bcs !, Gc, instantiated_location (Gc), grid, south_bc, north_bc, Tuple (args))
42
+ compute_y_bcs ! (Gc, grid:: AbstractGrid , c, south_bc, north_bc, arch:: AbstractArchitecture , args... ) =
43
+ launch! (arch, grid, :xz , _compute_y_bcs !, Gc, instantiated_location (Gc), grid, south_bc, north_bc, Tuple (args))
44
44
45
45
"""
46
46
Apply flux boundary conditions to a field `c` by adding the associated flux divergence to
47
47
the source term `Gc` at the top and bottom.
48
48
"""
49
- apply_z_bcs ! (Gc, grid:: AbstractGrid , c, bottom_bc, top_bc, arch:: AbstractArchitecture , args... ) =
50
- launch! (arch, grid, :xy , _apply_z_bcs !, Gc, instantiated_location (Gc), grid, bottom_bc, top_bc, Tuple (args))
49
+ compute_z_bcs ! (Gc, grid:: AbstractGrid , c, bottom_bc, top_bc, arch:: AbstractArchitecture , args... ) =
50
+ launch! (arch, grid, :xy , _compute_z_bcs !, Gc, instantiated_location (Gc), grid, bottom_bc, top_bc, Tuple (args))
51
51
52
52
"""
53
- _apply_x_bcs !(Gc, grid, west_bc, east_bc, args...)
53
+ _compute_x_bcs !(Gc, grid, west_bc, east_bc, args...)
54
54
55
55
Apply a west and/or east boundary condition to variable `c`.
56
56
"""
57
- @kernel function _apply_x_bcs ! (Gc, loc, grid, west_bc, east_bc, args)
57
+ @kernel function _compute_x_bcs ! (Gc, loc, grid, west_bc, east_bc, args)
58
58
j, k = @index (Global, NTuple)
59
- apply_x_west_bc ! (Gc, loc, west_bc, j, k, grid, args... )
60
- apply_x_east_bc ! (Gc, loc, east_bc, j, k, grid, args... )
59
+ compute_x_west_bc ! (Gc, loc, west_bc, j, k, grid, args... )
60
+ compute_x_east_bc ! (Gc, loc, east_bc, j, k, grid, args... )
61
61
end
62
62
63
63
"""
64
- _apply_y_bcs !(Gc, grid, south_bc, north_bc, args...)
64
+ _compute_y_bcs !(Gc, grid, south_bc, north_bc, args...)
65
65
66
66
Apply a south and/or north boundary condition to variable `c`.
67
67
"""
68
- @kernel function _apply_y_bcs ! (Gc, loc, grid, south_bc, north_bc, args)
68
+ @kernel function _compute_y_bcs ! (Gc, loc, grid, south_bc, north_bc, args)
69
69
i, k = @index (Global, NTuple)
70
- apply_y_south_bc ! (Gc, loc, south_bc, i, k, grid, args... )
71
- apply_y_north_bc ! (Gc, loc, north_bc, i, k, grid, args... )
70
+ compute_y_south_bc ! (Gc, loc, south_bc, i, k, grid, args... )
71
+ compute_y_north_bc ! (Gc, loc, north_bc, i, k, grid, args... )
72
72
end
73
73
74
74
"""
75
- _apply_z_bcs !(Gc, grid, bottom_bc, top_bc, args...)
75
+ _compute_z_bcs !(Gc, grid, bottom_bc, top_bc, args...)
76
76
77
77
Apply a top and/or bottom boundary condition to variable `c`.
78
78
"""
79
- @kernel function _apply_z_bcs ! (Gc, loc, grid, bottom_bc, top_bc, args)
79
+ @kernel function _compute_z_bcs ! (Gc, loc, grid, bottom_bc, top_bc, args)
80
80
i, j = @index (Global, NTuple)
81
- apply_z_bottom_bc ! (Gc, loc, bottom_bc, i, j, grid, args... )
82
- apply_z_top_bc ! (Gc, loc, top_bc, i, j, grid, args... )
81
+ compute_z_bottom_bc ! (Gc, loc, bottom_bc, i, j, grid, args... )
82
+ compute_z_top_bc ! (Gc, loc, top_bc, i, j, grid, args... )
83
83
end
84
84
85
85
# Shortcuts for zero flux or non-flux boundary conditions
86
- @inline apply_x_east_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
87
- @inline apply_x_west_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
88
- @inline apply_y_north_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
89
- @inline apply_y_south_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
90
- @inline apply_z_top_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
91
- @inline apply_z_bottom_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
86
+ @inline compute_x_east_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
87
+ @inline compute_x_west_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
88
+ @inline compute_y_north_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
89
+ @inline compute_y_south_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
90
+ @inline compute_z_top_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
91
+ @inline compute_z_bottom_bc ! (Gc, loc, :: NotFluxBC , args... ) = nothing
92
92
93
93
# shortcut for the zipper BC
94
- @inline apply_y_north_bc ! (Gc, loc, :: ZBC , args... ) = nothing
94
+ @inline compute_y_north_bc ! (Gc, loc, :: ZBC , args... ) = nothing
95
95
96
96
@inline flip (:: Center ) = Face ()
97
97
@inline flip (:: Face ) = Center ()
98
98
99
99
"""
100
- apply_x_west_bc !(Gc, loc, west_flux::BC{<:Flux}, j, k, grid, args...)
100
+ compute_x_west_bc !(Gc, loc, west_flux::BC{<:Flux}, j, k, grid, args...)
101
101
102
102
Add the flux divergence associated with a west flux boundary condition on `c`.
103
103
Note that because
@@ -111,26 +111,26 @@ If `west_bc.condition` is a function, the function must have the signature
111
111
112
112
The same logic holds for south and bottom boundary conditions in `y`, and `z`, respectively.
113
113
"""
114
- @inline function apply_x_west_bc ! (Gc, loc, west_flux:: BC{<:Flux} , j, k, grid, args... )
114
+ @inline function compute_x_west_bc ! (Gc, loc, west_flux:: BC{<:Flux} , j, k, grid, args... )
115
115
LX, LY, LZ = loc
116
116
@inbounds Gc[1 , j, k] += getbc (west_flux, j, k, grid, args... ) * Ax (1 , j, k, grid, flip (LX), LY, LZ) / volume (1 , j, k, grid, LX, LY, LZ)
117
117
return nothing
118
118
end
119
119
120
- @inline function apply_y_south_bc ! (Gc, loc, south_flux:: BC{<:Flux} , i, k, grid, args... )
120
+ @inline function compute_y_south_bc ! (Gc, loc, south_flux:: BC{<:Flux} , i, k, grid, args... )
121
121
LX, LY, LZ = loc
122
122
@inbounds Gc[i, 1 , k] += getbc (south_flux, i, k, grid, args... ) * Ay (i, 1 , k, grid, LX, flip (LY), LZ) / volume (i, 1 , k, grid, LX, LY, LZ)
123
123
return nothing
124
124
end
125
125
126
- @inline function apply_z_bottom_bc ! (Gc, loc, bottom_flux:: BC{<:Flux} , i, j, grid, args... )
126
+ @inline function compute_z_bottom_bc ! (Gc, loc, bottom_flux:: BC{<:Flux} , i, j, grid, args... )
127
127
LX, LY, LZ = loc
128
128
@inbounds Gc[i, j, 1 ] += getbc (bottom_flux, i, j, grid, args... ) * Az (i, j, 1 , grid, LX, LY, flip (LZ)) / volume (i, j, 1 , grid, LX, LY, LZ)
129
129
return nothing
130
130
end
131
131
132
132
"""
133
- apply_x_east_bc !(Gc, loc, east_flux::BC{<:Flux}, j, k, grid, args...)
133
+ compute_x_east_bc !(Gc, loc, east_flux::BC{<:Flux}, j, k, grid, args...)
134
134
135
135
Add the part of flux divergence associated with a east boundary condition on `c`.
136
136
Note that because
@@ -144,19 +144,19 @@ If `east_bc.condition` is a function, the function must have the signature
144
144
145
145
The same logic holds for north and top boundary conditions in `y`, and `z`, respectively.
146
146
"""
147
- @inline function apply_x_east_bc ! (Gc, loc, east_flux:: BC{<:Flux} , j, k, grid, args... )
147
+ @inline function compute_x_east_bc ! (Gc, loc, east_flux:: BC{<:Flux} , j, k, grid, args... )
148
148
LX, LY, LZ = loc
149
149
@inbounds Gc[grid. Nx, j, k] -= getbc (east_flux, j, k, grid, args... ) * Ax (grid. Nx+ 1 , j, k, grid, flip (LX), LY, LZ) / volume (grid. Nx, j, k, grid, LX, LY, LZ)
150
150
return nothing
151
151
end
152
152
153
- @inline function apply_y_north_bc ! (Gc, loc, north_flux:: BC{<:Flux} , i, k, grid, args... )
153
+ @inline function compute_y_north_bc ! (Gc, loc, north_flux:: BC{<:Flux} , i, k, grid, args... )
154
154
LX, LY, LZ = loc
155
155
@inbounds Gc[i, grid. Ny, k] -= getbc (north_flux, i, k, grid, args... ) * Ay (i, grid. Ny+ 1 , k, grid, LX, flip (LY), LZ) / volume (i, grid. Ny, k, grid, LX, LY, LZ)
156
156
return nothing
157
157
end
158
158
159
- @inline function apply_z_top_bc ! (Gc, loc, top_flux:: BC{<:Flux} , i, j, grid, args... )
159
+ @inline function compute_z_top_bc ! (Gc, loc, top_flux:: BC{<:Flux} , i, j, grid, args... )
160
160
LX, LY, LZ = loc
161
161
@inbounds Gc[i, j, grid. Nz] -= getbc (top_flux, i, j, grid, args... ) * Az (i, j, grid. Nz+ 1 , grid, LX, LY, flip (LZ)) / volume (i, j, grid. Nz, grid, LX, LY, LZ)
162
162
return nothing
0 commit comments