diff RegionIndices/src/RegionIndices.jl @ 291:0f94dc29c4bf

Merge in branch boundary_conditions
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 22 Jun 2020 21:43:05 +0200
parents 21e5c1dd6794
children
line wrap: on
line diff
--- a/RegionIndices/src/RegionIndices.jl	Wed Jun 26 15:07:47 2019 +0200
+++ b/RegionIndices/src/RegionIndices.jl	Mon Jun 22 21:43:05 2020 +0200
@@ -30,6 +30,8 @@
 Base.convert(::Type{CartesianIndex}, I::NTuple{N,Index} where N) = CartesianIndex(convert.(Int, I))
 
 Base.Int(I::Index) = I.i
+Base.to_index(I::Index) = Int(I) #How to get this to work for all cases??
+Base.getindex(A::AbstractArray{T,N}, I::NTuple{N,Index}) where {T,N} = A[I...] #Is this ok??
 
 function Index(i::Integer, boundary_width::Integer, dim_size::Integer)
     return Index{getregion(i,boundary_width,dim_size)}(i)
@@ -65,6 +67,8 @@
     end
 end
 
+export getregion
+
 function getrange(gridsize::Integer, closuresize::Integer, region::DataType)
     if region == Lower
         r = 1:closuresize