diff diffOp.jl @ 124:631eb9b35d72 cell_based_test

Make grid spacing a property of EquidistantGrid. Create plotting module for sbplib.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 13 Feb 2019 10:37:52 +0100
parents 4c0c02a80cd4
children 1aaeb46ba5f4
line wrap: on
line diff
--- a/diffOp.jl	Tue Feb 12 15:18:18 2019 +0100
+++ b/diffOp.jl	Wed Feb 13 10:37:52 2019 +0100
@@ -59,9 +59,7 @@
 
 # Maybe this should be split according to b3fbef345810 after all?! Seems like it makes performance more predictable
 function apply_region!(D::DiffOpCartesian{2}, u::AbstractArray{T,2}, v::AbstractArray{T,2}, r1::Type{<:Region}, r2::Type{<:Region}) where T
-    N = D.grid.numberOfPointsPerDim
-    closuresize = closureSize(D.op)
-    for I ∈ regionindices(N, closuresize, (r1,r2))
+    for I ∈ regionindices(D.grid.size, closureSize(D.op), (r1,r2))
         @inbounds indextuple = (Index{r1}(I[1]), Index{r2}(I[2]))
         @inbounds u[I] = apply(D, v, indextuple)
     end
@@ -83,10 +81,7 @@
 
 using TiledIteration
 function apply_region_tiled!(D::DiffOpCartesian{2}, u::AbstractArray{T,2}, v::AbstractArray{T,2}, r1::Type{<:Region}, r2::Type{<:Region}) where T
-    N = D.grid.numberOfPointsPerDim
-    closuresize = closureSize(D.op)
-    ri = regionindices(N, closuresize, (r1,r2))
-
+    ri = regionindices(D.grid.size, closureSize(D.op), (r1,r2))
     for tileaxs ∈ TileIterator(axes(ri), padded_tilesize(T, (5,5), 2)) # TBD: Is this the right way, the right size?
         for j ∈ tileaxs[2], i ∈ tileaxs[1]
             I = ri[i,j]
@@ -114,19 +109,17 @@
 
 # u = L*v
 function apply(L::Laplace{1}, v::AbstractVector, i::Int)
-    h = Grid.spacings(L.grid)[1]
-    uᵢ = L.a * apply(L.op, h, v, i)
+    uᵢ = L.a * apply(L.op, L.grid.spacing[1], v, i)
     return uᵢ
 end
 
 function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2}
-    h = Grid.spacings(L.grid)
     # 2nd x-derivative
     @inbounds vx = view(v, :, Int(I[2]))
-    @inbounds uᵢ = L.a*apply(L.op, h[1], vx , I[1])
+    @inbounds uᵢ = L.a*apply(L.op, L.grid.spacing[1], vx , I[1])
     # 2nd y-derivative
     @inbounds vy = view(v, Int(I[1]), :)
-    @inbounds uᵢ += L.a*apply(L.op, h[2], vy, I[2])
+    @inbounds uᵢ += L.a*apply(L.op, L.grid.spacing[2], vy, I[2])
     return uᵢ
 end