comparison src/SbpOperators/stencil.jl @ 894:54e36688dab8 feature/variable_derivatives

Add functions for converting the element type of nested stencils
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 10 Feb 2022 10:57:00 +0100
parents 0be29e65521e
children 004324d7ed35
comparison
equal deleted inserted replaced
893:422c9f22cf92 894:54e36688dab8
100 function CenteredNestedStencil(weights::Vararg{NTuple{N,T}}) where {T,N} 100 function CenteredNestedStencil(weights::Vararg{NTuple{N,T}}) where {T,N}
101 inner_stencils = map(w->CenteredStencil(w...), weights) 101 inner_stencils = map(w->CenteredStencil(w...), weights)
102 return CenteredNestedStencil(inner_stencils...) 102 return CenteredNestedStencil(inner_stencils...)
103 end 103 end
104 104
105
106 # Conversion
107 function NestedStencil{T}(ns::NestedStencil) where T
108 return NestedStencil(Stencil{Stencil{T}}(ns.s))
109 end
110
111 Base.convert(::Type{NestedStencil{T}}, stencil) where T = NestedStencil{T}(stencil)
112
105 Base.eltype(::NestedStencil{T}) where T = T 113 Base.eltype(::NestedStencil{T}) where T = T
106 114
107 function flip(ns::NestedStencil) 115 function flip(ns::NestedStencil)
108 s_flip = flip(ns.s) 116 s_flip = flip(ns.s)
109 return NestedStencil(Stencil(s_flip.range, flip.(s_flip.weights))) 117 return NestedStencil(Stencil(s_flip.range, flip.(s_flip.weights)))