Mercurial > repos > public > sbplib_julia
comparison diffOp.jl @ 78:fbf7398f8154 cell_based_test
Inline and inbounds everything
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Thu, 24 Jan 2019 14:38:14 +0100 |
parents | e4fa13137d12 |
children | b795ec7f9ca0 |
comparison
equal
deleted
inserted
replaced
70:e4fa13137d12 | 78:fbf7398f8154 |
---|---|
59 uᵢ = L.a * apply(L.op, h, v, i) | 59 uᵢ = L.a * apply(L.op, h, v, i) |
60 return uᵢ | 60 return uᵢ |
61 end | 61 end |
62 | 62 |
63 # u = L*v | 63 # u = L*v |
64 function apply(L::Laplace{2}, v::AbstractVector, i::Int) | 64 @inline function apply(L::Laplace{2}, v::AbstractVector, i::Int) |
65 h = Grid.spacings(L.grid) | 65 h = Grid.spacings(L.grid) |
66 | 66 |
67 li = LinearIndices(L.grid.numberOfPointsPerDim) | 67 li = LinearIndices(L.grid.numberOfPointsPerDim) |
68 ci = CartesianIndices(L.grid.numberOfPointsPerDim) | 68 ci = CartesianIndices(L.grid.numberOfPointsPerDim) |
69 I = ci[i] | 69 I = ci[i] |
70 | 70 |
71 # 2nd x-derivative | 71 # 2nd x-derivative |
72 vx = view(v, view(li,:,I[2])) | 72 vx = @inbounds view(v, view(li,:,I[2])) |
73 uᵢ = apply(L.op, h[1], vx , I[1]) | 73 uᵢ = apply(L.op, h[1], vx , I[1]) |
74 # 2nd y-derivative | 74 # 2nd y-derivative |
75 vy = view(v, view(li,I[1],:)) | 75 vy = @inbounds view(v, view(li,I[1],:)) |
76 uᵢ += apply(L.op, h[2], vy, I[2]) | 76 uᵢ += apply(L.op, h[2], vy, I[2]) |
77 | 77 |
78 return uᵢ | 78 return uᵢ |
79 end | 79 end |