comparison SbpOperators/src/stencil.jl @ 269:ccef055233a2 boundary_conditions

Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 05 Dec 2019 10:48:31 +0100
parents 69a6049e14d9
children
comparison
equal deleted inserted replaced
268:f67ce2eb6019 269:ccef055233a2
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