@@ -29,20 +29,21 @@ Base.@propagate_inbounds function fd_operator_fill_shmem!(
29
29
arg,
30
30
)
31
31
@inbounds begin
32
- vt = threadIdx (). x
32
+ si = ShmemIndex ()
33
+ bi = FDShmemBoundaryIndex ()
33
34
lg = Geometry. LocalGeometry (space, idx, hidx)
34
35
if ! on_boundary (idx, space, op)
35
36
u³ = Operators. getidx (space, arg, idx, hidx)
36
- Ju³[vt ] = Geometry. Jcontravariant3 (u³, lg)
37
+ Ju³[si ] = Geometry. Jcontravariant3 (u³, lg)
37
38
elseif on_left_boundary (idx, space, op)
38
39
bloc = Operators. left_boundary_window (space)
39
40
bc = Operators. get_boundary (op, bloc)
40
41
ub = Operators. getidx (space, bc. val, nothing , hidx)
41
42
bJu³ = on_left_boundary (idx, space) ? lJu³ : rJu³
42
43
if bc isa Operators. SetValue
43
- bJu³[1 ] = Geometry. Jcontravariant3 (ub, lg)
44
+ bJu³[bi ] = Geometry. Jcontravariant3 (ub, lg)
44
45
elseif bc isa Operators. SetDivergence
45
- bJu³[1 ] = ub
46
+ bJu³[bi ] = ub
46
47
elseif bc isa Operators. Extrapolate # no shmem needed
47
48
end
48
49
elseif on_right_boundary (idx, space, op)
@@ -51,9 +52,9 @@ Base.@propagate_inbounds function fd_operator_fill_shmem!(
51
52
ub = Operators. getidx (space, bc. val, nothing , hidx)
52
53
bJu³ = on_left_boundary (idx, space) ? lJu³ : rJu³
53
54
if bc isa Operators. SetValue
54
- bJu³[1 ] = Geometry. Jcontravariant3 (ub, lg)
55
+ bJu³[bi ] = Geometry. Jcontravariant3 (ub, lg)
55
56
elseif bc isa Operators. SetDivergence
56
- bJu³[1 ] = ub
57
+ bJu³[bi ] = ub
57
58
elseif bc isa Operators. Extrapolate # no shmem needed
58
59
end
59
60
end
@@ -70,11 +71,12 @@ Base.@propagate_inbounds function fd_operator_evaluate(
70
71
arg,
71
72
)
72
73
@inbounds begin
73
- vt = threadIdx (). x
74
+ si = ShmemIndex ()
75
+ bi = FDShmemBoundaryIndex ()
74
76
lg = Geometry. LocalGeometry (space, idx, hidx)
75
77
if ! on_boundary (idx, space, op)
76
- Ju³₋ = Ju³[vt ] # corresponds to idx - half
77
- Ju³₊ = Ju³[vt + 1 ] # corresponds to idx + half
78
+ Ju³₋ = Ju³[si ] # corresponds to idx - half
79
+ Ju³₊ = Ju³[si + 1 ] # corresponds to idx + half
78
80
return (Ju³₊ ⊟ Ju³₋) ⊠ lg. invJ
79
81
else
80
82
bloc =
@@ -85,22 +87,22 @@ Base.@propagate_inbounds function fd_operator_evaluate(
85
87
@assert bc isa Operators. SetValue || bc isa Operators. SetDivergence
86
88
if on_left_boundary (idx, space)
87
89
if bc isa Operators. SetValue
88
- Ju³₋ = lJu³[1 ] # corresponds to idx - half
89
- Ju³₊ = Ju³[vt + 1 ] # corresponds to idx + half
90
+ Ju³₋ = lJu³[bi ] # corresponds to idx - half
91
+ Ju³₊ = Ju³[si + 1 ] # corresponds to idx + half
90
92
return (Ju³₊ ⊟ Ju³₋) ⊠ lg. invJ
91
93
else
92
94
# @assert bc isa Operators.SetDivergence
93
- return lJu³[1 ]
95
+ return lJu³[bi ]
94
96
end
95
97
else
96
98
@assert on_right_boundary (idx, space)
97
99
if bc isa Operators. SetValue
98
- Ju³₋ = Ju³[vt ] # corresponds to idx - half
99
- Ju³₊ = rJu³[1 ] # corresponds to idx + half
100
+ Ju³₋ = Ju³[si ] # corresponds to idx - half
101
+ Ju³₊ = rJu³[bi ] # corresponds to idx + half
100
102
return (Ju³₊ ⊟ Ju³₋) ⊠ lg. invJ
101
103
else
102
104
@assert bc isa Operators. SetDivergence
103
- return rJu³[1 ]
105
+ return rJu³[bi ]
104
106
end
105
107
end
106
108
end
@@ -133,10 +135,11 @@ Base.@propagate_inbounds function fd_operator_fill_shmem!(
133
135
)
134
136
@inbounds begin
135
137
is_out_of_bounds (idx, space) && return nothing
136
- vt = threadIdx (). x
138
+ si = ShmemIndex ()
139
+ bi = FDShmemBoundaryIndex ()
137
140
cov3 = Geometry. Covariant3Vector (1 )
138
141
if in_domain (idx, arg_space)
139
- u[vt ] = cov3 ⊗ Operators. getidx (space, arg, idx, hidx)
142
+ u[si ] = cov3 ⊗ Operators. getidx (space, arg, idx, hidx)
140
143
end
141
144
if on_any_boundary (idx, space, op)
142
145
lloc = Operators. left_boundary_window (space)
@@ -149,10 +152,10 @@ Base.@propagate_inbounds function fd_operator_fill_shmem!(
149
152
ub = Operators. getidx (space, bc. val, nothing , hidx)
150
153
bu = on_left_boundary (idx, space) ? lb : rb
151
154
if bc isa Operators. SetValue
152
- bu[1 ] = cov3 ⊗ ub
155
+ bu[bi ] = cov3 ⊗ ub
153
156
elseif bc isa Operators. SetGradient
154
157
lg = Geometry. LocalGeometry (space, idx, hidx)
155
- bu[1 ] = Geometry. project (Geometry. Covariant3Axis (), ub, lg)
158
+ bu[bi ] = Geometry. project (Geometry. Covariant3Axis (), ub, lg)
156
159
elseif bc isa Operators. Extrapolate # no shmem needed
157
160
end
158
161
end
@@ -169,11 +172,12 @@ Base.@propagate_inbounds function fd_operator_evaluate(
169
172
args... ,
170
173
)
171
174
@inbounds begin
172
- vt = threadIdx (). x
175
+ si = ShmemIndex ()
176
+ bi = FDShmemBoundaryIndex ()
173
177
lg = Geometry. LocalGeometry (space, idx, hidx)
174
178
if ! on_boundary (idx, space, op)
175
- u₋ = u[vt - 1 ] # corresponds to idx - half
176
- u₊ = u[vt ] # corresponds to idx + half
179
+ u₋ = u[si - 1 ] # corresponds to idx - half
180
+ u₊ = u[si ] # corresponds to idx + half
177
181
return u₊ ⊟ u₋
178
182
else
179
183
bloc =
@@ -184,15 +188,15 @@ Base.@propagate_inbounds function fd_operator_evaluate(
184
188
@assert bc isa Operators. SetValue
185
189
if on_left_boundary (idx, space)
186
190
if bc isa Operators. SetValue
187
- u₋ = 2 * lb[1 ] # corresponds to idx - half
188
- u₊ = 2 * u[vt ] # corresponds to idx + half
191
+ u₋ = 2 * lb[bi ] # corresponds to idx - half
192
+ u₊ = 2 * u[si ] # corresponds to idx + half
189
193
return u₊ ⊟ u₋
190
194
end
191
195
else
192
196
@assert on_right_boundary (idx, space)
193
197
if bc isa Operators. SetValue
194
- u₋ = 2 * u[vt - 1 ] # corresponds to idx - half
195
- u₊ = 2 * rb[1 ] # corresponds to idx + half
198
+ u₋ = 2 * u[si - 1 ] # corresponds to idx - half
199
+ u₊ = 2 * rb[bi ] # corresponds to idx + half
196
200
return u₊ ⊟ u₋
197
201
end
198
202
end
@@ -226,9 +230,10 @@ Base.@propagate_inbounds function fd_operator_fill_shmem!(
226
230
)
227
231
@inbounds begin
228
232
is_out_of_bounds (idx, space) && return nothing
229
- ᶜidx = get_cent_idx (idx)
233
+ si = ShmemIndex (idx)
234
+ bi = FDShmemBoundaryIndex ()
230
235
if in_domain (idx, arg_space)
231
- u[idx ] = Operators. getidx (space, arg, idx, hidx)
236
+ u[si ] = Operators. getidx (space, arg, idx, hidx)
232
237
else
233
238
lloc = Operators. left_boundary_window (space)
234
239
rloc = Operators. right_boundary_window (space)
@@ -242,16 +247,16 @@ Base.@propagate_inbounds function fd_operator_fill_shmem!(
242
247
bc isa Operators. NullBoundaryCondition
243
248
if bc isa Operators. NullBoundaryCondition ||
244
249
bc isa Operators. Extrapolate
245
- u[idx ] = Operators. getidx (space, arg, idx, hidx)
250
+ u[si ] = Operators. getidx (space, arg, idx, hidx)
246
251
return nothing
247
252
end
248
253
bu = on_left_boundary (idx, space) ? lb : rb
249
254
ub = Operators. getidx (space, bc. val, nothing , hidx)
250
255
if bc isa Operators. SetValue
251
- bu[1 ] = ub
256
+ bu[bi ] = ub
252
257
elseif bc isa Operators. SetGradient
253
258
lg = Geometry. LocalGeometry (space, idx, hidx)
254
- bu[1 ] = Geometry. covariant3 (ub, lg)
259
+ bu[bi ] = Geometry. covariant3 (ub, lg)
255
260
end
256
261
end
257
262
end
@@ -270,9 +275,11 @@ Base.@propagate_inbounds function fd_operator_evaluate(
270
275
vt = threadIdx (). x
271
276
lg = Geometry. LocalGeometry (space, idx, hidx)
272
277
ᶜidx = get_cent_idx (idx)
278
+ si = ShmemIndex (ᶜidx)
279
+ bi = FDShmemBoundaryIndex ()
273
280
if ! on_boundary (idx, space, op)
274
- u₋ = u[ᶜidx - 1 ] # corresponds to idx - half
275
- u₊ = u[ᶜidx ] # corresponds to idx + half
281
+ u₋ = u[si - 1 ] # corresponds to idx - half
282
+ u₊ = u[si ] # corresponds to idx + half
276
283
return RecursiveApply. rdiv (u₊ ⊞ u₋, 2 )
277
284
else
278
285
bloc =
@@ -285,26 +292,26 @@ Base.@propagate_inbounds function fd_operator_evaluate(
285
292
bc isa Operators. Extrapolate
286
293
if on_left_boundary (idx, space)
287
294
if bc isa Operators. SetValue
288
- return lb[1 ]
295
+ return lb[bi ]
289
296
elseif bc isa Operators. SetGradient
290
- u₋ = lb[1 ] # corresponds to idx - half
291
- u₊ = u[ᶜidx ] # corresponds to idx + half
297
+ u₋ = lb[bi ] # corresponds to idx - half
298
+ u₊ = u[si ] # corresponds to idx + half
292
299
return u₊ ⊟ RecursiveApply. rdiv (u₋, 2 )
293
300
else
294
301
@assert bc isa Operators. Extrapolate
295
- return u[ᶜidx ]
302
+ return u[si ]
296
303
end
297
304
else
298
305
@assert on_right_boundary (idx, space)
299
306
if bc isa Operators. SetValue
300
- return rb[1 ]
307
+ return rb[bi ]
301
308
elseif bc isa Operators. SetGradient
302
- u₋ = u[ᶜidx - 1 ] # corresponds to idx - half
303
- u₊ = rb[1 ] # corresponds to idx + half
309
+ u₋ = u[si - 1 ] # corresponds to idx - half
310
+ u₊ = rb[bi ] # corresponds to idx + half
304
311
return u₋ ⊞ RecursiveApply. rdiv (u₊, 2 )
305
312
else
306
313
@assert bc isa Operators. Extrapolate
307
- return u[ᶜidx - 1 ]
314
+ return u[si - 1 ]
308
315
end
309
316
end
310
317
end
0 commit comments