diff sbpD2.jl @ 129:1aaeb46ba5f4 cell_based_test

Improve efficiency of apply by the following: - Remove divisions in interior loop by storing and multiplying by the reciprocal of grid spacing instead. - Add @inline to apply(::Laplace - Remove initialization of w = 0 in apply(::Stencil) by manually unrolling first iteration of the loop.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 14 Feb 2019 16:25:22 +0100
parents 6c6979ff17f4
children 6b6d921e8f05
line wrap: on
line diff
--- a/sbpD2.jl	Thu Feb 14 12:46:58 2019 +0100
+++ b/sbpD2.jl	Thu Feb 14 16:25:22 2019 +0100
@@ -2,16 +2,16 @@
 
 # Apply for different regions Lower/Interior/Upper or Unknown region
 @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Index{Lower})
-    return @inbounds apply(op.closureStencils[Int(i)], v, Int(i))/h^2
+    return @inbounds h*h*apply(op.closureStencils[Int(i)], v, Int(i))
 end
 
 @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Index{Interior})
-    return @inbounds apply(op.innerStencil, v, Int(i))/h^2
+    return @inbounds h*h*apply(op.innerStencil, v, Int(i))
 end
 
 @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Index{Upper})
     N = length(v)
-    return @inbounds Int(op.parity)*apply_backwards(op.closureStencils[N-Int(i)+1], v, Int(i))/h^2
+    return @inbounds h*h*Int(op.parity)*apply_backwards(op.closureStencils[N-Int(i)+1], v, Int(i))
 end
 
 @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, index::Index{Unknown})