comparison src/SbpOperators/stencil.jl @ 879:011d3ff65e9f feature/variable_derivatives

Add methods for CenteredNestedStencil with tuple input
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 20 Jan 2022 14:03:16 +0100
parents e37ee63bf9ac
children f74189c954d6
comparison
equal deleted inserted replaced
878:0fe46190a81a 879:011d3ff65e9f
83 83
84 struct NestedStencil{T,N} 84 struct NestedStencil{T,N}
85 s::Stencil{Stencil{T,N},N} 85 s::Stencil{Stencil{T,N},N}
86 end 86 end
87 87
88 # Stencil input
88 NestedStencil(s::Vararg{Stencil}; center) = NestedStencil(Stencil(s... ; center)) 89 NestedStencil(s::Vararg{Stencil}; center) = NestedStencil(Stencil(s... ; center))
90 CenteredNestedStencil(s::Vararg{Stencil}) = NestedStencil(CenteredStencil(s...))
89 91
92 # Tuple input
90 function NestedStencil(weights::Vararg{Tuple}; center) 93 function NestedStencil(weights::Vararg{Tuple}; center)
91 inner_stencils = map(w -> Stencil(w...; center), weights) 94 inner_stencils = map(w -> Stencil(w...; center), weights)
92 return NestedStencil(Stencil(inner_stencils... ; center)) 95 return NestedStencil(Stencil(inner_stencils... ; center))
93 end 96 end
94 97 function CenteredNestedStencil(weights::Vararg{Tuple})
95 CenteredNestedStencil(s...) = NestedStencil(CenteredStencil(s...)) 98 inner_stencils = map(w->CenteredStencil(w...), weights)
99 return CenteredNestedStencil(inner_stencils...)
100 end
96 101
97 Base.eltype(::NestedStencil{T}) where T = T 102 Base.eltype(::NestedStencil{T}) where T = T
98 103
99 function flip(ns::NestedStencil) 104 function flip(ns::NestedStencil)
100 s_flip = flip(ns.s) 105 s_flip = flip(ns.s)