Mercurial > repos > public > sbplib_julia
changeset 2045:8ee4b491c237 bugfix/zero_dim_grid_boundary_ops
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Thu, 05 Feb 2026 22:33:13 +0100 |
| parents | 0e93fc7fb2e2 (diff) b3268d0bd5bc (current diff) |
| children | d864282687a7 |
| files | |
| diffstat | 4 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl Thu Feb 05 22:32:54 2026 +0100 +++ b/src/SbpOperators/boundaryops/boundary_restriction.jl Thu Feb 05 22:33:13 2026 +0100 @@ -25,3 +25,5 @@ converted_stencil = convert(Stencil{eltype(g)}, closure_stencil) return BoundaryOperator(g, converted_stencil, boundary) end + +boundary_restriction(::ZeroDimGrid, stencil_set::StencilSet, boundary) = throw(ArgumentError("ZeroDimGrid has no boundaries"))
--- a/src/SbpOperators/boundaryops/normal_derivative.jl Thu Feb 05 22:32:54 2026 +0100 +++ b/src/SbpOperators/boundaryops/normal_derivative.jl Thu Feb 05 22:33:13 2026 +0100 @@ -28,3 +28,5 @@ scaled_stencil = scale(closure_stencil,h_inv) return BoundaryOperator(g, scaled_stencil, boundary) end + +normal_derivative(::ZeroDimGrid, stencil_set::StencilSet, boundary) = throw(ArgumentError("ZeroDimGrid has no boundaries"))
--- a/test/SbpOperators/boundaryops/boundary_restriction_test.jl Thu Feb 05 22:32:54 2026 +0100 +++ b/test/SbpOperators/boundaryops/boundary_restriction_test.jl Thu Feb 05 22:33:13 2026 +0100 @@ -6,6 +6,7 @@ using Diffinitive.RegionIndices using Diffinitive.SbpOperators: BoundaryOperator, Stencil + @testset "boundary_restriction" begin stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order = 4) e_closure = parse_stencil(stencil_set["e"]["closure"]) @@ -30,6 +31,11 @@ @test e_w isa InflatedTensor @test e_w isa LazyTensor{T,1,2} where T end + + @testset "0D" begin + g = ZeroDimGrid(1) + @test_throws ArgumentError("ZeroDimGrid has no boundaries") boundary_restriction(g, stencil_set, ()) + end end @testset "Application" begin
--- a/test/SbpOperators/boundaryops/normal_derivative_test.jl Thu Feb 05 22:32:54 2026 +0100 +++ b/test/SbpOperators/boundaryops/normal_derivative_test.jl Thu Feb 05 22:33:13 2026 +0100 @@ -30,6 +30,11 @@ @test d_w isa LazyTensor{T,1,2} where T @test d_n isa LazyTensor{T,1,2} where T end + + @testset "0D" begin + g = ZeroDimGrid(1) + @test_throws ArgumentError("ZeroDimGrid has no boundaries") normal_derivative(g, stencil_set, ()) + end end @testset "Accuracy" begin v = eval_on(g_2D, (x,y)-> x^2 + (y-1)^2 + x*y)
