changeset 89:c0729ade65da patch_based_test

Merge with default
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 25 Jan 2019 16:47:51 +0100
parents 170e5447bc19 (current diff) 48079bd39969 (diff)
children 2882e1318cc3
files diffOp.jl sbpD2.jl stencil.jl
diffstat 2 files changed, 7 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/diffOp.jl	Fri Jan 25 15:10:41 2019 +0100
+++ b/diffOp.jl	Fri Jan 25 16:47:51 2019 +0100
@@ -33,10 +33,10 @@
 end
 
 # Differential operator for a*d^2/dx^2
-struct Laplace{Dim, T<:Real} <: DiffOp
+struct Laplace{Dim,T<:Real,N,M,K} <: DiffOp
     grid::Grid.EquidistantGrid{Dim,T}
     a::T
-    op::D2{Float64}
+    op::D2{Float64,N,M,K}
 end
 
 # u = L*v
@@ -63,7 +63,7 @@
         @inbounds indices = uview(li,i,:)
         @inbounds apply!(L.op, temp, uview(v, indices), h[2])
         for i ∈ eachindex(indices)
-            @inbounds u[indices[i]] += temp[i]
+            @inbounds u[indices[i]] = temp[i]
         end
     end
 
--- a/stencil.jl	Fri Jan 25 15:10:41 2019 +0100
+++ b/stencil.jl	Fri Jan 25 16:47:51 2019 +0100
@@ -1,18 +1,11 @@
-struct Stencil{T<:Real}
-    range::NTuple{2,Int}
-    weights::Vector{T} # TBD: Should this be a tuple?
-    function Stencil(range, weights)
-        width = range[2]-range[1]+1
-        if width != length(weights)
-            error("The width and the number of weights must be the same")
-        end
-        new{eltype(weights)}(range, weights)
-    end
+struct Stencil{T<:Real,N}
+    range::Tuple{Int,Int}
+    weights::NTuple{N,T}
 end
 
 function flip(s::Stencil)
     range = (-s.range[2], -s.range[1])
-    s = Stencil(range, s.weights[end:-1:1])
+    return Stencil(range, reverse(s.weights))
 end
 
 # Provides index into the Stencil based on offset for the root element