Mercurial > repos > public > sbplib_julia
changeset 122:6c6979ff17f4 cell_based_test
Introduce and use apply_backwards for stencils
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 12 Feb 2019 15:18:18 +0100 |
parents | 3560f54e3eb3 |
children | 5df4ccb19476 631eb9b35d72 |
files | sbpD2.jl stencil.jl |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/sbpD2.jl Sun Feb 10 19:16:14 2019 +0100 +++ b/sbpD2.jl Tue Feb 12 15:18:18 2019 +0100 @@ -11,7 +11,7 @@ @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Index{Upper}) N = length(v) - return @inbounds Int(op.parity)*apply(flip(op.closureStencils[N-Int(i)+1]), v, Int(i))/h^2 + return @inbounds Int(op.parity)*apply_backwards(op.closureStencils[N-Int(i)+1], v, Int(i))/h^2 end @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, index::Index{Unknown})
--- a/stencil.jl Sun Feb 10 19:16:14 2019 +0100 +++ b/stencil.jl Tue Feb 12 15:18:18 2019 +0100 @@ -25,3 +25,12 @@ end return w end + +Base.@propagate_inbounds function apply_backwards(s::Stencil, v::AbstractVector, i::Int) + w = zero(eltype(v)) + for j ∈ s.range[2]:-1:s.range[1] + @inbounds weight = s[j] + w += weight*v[i-j] + end + return w +end