diff 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
line wrap: on
line diff
--- a/src/Grids/EquidistantGrid.jl	Fri Apr 08 19:36:22 2022 +0200
+++ b/src/Grids/EquidistantGrid.jl	Tue Apr 26 14:28:42 2022 +0200
@@ -67,6 +67,11 @@
 
 Base.size(g::EquidistantGrid) = g.size
 
+function Base.getindex(g::EquidistantGrid, I...)
+    h = spacing(g)
+    return g.limit_lower .+ (I.-1).*h
+end
+
 """
     dimension(grid::EquidistantGrid)