changeset 658:26b0eb83aea4 feature/get_boundary_identifiers

Add function for getting boundary identifiers from equidistant grid
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sat, 30 Jan 2021 20:18:37 +0100
parents a768a9efb200
children aa3066010569
files src/Grids/EquidistantGrid.jl
diffstat 1 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/Grids/EquidistantGrid.jl	Sat Jan 30 20:47:52 2021 +0100
+++ b/src/Grids/EquidistantGrid.jl	Sat Jan 30 20:18:37 2021 +0100
@@ -41,15 +41,13 @@
 
 Base.size(g::EquidistantGrid) = g.size
 
+# TODO: Change to ndims? Seem to be the julia naming convention, at least for AbstractArrays.
 """
     dimension(grid::EquidistantGrid)
 
 The dimension of the grid.
 """
-function dimension(grid::EquidistantGrid)
-    return length(grid.size)
-end
-
+dimension(grid::EquidistantGrid{Dim}) where Dim = Dim
 
 """
     spacing(grid::EquidistantGrid)
@@ -95,3 +93,23 @@
     return EquidistantGrid(size, limit_lower, limit_upper)
 end
 export restrict
+
+"""
+    boundary_identifiers(::EquidistantGrid)
+
+Returns a tuple containing the boundary identifiers for the grid, stored as
+	(CartesianBoundary(1,Lower),
+	 CartesianBoundary(1,Upper),
+	 CartesianBoundary(2,Lower),
+	 ...)
+"""
+function boundary_identifiers(g::EquidistantGrid{Dim}) where Dim
+    bids = ()
+    for i=1:Dim
+        for r ∈ (Lower,Upper)
+            bids = (bids...,CartesianBoundary{i,r}())
+        end
+    end
+    return bids
+end
+export boundary_identifiers