Mercurial > repos > public > sbplib_julia
diff src/Grids/equidistant_grid.jl @ 1719:d81d0660b80d
Merge refactor/grids/boundary_identifiers_1d
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Thu, 05 Sep 2024 08:26:12 -0700 |
parents | b5690ab5f0b8 |
children | 863385aae454 d207e1abacc1 |
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl Thu Sep 05 08:22:47 2024 -0700 +++ b/src/Grids/equidistant_grid.jl Thu Sep 05 08:26: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 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)