Mercurial > repos > public > sbplib_julia
changeset 2018:a3ffc3202813 feature/grids/multiblock_grids
Start implementation of MultiBlockGrid
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 12 Mar 2025 09:34:00 +0100 |
| parents | ea2a15454cf2 |
| children | fb2dc185c197 |
| files | src/Grids/Grids.jl src/Grids/multiblockgrids.jl test/Grids/multiblockgrids_test.jl |
| diffstat | 3 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/Grids.jl Wed Mar 12 09:32:32 2025 +0100 +++ b/src/Grids/Grids.jl Wed Mar 12 09:34:00 2025 +0100 @@ -64,6 +64,7 @@ export metric_tensor # Multi-block-grids +export MultiBlockGrid export MultiBlockBoundary export connection
--- a/src/Grids/multiblockgrids.jl Wed Mar 12 09:32:32 2025 +0100 +++ b/src/Grids/multiblockgrids.jl Wed Mar 12 09:34:00 2025 +0100 @@ -1,3 +1,17 @@ + +struct MultiBlockGrid{T,D,GT, CT} <: Grid{T,D} + grids::GT + connections::CT +end + +function MultiBlockGrid(grids, connections) + T = eltype(valtype(grids)) + D = ndims(valtype(grids)) + + MultiBlockGrid{T,D,typeof(grids), typeof(connections)}(grids,connections) +end + + """ MultiBlockBoundary{N, BID} <: BoundaryIdentifier
--- a/test/Grids/multiblockgrids_test.jl Wed Mar 12 09:32:32 2025 +0100 +++ b/test/Grids/multiblockgrids_test.jl Wed Mar 12 09:34:00 2025 +0100 @@ -1,5 +1,29 @@ using Diffinitive.Grids +@testset "MultiBlockGrid" begin + @test MultiBlockGrid <: Grid + + @testset "Constructors" begin + g₁ = equidistant_grid(0,1,5) + g₂ = equidistant_grid(0,1,5) + g₃ = equidistant_grid(0,1,5) + + + # Vector + C = connection.([ + (1, UpperBoundary(), 2, LowerBoundary()), + (2, UpperBoundary(), 3, LowerBoundary()), + ]) + + @test MultiBlockGrid([g₁,g₂,g₃], C) isa Grid{Float64,1} + @test MultiBlockGrid([g₁,g₂,g₃], C) isa MultiBlockGrid{Float64,1} + + # Dictionary + @test MultiBlockGrid(Dict(:a=>g₁, :b=>g₂), [connection(:a, UpperBoundary(), :b, LowerBoundary())]) isa MultiBlockGrid{Float64,1} + end +end + + @testset "MultiBlockBoundary" begin @test MultiBlockBoundary{1,UpperBoundary}() isa BoundaryIdentifier
