Mercurial > repos > public > sbplib_julia
changeset 666:94fe0761e6f9 feature/laplace_opset
Merge in changes from default
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Sun, 31 Jan 2021 20:59:29 +0100 |
parents | f1803ab08740 (current diff) 7d7c1d636de3 (diff) |
children | f3a0d1f7d842 |
files | |
diffstat | 2 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/EquidistantGrid.jl Sun Jan 31 13:13:06 2021 +0100 +++ b/src/Grids/EquidistantGrid.jl Sun Jan 31 20:59:29 2021 +0100 @@ -46,10 +46,7 @@ The dimension of the grid. """ -function dimension(grid::EquidistantGrid) - return length(grid.size) -end - +dimension(grid::EquidistantGrid{Dim}) where Dim = Dim """ spacing(grid::EquidistantGrid) @@ -95,3 +92,15 @@ return EquidistantGrid(size, limit_lower, limit_upper) end export restrict + +""" + boundary_identifiers(::EquidistantGrid) + +Returns a tuple containing the boundary identifiers for the grid, stored as + (CartesianBoundary(1,Lower), + CartesianBoundary(1,Upper), + CartesianBoundary(2,Lower), + ...) +""" +boundary_identifiers(g::EquidistantGrid) = (((ntuple(i->(CartesianBoundary{i,Lower}(),CartesianBoundary{i,Upper}()),dimension(g)))...)...,) +export boundary_identifiers
--- a/test/testGrids.jl Sun Jan 31 13:13:06 2021 +0100 +++ b/test/testGrids.jl Sun Jan 31 20:59:29 2021 +0100 @@ -1,5 +1,6 @@ using Sbplib.Grids using Test +using Sbplib.RegionIndices @testset "Grids" begin @@ -53,6 +54,15 @@ @test restrict(g, 2:3) == EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0)) @test restrict(g, [1,3]) == EquidistantGrid((2,3),(0.0,0.0),(2.0,3.0)) @test restrict(g, [2,1]) == EquidistantGrid((5,2),(0.0,0.0),(1.0,2.0)) + + @testset "boundary_identifiers" begin + g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0)) + bids = (CartesianBoundary{1,Lower}(),CartesianBoundary{1,Upper}(), + CartesianBoundary{2,Lower}(),CartesianBoundary{2,Upper}(), + CartesianBoundary{3,Lower}(),CartesianBoundary{3,Upper}()) + @test boundary_identifiers(g) == bids + @inferred boundary_identifiers(g) + end end end