Mercurial > repos > public > sbplib_julia
changeset 887:0be29e65521e feature/variable_derivatives
Add length method for stencils
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 07 Feb 2022 14:34:03 +0100 |
parents | 0e170dcc6a9e |
children | e6d8fd5e8268 |
files | src/SbpOperators/stencil.jl test/SbpOperators/stencil_test.jl |
diffstat | 2 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/stencil.jl Mon Feb 07 14:32:29 2022 +0100 +++ b/src/SbpOperators/stencil.jl Mon Feb 07 14:34:03 2022 +0100 @@ -49,7 +49,8 @@ return Stencil(s.range, a.*s.weights) end -Base.eltype(::Stencil{T}) where T = T +Base.eltype(::Stencil{T,N}) where {T,N} = T +Base.length(::Stencil{T,N}) where {T,N} = N function flip(s::Stencil) range = (-s.range[2], -s.range[1])
--- a/test/SbpOperators/stencil_test.jl Mon Feb 07 14:32:29 2022 +0100 +++ b/test/SbpOperators/stencil_test.jl Mon Feb 07 14:34:03 2022 +0100 @@ -9,6 +9,10 @@ @test s isa Stencil{Float64, 5} @test eltype(s) == Float64 + + @test length(s) == 5 + @test length(Stencil((-1,2), (1,2,3,4))) == 4 + @test SbpOperators.scale(s, 2) == Stencil((-2,2), (2.,4.,4.,6.,8.)) @test Stencil(1,2,3,4; center=1) == Stencil((0, 3),(1,2,3,4))