diff src/Grids/equidistant_grid.jl @ 1829:871f3f1decea refactor/grids/iterable_boundary_indices

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 20 Oct 2024 21:38:09 +0200
parents b0c019acb50b 863385aae454
children 805b9b7fcc39
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl	Tue Sep 17 11:20:00 2024 +0200
+++ b/src/Grids/equidistant_grid.jl	Sun Oct 20 21:38:09 2024 +0200
@@ -47,12 +47,32 @@
 """
 inverse_spacing(g::EquidistantGrid) = 1/step(g.points)
 
+min_spacing(g::EquidistantGrid) = spacing(g)
 
-boundary_identifiers(::EquidistantGrid) = (Lower(), Upper())
-boundary_grid(g::EquidistantGrid, id::Lower) = ZeroDimGrid(g[begin])
-boundary_grid(g::EquidistantGrid, id::Upper) = ZeroDimGrid(g[end])
-boundary_indices(g::EquidistantGrid, id::Lower) = 1
-boundary_indices(g::EquidistantGrid, id::Upper) = length(g)
+"""
+    LowerBoundary <: BoundaryIdentifier
+
+Boundary identifier for the the lower (left) boundary of a one-dimensional grid.
+
+See also: [`BoundaryIdentifier`](@ref)
+"""
+struct LowerBoundary <: BoundaryIdentifier end
+
+"""
+    UpperBoundary <: BoundaryIdentifier
+
+Boundary identifier for the the upper (right)  boundary of a one-dimensional grid.
+
+See also: [`BoundaryIdentifier`](@ref)
+"""
+struct UpperBoundary <: BoundaryIdentifier end
+
+
+boundary_identifiers(::EquidistantGrid) = (LowerBoundary(), UpperBoundary())
+boundary_grid(g::EquidistantGrid, id::LowerBoundary) = ZeroDimGrid(g[begin])
+boundary_grid(g::EquidistantGrid, id::UpperBoundary) = ZeroDimGrid(g[end])
+boundary_indices(g::EquidistantGrid, id::LowerBoundary) = (firstindex(g),)
+boundary_indices(g::EquidistantGrid, id::UpperBoundary) = (lastindex(g),)
 
 """
     refine(g::EquidistantGrid, r::Int)
@@ -119,7 +139,7 @@
 
 Constructs a 1D equidistant grid.
 """
-function equidistant_grid(limit_lower::T, limit_upper::T, size::Int) where T
+function equidistant_grid(limit_lower::Number, limit_upper::Number, size::Int)
     if any(size .<= 0)
         throw(DomainError("size must be postive"))
     end