Skip to content

Commit e417013

Browse files
Add convenience method in stencils (#2221)
1 parent ba8e3ff commit e417013

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/Operators/finitedifference.jl

+23-6
Original file line numberDiff line numberDiff line change
@@ -3739,6 +3739,27 @@ end
37393739
right_idx(space)
37403740
end
37413741

3742+
@inline function should_call_left_boundary(idx, space, bc, loc)
3743+
(; op) = bc
3744+
return Operators.has_boundary(op, loc) &&
3745+
idx < Operators.left_interior_idx(
3746+
space,
3747+
op,
3748+
Operators.get_boundary(op, loc),
3749+
bc.args...,
3750+
)
3751+
end
3752+
3753+
@inline function should_call_right_boundary(idx, space, bc, loc)
3754+
(; op) = bc
3755+
return Operators.has_boundary(op, loc) &&
3756+
idx > Operators.right_interior_idx(
3757+
space,
3758+
bc.op,
3759+
Operators.get_boundary(bc.op, loc),
3760+
bc.args...,
3761+
)
3762+
end
37423763

37433764
Base.@propagate_inbounds function getidx(
37443765
parent_space,
@@ -3760,9 +3781,7 @@ Base.@propagate_inbounds function getidx(
37603781
)
37613782
space = reconstruct_placeholder_space(axes(bc), parent_space)
37623783
op = bc.op
3763-
if has_boundary(op, loc) &&
3764-
idx <
3765-
left_interior_idx(space, bc.op, get_boundary(bc.op, loc), bc.args...)
3784+
if should_call_left_boundary(idx, space, bc, loc)
37663785
stencil_left_boundary(
37673786
op,
37683787
get_boundary(op, loc),
@@ -3787,9 +3806,7 @@ Base.@propagate_inbounds function getidx(
37873806
)
37883807
op = bc.op
37893808
space = reconstruct_placeholder_space(axes(bc), parent_space)
3790-
if has_boundary(op, loc) &&
3791-
idx >
3792-
right_interior_idx(space, bc.op, get_boundary(bc.op, loc), bc.args...)
3809+
if should_call_right_boundary(idx, space, bc, loc)
37933810
stencil_right_boundary(
37943811
op,
37953812
get_boundary(op, loc),

0 commit comments

Comments
 (0)