changeset 43:ef060ab3b035

remove stride and remove some bugs
author Ylva Rydin <ylva.rydin@telia.com>
date Thu, 10 Jan 2019 16:30:54 +0100
parents 8b04efde1a46
children f03e50edd60f
files diffOp.jl sbpD2.jl stencil.jl
diffstat 3 files changed, 16 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/diffOp.jl	Thu Jan 10 15:53:44 2019 +0100
+++ b/diffOp.jl	Thu Jan 10 16:30:54 2019 +0100
@@ -30,11 +30,7 @@
 
 # u = L*v
 function apply!(L::Laplace1D, u::AbstractVector, v::AbstractVector)
-    N = closureSize(L.op)
-    M = length(v)
-
-    h = scaling(L.grid)
-
-    apply!(L.op, u, v, grid.spacings(L.grid)[1], 1, L.grid.numberOfPointsPerDim, stride=1)
+    h = grid.spacings(L.grid)[1]
+    apply!(L.op, u, v, h)
     return nothing
 end
--- a/sbpD2.jl	Thu Jan 10 15:53:44 2019 +0100
+++ b/sbpD2.jl	Thu Jan 10 16:30:54 2019 +0100
@@ -1,20 +1,21 @@
 abstract type ConstantStencilOperator end
 
-function apply!(op::ConstantStencilOperator, u::AbstractVector, v::AbstractVector, h::Real, start::Int, N::Int; stride::Int=1)
+function apply!(op::ConstantStencilOperator, u::AbstractVector, v::AbstractVector, h::Real)
+    N = length(v)
     cSize = closureSize(op)
 
-    for i ∈ range(start; length=cSize, step=stride)
-        u[i] = apply!(op.closureStencils[i], v, i; stride=stride)/h^2
+    for i ∈ range(1; length=cSize)
+        u[i] = apply(op.closureStencils[i], v, i)/h^2
     end
 
-    innerStart = start + cSize*stride
-    innerEnd = N - cSize*stride-1
-    for i ∈ range(innerStart, stop=innerEnd, step=stride)
-        u[i] = apply(op.innerStencil, v, i; stride=stride)/h^2
+    innerStart = 1 + cSize
+    innerEnd = N - cSize
+    for i ∈ range(innerStart, stop=innerEnd)
+        u[i] = apply(op.innerStencil, v, i)/h^2
     end
 
-    for i ∈ range(innerEnd+1, length=cSize, step=cSize)
-        u[i] = op.parity*apply(flip(op.closureStencils[M-i+1]), v, i; stride=stride)/h^2
+    for i ∈ range(innerEnd+1, length=cSize)
+        u[i] = op.parity*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2
     end
 end
 
@@ -31,7 +32,7 @@
 end
 
 function closureSize(D::D2)::Int
-    return length(quadratureClosure)
+    return length(D.quadratureClosure)
 end
 
 function readOperator(D2fn, Hfn)
--- a/stencil.jl	Thu Jan 10 15:53:44 2019 +0100
+++ b/stencil.jl	Thu Jan 10 16:30:54 2019 +0100
@@ -24,10 +24,10 @@
     end
 end
 
-function apply(s::Stencil, v::AbstractVector, i::Int; stride::Int = 1)
+function apply(s::Stencil, v::AbstractVector, i::Int)
     w = zero(eltype(v))
-    for j ∈ i .+ stride.*(s.range[1]:s.range[2])
-        w += v[j]
+    for j ∈ s.range[1]:s.range[2]
+        w += s[j]*v[i+j]
     end
     return w
 end