Mercurial > repos > public > sbplib_julia
diff src/Grids/equidistant_grid.jl @ 1672:3714a391545a refactor/grids/boundary_identifiers_1d
Make the boundary identifiers for EquidistantGrid subtype BoundaryIdentifer
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Sun, 07 Jul 2024 15:15:12 -0700 |
parents | 5f348cc5598e |
children | f09d98874f12 |
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl Sat Jun 29 17:06:27 2024 +0200 +++ b/src/Grids/equidistant_grid.jl Sun Jul 07 15:15:12 2024 -0700 @@ -49,12 +49,30 @@ min_spacing(g::EquidistantGrid) = spacing(g) +""" + LowerBoundary <: BoundaryIdentifier -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),) +Boundary identifier for the the lower (left) boundary of an EquidistantGrid + +See also: [`BoundaryIdentifier`](@ref) +""" +struct LowerBoundary <: BoundaryIdentifier end + +""" + UpperBoundary <: BoundaryIdentifier + +Boundary identifier for the the upper (right) boundary of an EquidistantGrid + +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)