changeset 98:50273f745f05 cell_based_test

Add "Unknown" region and implement D2 for it
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 06 Feb 2019 08:58:32 +0100
parents 8324c82c2dfb
children 6b6d680f2e25
files index.jl sbpD2.jl
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/index.jl	Tue Feb 05 22:30:46 2019 +0100
+++ b/index.jl	Wed Feb 06 08:58:32 2019 +0100
@@ -2,6 +2,7 @@
 struct Interior <: Region end
 struct Lower    <: Region end
 struct Upper    <: Region end
+struct Unknown  <: Region end
 
 struct Index{R<:Region, T<:Integer}
     i::T
--- a/sbpD2.jl	Tue Feb 05 22:30:46 2019 +0100
+++ b/sbpD2.jl	Wed Feb 06 08:58:32 2019 +0100
@@ -1,6 +1,6 @@
 abstract type ConstantStencilOperator end
 
-# Apply for different regions Lower/Interior/Upper
+# 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
 end
@@ -14,11 +14,12 @@
     return @inbounds Int(op.parity)*apply(flip(op.closureStencils[N-Int(i)+1]), v, Int(i))/h^2
 end
 
-# Wrapper functions for using regular indecies without specifying regions
-@inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int)
+@inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, index::Index{Unknown})
     cSize = closureSize(op)
     N = length(v)
 
+    i = Int(index)
+
     if 0 < i <= cSize
         return apply(op, h, v, Index{Lower}(i))
     elseif cSize < i <= N-cSize
@@ -30,6 +31,11 @@
     end
 end
 
+# Wrapper functions for using regular indecies without specifying regions
+@inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int)
+    return apply(op, h, v, Index{Unknown}(i))
+end
+
 @enum Parity begin
     odd = -1
     even = 1