Mercurial > repos > public > sbplib_julia
diff StencilIndex.jl @ 93:93df72e2b135 stencil_index
Implement apply for 2D-Laplace which takes an StencilIndex as input
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 04 Feb 2019 09:13:48 +0100 |
parents | c0f33eccd527 |
children | 84b1ad5a3755 |
line wrap: on
line diff
--- a/StencilIndex.jl Mon Feb 04 09:11:53 2019 +0100 +++ b/StencilIndex.jl Mon Feb 04 09:13:48 2019 +0100 @@ -1,21 +1,25 @@ abstract type StencilIndex end function Base.getindex(si::StencilIndex, i::Int) - return si.index[i] + return si.gridindex[i] end struct LowerClosureIndex <: StencilIndex - index::CartesianIndex + globalindex::Integer + gridindex::CartesianIndex end -struct UpperClosureIndex <: StencilIndex - index::CartesianIndex +struct UpperClosureIndex <: StencilIndex + globalindex::Integer + gridindex::CartesianIndex end -struct InteriorIndex <: StencilIndex - index::CartesianIndex +struct InteriorIndex <: StencilIndex + globalindex::Integer + gridindex::CartesianIndex end +# TODO: The design of StencilIndex is wrong. Use Jonatans design instead. # TODO: This should take a Stencil or DiffOp so that we can extract all the # indices in the closures. # TODO: Where to place this function? @@ -27,16 +31,14 @@ islower = x -> (x == 1) isupper = x -> (x in grid.numberOfPointsPerDim) ci = CartesianIndices(grid.numberOfPointsPerDim) - for i ∈ ci - I = Tuple(i) + for i ∈ 1:Grid.numberOfPoints(grid) + I = Tuple(ci[i]) if any(islower, I) - push!(lowerclosure, LowerClosureIndex(i)) - # TODO: Corner points should be in both Lower and Upper? - # Should they have a separate type? + push!(lowerclosure, LowerClosureIndex(i,ci[i])) elseif any(isupper, I) - push!(upperclosure, UpperClosureIndex(i)) + push!(upperclosure, UpperClosureIndex(i,ci[i])) else - push!(interior, InteriorIndex(i)) + push!(interior, InteriorIndex(i,ci[i])) end end return lowerclosure, upperclosure, interior