Mercurial > repos > public > sbplib_julia
changeset 2017:ea2a15454cf2 feature/grids/multiblock_grids
Add connectio(...) to simplify the creation of grid connection tuples
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 12 Mar 2025 09:32:32 +0100 |
| parents | e17d90763a3f |
| children | a3ffc3202813 |
| files | src/Grids/Grids.jl src/Grids/multiblockgrids.jl test/Grids/multiblockgrids_test.jl |
| diffstat | 3 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/Grids.jl Wed Mar 12 08:59:28 2025 +0100 +++ b/src/Grids/Grids.jl Wed Mar 12 09:32:32 2025 +0100 @@ -55,7 +55,6 @@ export spacing export equidistant_grid -export MultiBlockBoundary # MappedGrid export MappedGrid @@ -64,6 +63,10 @@ export mapped_grid export metric_tensor +# Multi-block-grids +export MultiBlockBoundary +export connection + include("parameter_space.jl") include("grid.jl") include("tensor_grid.jl")
--- a/src/Grids/multiblockgrids.jl Wed Mar 12 08:59:28 2025 +0100 +++ b/src/Grids/multiblockgrids.jl Wed Mar 12 09:32:32 2025 +0100 @@ -7,3 +7,13 @@ struct MultiBlockBoundary{N, BID} <: BoundaryIdentifier end grid_id(::MultiBlockBoundary{N, BID}) where {N, BID} = N boundary_id(::MultiBlockBoundary{N, BID}) where {N, BID} = BID() + + +function connection(k1, b1::BoundaryIdentifier, k2, b2::BoundaryIdentifier) + return ( + MultiBlockBoundary{k1,typeof(b1)}(), + MultiBlockBoundary{k2,typeof(b2)}(), + ) +end + +connection(t::Tuple) = connection(t...)
--- a/test/Grids/multiblockgrids_test.jl Wed Mar 12 08:59:28 2025 +0100 +++ b/test/Grids/multiblockgrids_test.jl Wed Mar 12 09:32:32 2025 +0100 @@ -7,3 +7,12 @@ @test boundary_id(MultiBlockBoundary{1,UpperBoundary}()) == UpperBoundary() end + +@testset "connection" begin + @test connection(1, UpperBoundary(), 2, LowerBoundary()) == (MultiBlockBoundary{1,UpperBoundary}(), MultiBlockBoundary{2,LowerBoundary}()) + @test connection(:a, UpperBoundary(), :b, LowerBoundary()) == (MultiBlockBoundary{:a,UpperBoundary}(), MultiBlockBoundary{:b,LowerBoundary}()) + @test connection((1, UpperBoundary(), 2, LowerBoundary())) == (MultiBlockBoundary{1,UpperBoundary}(), MultiBlockBoundary{2,LowerBoundary}()) + + @test_throws Exception connection(1, UpperBoundary, 2, LowerBoundary()) + @test_throws Exception connection(1, UpperBoundary(), 2, LowerBoundary) +end
