comparison src/SbpOperators/stencil.jl @ 903:a7f898b1ce1e feature/variable_derivatives

Fix type instability for stencil application when weights and vector didn't match
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 14 Feb 2022 14:28:48 +0100
parents 18f63f1a0c44
children a3bc90c59e8e
comparison
equal deleted inserted replaced
902:7513c5ace0a2 903:a7f898b1ce1e
67 end 67 end
68 return s.weights[1 + i - s.range[1]] 68 return s.weights[1 + i - s.range[1]]
69 end 69 end
70 70
71 Base.@propagate_inbounds @inline function apply_stencil(s::Stencil, v::AbstractVector, i::Int) 71 Base.@propagate_inbounds @inline function apply_stencil(s::Stencil, v::AbstractVector, i::Int)
72 w = zero(eltype(v)) 72 w = zero(promote_type(eltype(s),eltype(v)))
73 @simd for k ∈ 1:length(s) 73 @simd for k ∈ 1:length(s)
74 w += s.weights[k]*v[i + s.range[k]] 74 w += s.weights[k]*v[i + s.range[k]]
75 end 75 end
76 76
77 return w 77 return w