Mercurial > repos > public > sbplib_julia
diff src/Grids/equidistant_grid.jl @ 1720:7fdc348f91ff feature/lazy_tensors/sparse_conversions
Merge with default
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Thu, 05 Sep 2024 08:26:57 -0700 |
parents | b5690ab5f0b8 |
children | 863385aae454 d207e1abacc1 |
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl Wed Sep 04 23:20:28 2024 +0200 +++ b/src/Grids/equidistant_grid.jl Thu Sep 05 08:26:57 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) @@ -121,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