Mercurial > repos > public > sbplib_julia
comparison src/Grids/EquidistantGrid.jl @ 1090:9b40aeac4269 refactor/grids
Add getindex for grid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 26 Apr 2022 14:28:42 +0200 |
parents | b900fea1c057 |
children | c4ea28d904f5 |
comparison
equal
deleted
inserted
replaced
1082:9abb140a4636 | 1090:9b40aeac4269 |
---|---|
64 Base.eltype(grid::EquidistantGrid{Dim,T}) where {Dim,T} = T | 64 Base.eltype(grid::EquidistantGrid{Dim,T}) where {Dim,T} = T |
65 | 65 |
66 Base.eachindex(grid::EquidistantGrid) = CartesianIndices(grid.size) | 66 Base.eachindex(grid::EquidistantGrid) = CartesianIndices(grid.size) |
67 | 67 |
68 Base.size(g::EquidistantGrid) = g.size | 68 Base.size(g::EquidistantGrid) = g.size |
69 | |
70 function Base.getindex(g::EquidistantGrid, I...) | |
71 h = spacing(g) | |
72 return g.limit_lower .+ (I.-1).*h | |
73 end | |
69 | 74 |
70 """ | 75 """ |
71 dimension(grid::EquidistantGrid) | 76 dimension(grid::EquidistantGrid) |
72 | 77 |
73 The dimension of the grid. | 78 The dimension of the grid. |