diff sbpD2.jl @ 93:93df72e2b135 stencil_index

Implement apply for 2D-Laplace which takes an StencilIndex as input
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 04 Feb 2019 09:13:48 +0100
parents c0f33eccd527
children 84b1ad5a3755
line wrap: on
line diff
--- a/sbpD2.jl	Mon Feb 04 09:11:53 2019 +0100
+++ b/sbpD2.jl	Mon Feb 04 09:13:48 2019 +0100
@@ -15,15 +15,16 @@
     return uᵢ
 end
 
-Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::InteriorIndex)
-    return apply(op.innerStencil, v, i)/h^2
+Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int, ::InteriorIndex)
+    return apply(op.innerStencil, v,  i)/h^2
 end
 
-Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::LowerClosureIndex)
+Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int, ::LowerClosureIndex)
     return apply(op.closureStencils[i], v, i)/h^2
 end
 
-Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::UpperClosureIndex)
+Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int, ::UpperClosureIndex)
+    N = length(v)
     return Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 #TODO: Write an applybackwards instead?
 end