Mercurial > repos > public > sbplib_julia
changeset 1462:05eb8ba149e2 feature/grids/boundary_indicies
Implement boundary_indices for EquidistantGrid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 28 Nov 2023 08:51:58 +0100 |
parents | 455e6b4c8b02 |
children | 4ad1282f8bab |
files | src/Grids/Grids.jl src/Grids/equidistant_grid.jl test/Grids/equidistant_grid_test.jl |
diffstat | 3 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/Grids.jl Tue Nov 28 08:42:00 2023 +0100 +++ b/src/Grids/Grids.jl Tue Nov 28 08:51:58 2023 +0100 @@ -16,6 +16,7 @@ export grid_id export boundary_id +export boundary_indices export eval_on export getcomponent
--- a/src/Grids/equidistant_grid.jl Tue Nov 28 08:42:00 2023 +0100 +++ b/src/Grids/equidistant_grid.jl Tue Nov 28 08:51:58 2023 +0100 @@ -51,7 +51,8 @@ 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) """ refine(g::EquidistantGrid, r::Int)
--- a/test/Grids/equidistant_grid_test.jl Tue Nov 28 08:42:00 2023 +0100 +++ b/test/Grids/equidistant_grid_test.jl Tue Nov 28 08:51:58 2023 +0100 @@ -68,6 +68,17 @@ @test boundary_grid(g, Upper()) == ZeroDimGrid(1.0) end + @testset "boundary_indices" begin + g = EquidistantGrid(0:0.1:1) + @test boundary_indices(g, Lower()) == 1 + @test boundary_indices(g, Upper()) == 11 + + g = EquidistantGrid(2:0.1:10) + @test boundary_indices(g, Lower()) == 1 + @test boundary_indices(g, Upper()) == 81 + + end + @testset "refine" begin g = EquidistantGrid(0:0.1:1) @test refine(g, 1) == g