Mercurial > repos > public > sbplib_julia
changeset 2024:3fb33f00dab2 feature/grids/multiblock_grids
Implement getindex
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 12 Mar 2025 11:15:36 +0100 |
| parents | 50e7090f5a95 |
| children | d35a4cb170ff |
| files | src/Grids/multiblockgrids.jl test/Grids/multiblockgrids_test.jl |
| diffstat | 2 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/multiblockgrids.jl Wed Mar 12 11:11:50 2025 +0100 +++ b/src/Grids/multiblockgrids.jl Wed Mar 12 11:15:36 2025 +0100 @@ -14,7 +14,7 @@ grids(g::MultiBlockGrid) = g.grids connections(g::MultiBlockGrid) = g.connections -# function Base.getindex end +Base.getindex(g::MultiBlockGrid, I...) = g.grids[I...] # function boundary_identifiers end # Requires function from manifolds? # function boundary_grid end # Should return a MultiBlockGrid with the right connections?
--- a/test/Grids/multiblockgrids_test.jl Wed Mar 12 11:11:50 2025 +0100 +++ b/test/Grids/multiblockgrids_test.jl Wed Mar 12 11:15:36 2025 +0100 @@ -75,12 +75,13 @@ @testset "grids" begin gs, cs = multiblockgrid1d() @test grids(MultiBlockGrid(gs, cs)) == gs - gs, cs = multiblockgrid1d() - @test grids(MultiBlockGrid(gs, cs)) == gs + gs, cs = multiblockgrid2d() @test grids(MultiBlockGrid(gs, cs)) == gs + gs, cs = multiblockgrid_matrix() @test grids(MultiBlockGrid(gs, cs)) == gs + gs, cs = multiblockgrid_dict() @test grids(MultiBlockGrid(gs, cs)) == gs end @@ -88,19 +89,30 @@ @testset "connections" begin gs, cs = multiblockgrid1d() @test connections(MultiBlockGrid(gs, cs)) == cs - gs, cs = multiblockgrid1d() - @test connections(MultiBlockGrid(gs, cs)) == cs + gs, cs = multiblockgrid2d() @test connections(MultiBlockGrid(gs, cs)) == cs + gs, cs = multiblockgrid_matrix() @test connections(MultiBlockGrid(gs, cs)) == cs + gs, cs = multiblockgrid_dict() @test connections(MultiBlockGrid(gs, cs)) == cs end end @testset "Base.getindex" begin - @test_broken false + gs, cs = multiblockgrid1d() + @test MultiBlockGrid(gs, cs)[2] == gs[2] + + gs, cs = multiblockgrid2d() + @test MultiBlockGrid(gs, cs)[3] == gs[3] + + gs, cs = multiblockgrid_matrix() + @test MultiBlockGrid(gs, cs)[1,2] == gs[1,2] + + gs, cs = multiblockgrid_dict() + @test MultiBlockGrid(gs, cs)[:a] == gs[:a] end @testset "boundary_identifiers" begin
