comparison SbpOperators/src/stencil.jl @ 291:0f94dc29c4bf

Merge in branch boundary_conditions
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 22 Jun 2020 21:43:05 +0200
parents ccef055233a2
children
comparison
equal deleted inserted replaced
231:fbabfd4e8f20 291:0f94dc29c4bf
19 return eltype(s.weights)(0) 19 return eltype(s.weights)(0)
20 end 20 end
21 return s.weights[1 + i - s.range[1]] 21 return s.weights[1 + i - s.range[1]]
22 end 22 end
23 23
24 Base.@propagate_inbounds @inline function apply(s::Stencil{T,N}, v::AbstractVector, i::Int) where {T,N} 24 Base.@propagate_inbounds @inline function apply_stencil(s::Stencil{T,N}, v::AbstractVector, i::Int) where {T,N}
25 w = s.weights[1]*v[i + s.range[1]] 25 w = s.weights[1]*v[i + s.range[1]]
26 @simd for k ∈ 2:N 26 @simd for k ∈ 2:N
27 w += s.weights[k]*v[i + s.range[1] + k-1] 27 w += s.weights[k]*v[i + s.range[1] + k-1]
28 end 28 end
29 return w 29 return w
30 end 30 end
31 31
32 Base.@propagate_inbounds @inline function apply_backwards(s::Stencil{T,N}, v::AbstractVector, i::Int) where {T,N} 32 Base.@propagate_inbounds @inline function apply_stencil_backwards(s::Stencil{T,N}, v::AbstractVector, i::Int) where {T,N}
33 w = s.weights[N]*v[i - s.range[2]] 33 w = s.weights[N]*v[i - s.range[2]]
34 @simd for k ∈ N-1:-1:1 34 @simd for k ∈ N-1:-1:1
35 w += s.weights[k]*v[i - s.range[1] - k + 1] 35 w += s.weights[k]*v[i - s.range[1] - k + 1]
36 end 36 end
37 return w 37 return w