Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/parse_boundaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ function isupper(::InterfaceBoundary{IsUpper_u}) where {IsUpper_u}
end
isupper(::HigherOrderInterfaceBoundary) = true

offset(::LowerBoundary, i, len) = i
offset(::UpperBoundary, i, len) = len - i + 1
offset(b::AbstractInterfaceBoundary, i, len) = isupper(b) ? len - i + 1 : i

flatten_vardict(bmps) = reduce(vcat, reduce(vcat, collect.(values.(collect(values(bmps))))))

function _boundary_rules(v, orders, u, x, val)
Expand Down
16 changes: 16 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ const is_CI = haskey(ENV, "CI")
end
end

# Verify correct dispatch and calculations for boundary offsets (Resolves #67)
@safetestset "Boundary Type Hierarchy and Offset Dispatch Tests" begin
using Test
using PDEBase

upper_interface = PDEBase.InterfaceBoundary{Val(true), Val(false)}(1, 2, 3, 4, 5)
lower_interface = PDEBase.InterfaceBoundary{Val(false), Val(true)}(1, 2, 3, 4, 5)

@test PDEBase.offset(upper_interface, 2, 10) == 9
@test PDEBase.offset(lower_interface, 2, 10) == 2

@test hasmethod(PDEBase.offset, Tuple{PDEBase.LowerBoundary, Int, Int})
@test hasmethod(PDEBase.offset, Tuple{PDEBase.UpperBoundary, Int, Int})
@test hasmethod(PDEBase.offset, Tuple{PDEBase.HigherOrderInterfaceBoundary, Int, Int})
end

# Run allocation tests in a separate group to avoid precompilation interference
if GROUP == "All" || GROUP == "nopre"
@safetestset "Allocation Tests" begin
Expand Down