Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
92:b8c9e2db126f | 93:93df72e2b135 |
---|---|
13 end | 13 end |
14 | 14 |
15 return uᵢ | 15 return uᵢ |
16 end | 16 end |
17 | 17 |
18 Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::InteriorIndex) | 18 Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int, ::InteriorIndex) |
19 return apply(op.innerStencil, v, i)/h^2 | 19 return apply(op.innerStencil, v, i)/h^2 |
20 end | 20 end |
21 | 21 |
22 Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::LowerClosureIndex) | 22 Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int, ::LowerClosureIndex) |
23 return apply(op.closureStencils[i], v, i)/h^2 | 23 return apply(op.closureStencils[i], v, i)/h^2 |
24 end | 24 end |
25 | 25 |
26 Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::UpperClosureIndex) | 26 Base.@propagate_inbounds function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int, ::UpperClosureIndex) |
27 N = length(v) | |
27 return Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 #TODO: Write an applybackwards instead? | 28 return Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 #TODO: Write an applybackwards instead? |
28 end | 29 end |
29 | 30 |
30 @enum Parity begin | 31 @enum Parity begin |
31 odd = -1 | 32 odd = -1 |