From a4ec87b7f9003051019d3e126db682df57b7453e Mon Sep 17 00:00:00 2001 From: utkuyilmaz1903 Date: Mon, 6 Apr 2026 15:27:27 +0300 Subject: [PATCH] Fix #67: Add offset methods for boundaries and include dispatch tests --- src/parse_boundaries.jl | 4 ++++ test/runtests.jl | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/parse_boundaries.jl b/src/parse_boundaries.jl index 2d3c3ec..5cf82ba 100644 --- a/src/parse_boundaries.jl +++ b/src/parse_boundaries.jl @@ -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) diff --git a/test/runtests.jl b/test/runtests.jl index f818d29..250ed29 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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