Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
1671:791d0f3f289a | 1672:3714a391545a |
---|---|
47 """ | 47 """ |
48 inverse_spacing(g::EquidistantGrid) = 1/step(g.points) | 48 inverse_spacing(g::EquidistantGrid) = 1/step(g.points) |
49 | 49 |
50 min_spacing(g::EquidistantGrid) = spacing(g) | 50 min_spacing(g::EquidistantGrid) = spacing(g) |
51 | 51 |
52 """ | |
53 LowerBoundary <: BoundaryIdentifier | |
52 | 54 |
53 boundary_identifiers(::EquidistantGrid) = (Lower(), Upper()) | 55 Boundary identifier for the the lower (left) boundary of an EquidistantGrid |
54 boundary_grid(g::EquidistantGrid, id::Lower) = ZeroDimGrid(g[begin]) | 56 |
55 boundary_grid(g::EquidistantGrid, id::Upper) = ZeroDimGrid(g[end]) | 57 See also: [`BoundaryIdentifier`](@ref) |
56 boundary_indices(g::EquidistantGrid, id::Lower) = (1,) | 58 """ |
57 boundary_indices(g::EquidistantGrid, id::Upper) = (length(g),) | 59 struct LowerBoundary <: BoundaryIdentifier end |
60 | |
61 """ | |
62 UpperBoundary <: BoundaryIdentifier | |
63 | |
64 Boundary identifier for the the upper (right) boundary of an EquidistantGrid | |
65 | |
66 See also: [`BoundaryIdentifier`](@ref) | |
67 """ | |
68 struct UpperBoundary <: BoundaryIdentifier end | |
69 | |
70 | |
71 boundary_identifiers(::EquidistantGrid) = (LowerBoundary(), UpperBoundary()) | |
72 boundary_grid(g::EquidistantGrid, id::LowerBoundary) = ZeroDimGrid(g[begin]) | |
73 boundary_grid(g::EquidistantGrid, id::UpperBoundary) = ZeroDimGrid(g[end]) | |
74 boundary_indices(g::EquidistantGrid, id::LowerBoundary) = (firstindex(g),) | |
75 boundary_indices(g::EquidistantGrid, id::UpperBoundary) = (lastindex(g),) | |
58 | 76 |
59 """ | 77 """ |
60 refine(g::EquidistantGrid, r::Int) | 78 refine(g::EquidistantGrid, r::Int) |
61 | 79 |
62 The grid where `g` is refined by the factor `r`. The factor is applied to the number of | 80 The grid where `g` is refined by the factor `r`. The factor is applied to the number of |