Mercurial > repos > public > sbplib_julia
diff src/SbpOperators/stencil.jl @ 868:e37ee63bf9ac feature/variable_derivatives
Add some tests and fix some bugs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 20 Jan 2022 10:23:15 +0100 |
parents | 313648b01504 |
children | 011d3ff65e9f |
line wrap: on
line diff
--- a/src/SbpOperators/stencil.jl Wed Jan 19 21:49:34 2022 +0100 +++ b/src/SbpOperators/stencil.jl Thu Jan 20 10:23:15 2022 +0100 @@ -88,7 +88,7 @@ NestedStencil(s::Vararg{Stencil}; center) = NestedStencil(Stencil(s... ; center)) function NestedStencil(weights::Vararg{Tuple}; center) - inner_stencils = map((w,c) -> Stencil(w...,center=c), weights, 1:length(weights)) + inner_stencils = map(w -> Stencil(w...; center), weights) return NestedStencil(Stencil(inner_stencils... ; center)) end @@ -104,25 +104,25 @@ Base.getindex(ns::NestedStencil, i::Int) = ns.s[i] "Apply inner stencils to `c` and get a concrete stencil" -Base.@propagate_inbounds function apply_stencil(ns::NestedStencil, c::AbstractVector, i::Int) +Base.@propagate_inbounds function apply_inner_stencils(ns::NestedStencil, c::AbstractVector, i::Int) weights = apply_stencil.(ns.s.weights, Ref(c), i) return Stencil(ns.s.range, weights) end "Apply the whole nested stencil" Base.@propagate_inbounds function apply_stencil(ns::NestedStencil, c::AbstractVector, v::AbstractVector, i::Int) - s = apply_stencil(ns,c,i) + s = apply_inner_stencils(ns,c,i) return apply_stencil(s, v, i) end "Apply inner stencils backwards to `c` and get a concrete stencil" -Base.@propagate_inbounds @inline function apply_stencil_backwards(ns::NestedStencil, c::AbstractVector, v::AbstractVector, i::Int) +Base.@propagate_inbounds @inline function apply_inner_stencils_backwards(ns::NestedStencil, c::AbstractVector, i::Int) weights = apply_stencil_backwards.(ns.s.weights, Ref(c), i) return Stencil(ns.s.range, weights) end "Apply the whole nested stencil backwards" Base.@propagate_inbounds @inline function apply_stencil_backwards(ns::NestedStencil, c::AbstractVector, v::AbstractVector, i::Int) - s = apply_stencil_backwards(ns,c,i) + s = apply_inner_stencils_backwards(ns,c,i) return apply_stencil_backwards(s, v, i) end