diff src/Grids/grid.jl @ 1116:c2d7e940639e feature/grids

Rename AbstractGrid to Grid and clean up Grids module
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 15 Jul 2022 09:54:15 +0200
parents src/Grids/AbstractGrid.jl@6530fceef37c
children aeeffca46b94
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Grids/grid.jl	Fri Jul 15 09:54:15 2022 +0200
@@ -0,0 +1,28 @@
+"""
+     Grid
+
+Should implement
+    dim(grid::Grid)
+    points(grid::Grid)
+
+"""
+abstract type Grid end
+function dim end # TODO: Rename to Base.ndims instead? That's the name used for arrays.
+function points end
+
+"""
+    dims(g::Grid)
+
+A range containing the dimensions of the grid
+"""
+dims(grid::Grid) = 1:dim(grid)
+
+"""
+    evalOn(g::Grid, f::Function)
+
+Evaluate function f on the grid g
+"""
+function evalOn(g::Grid, f::Function)
+    F(x) = f(x...)
+    return F.(points(g))
+end
\ No newline at end of file