Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
231:fbabfd4e8f20 | 291:0f94dc29c4bf |
---|---|
28 | 28 |
29 Base.convert(::Type{T}, i::Index{R,T} where R) where T = i.i | 29 Base.convert(::Type{T}, i::Index{R,T} where R) where T = i.i |
30 Base.convert(::Type{CartesianIndex}, I::NTuple{N,Index} where N) = CartesianIndex(convert.(Int, I)) | 30 Base.convert(::Type{CartesianIndex}, I::NTuple{N,Index} where N) = CartesianIndex(convert.(Int, I)) |
31 | 31 |
32 Base.Int(I::Index) = I.i | 32 Base.Int(I::Index) = I.i |
33 Base.to_index(I::Index) = Int(I) #How to get this to work for all cases?? | |
34 Base.getindex(A::AbstractArray{T,N}, I::NTuple{N,Index}) where {T,N} = A[I...] #Is this ok?? | |
33 | 35 |
34 function Index(i::Integer, boundary_width::Integer, dim_size::Integer) | 36 function Index(i::Integer, boundary_width::Integer, dim_size::Integer) |
35 return Index{getregion(i,boundary_width,dim_size)}(i) | 37 return Index{getregion(i,boundary_width,dim_size)}(i) |
36 end | 38 end |
37 | 39 |
63 else | 65 else |
64 error("Bounds error") # TODO: Make this more standard | 66 error("Bounds error") # TODO: Make this more standard |
65 end | 67 end |
66 end | 68 end |
67 | 69 |
70 export getregion | |
71 | |
68 function getrange(gridsize::Integer, closuresize::Integer, region::DataType) | 72 function getrange(gridsize::Integer, closuresize::Integer, region::DataType) |
69 if region == Lower | 73 if region == Lower |
70 r = 1:closuresize | 74 r = 1:closuresize |
71 elseif region == Interior | 75 elseif region == Interior |
72 r = (closuresize+1):(gridsize - closuresize) | 76 r = (closuresize+1):(gridsize - closuresize) |