Mercurial > repos > public > sbplib_julia
changeset 1055:df498ce0cf52 feature/nested_stencils
Add methods for CenteredNestedStencil with tuple input
(grafted from 011d3ff65e9f9751507863ec9879c4789f8409dc)
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 20 Jan 2022 14:03:16 +0100 |
parents | ce16519aa7ff |
children | fe83ea1db953 |
files | src/SbpOperators/stencil.jl test/SbpOperators/stencil_test.jl |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/stencil.jl Thu Jan 20 13:35:21 2022 +0100 +++ b/src/SbpOperators/stencil.jl Thu Jan 20 14:03:16 2022 +0100 @@ -85,14 +85,19 @@ s::Stencil{Stencil{T,N},N} end +# Stencil input NestedStencil(s::Vararg{Stencil}; center) = NestedStencil(Stencil(s... ; center)) +CenteredNestedStencil(s::Vararg{Stencil}) = NestedStencil(CenteredStencil(s...)) +# Tuple input function NestedStencil(weights::Vararg{Tuple}; center) inner_stencils = map(w -> Stencil(w...; center), weights) return NestedStencil(Stencil(inner_stencils... ; center)) end - -CenteredNestedStencil(s...) = NestedStencil(CenteredStencil(s...)) +function CenteredNestedStencil(weights::Vararg{Tuple}) + inner_stencils = map(w->CenteredStencil(w...), weights) + return CenteredNestedStencil(inner_stencils...) +end Base.eltype(::NestedStencil{T}) where T = T
--- a/test/SbpOperators/stencil_test.jl Thu Jan 20 13:35:21 2022 +0100 +++ b/test/SbpOperators/stencil_test.jl Thu Jan 20 14:03:16 2022 +0100 @@ -48,6 +48,7 @@ @test NestedStencil(s1,s2,s3, center = 1) == NestedStencil(Stencil(s1,s2,s3, center=1)) @test NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=2) == ns + @test CenteredNestedStencil((-1,1,0),(-1,0,1),(0,-1,1)) == ns @test NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=1) == NestedStencil(Stencil( Stencil(-1, 1, 0; center=1), Stencil(-1, 0, 1; center=1),