Mercurial > repos > public > sbplib_julia
comparison test/Grids/multiblockgrids_test.jl @ 2021:d6618d628515 feature/grids/multiblock_grids
Factor out functions for creating different types of multiblock grids in the tests
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 12 Mar 2025 10:54:47 +0100 |
| parents | 7f7207b9bd6c |
| children | 7f04753ead30 |
comparison
equal
deleted
inserted
replaced
| 2020:7f7207b9bd6c | 2021:d6618d628515 |
|---|---|
| 1 using Diffinitive.Grids | 1 using Diffinitive.Grids |
| 2 using StaticArrays | 2 using StaticArrays |
| 3 | |
| 4 | |
| 5 function multiblockgrid1d() | |
| 6 g₁ = equidistant_grid(0,1,5) | |
| 7 g₂ = equidistant_grid(0,1,5) | |
| 8 g₃ = equidistant_grid(0,1,5) | |
| 9 | |
| 10 C = connection.([ | |
| 11 (1, UpperBoundary(), 2, LowerBoundary()), | |
| 12 (2, UpperBoundary(), 3, LowerBoundary()), | |
| 13 ]) | |
| 14 | |
| 15 return MultiBlockGrid([g₁,g₂,g₃], C) | |
| 16 end | |
| 17 | |
| 18 function multiblockgrid2d() | |
| 19 g₁₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 20 g₁₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 21 g₂₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 22 g₂₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 23 | |
| 24 C = map(((i1,d1,b1,i2,d2,b2),)->connection(i1,CartesianBoundary{d1,b1}(), i2, CartesianBoundary{d2,b2}()),[ | |
| 25 (1, 1, UpperBoundary, 2, 1, LowerBoundary), | |
| 26 (3, 1, UpperBoundary, 4, 1, LowerBoundary), | |
| 27 (1, 2, UpperBoundary, 3, 2, LowerBoundary), | |
| 28 (2, 2, UpperBoundary, 4, 2, LowerBoundary), | |
| 29 ]) | |
| 30 | |
| 31 return MultiBlockGrid([g₁₁, g₁₂, g₂₁, g₂₂], C) | |
| 32 end | |
| 33 | |
| 34 function multiblockgrid_matrix() | |
| 35 g₁₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 36 g₁₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 37 g₂₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 38 g₂₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 39 | |
| 40 C = map(((i1,d1,b1,i2,d2,b2),)->connection(CartesianIndex(i1),CartesianBoundary{d1,b1}(), CartesianIndex(i2), CartesianBoundary{d2,b2}()),[ | |
| 41 ((1,1), 1, UpperBoundary, (1,2), 1, LowerBoundary), | |
| 42 ((2,1), 1, UpperBoundary, (2,2), 1, LowerBoundary), | |
| 43 ((1,1), 2, UpperBoundary, (1,2), 2, LowerBoundary), | |
| 44 ((2,1), 2, UpperBoundary, (2,2), 2, LowerBoundary), | |
| 45 ]) | |
| 46 | |
| 47 return MultiBlockGrid([g₁₁ g₁₂; g₂₁ g₂₂], C) | |
| 48 end | |
| 49 | |
| 50 function multiblockgrid_dict() | |
| 51 g₁ = equidistant_grid(0,1,5) | |
| 52 g₂ = equidistant_grid(0,1,5) | |
| 53 | |
| 54 C = [connection(:a, UpperBoundary(), :b, LowerBoundary())] | |
| 55 MultiBlockGrid(Dict(:a=>g₁, :b=>g₂), C) | |
| 56 end | |
| 3 | 57 |
| 4 @testset "MultiBlockGrid" begin | 58 @testset "MultiBlockGrid" begin |
| 5 @test MultiBlockGrid <: Grid | 59 @test MultiBlockGrid <: Grid |
| 6 | 60 |
| 7 @testset "Constructors" begin | 61 @testset "Constructors" begin |
| 8 # Vector | 62 @test multiblockgrid1d() isa Grid{Float64,1} |
| 9 g₁ = equidistant_grid(0,1,5) | 63 @test multiblockgrid1d() isa MultiBlockGrid{Float64,1} |
| 10 g₂ = equidistant_grid(0,1,5) | 64 @test multiblockgrid2d() isa MultiBlockGrid{SVector{2,Float64},2} |
| 11 g₃ = equidistant_grid(0,1,5) | 65 @test multiblockgrid_matrix() isa MultiBlockGrid{SVector{2,Float64},2} |
| 12 | 66 @test multiblockgrid_dict() isa MultiBlockGrid{Float64,1} |
| 13 C = connection.([ | |
| 14 (1, UpperBoundary(), 2, LowerBoundary()), | |
| 15 (2, UpperBoundary(), 3, LowerBoundary()), | |
| 16 ]) | |
| 17 | |
| 18 @test MultiBlockGrid([g₁,g₂,g₃], C) isa Grid{Float64,1} | |
| 19 @test MultiBlockGrid([g₁,g₂,g₃], C) isa MultiBlockGrid{Float64,1} | |
| 20 | |
| 21 | |
| 22 g₁₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 23 g₁₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 24 g₂₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 25 g₂₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 26 | |
| 27 C = map(((i1,d1,b1,i2,d2,b2),)->connection(i1,CartesianBoundary{d1,b1}(), i2, CartesianBoundary{d2,b2}()),[ | |
| 28 (1, 1, UpperBoundary, 2, 1, LowerBoundary), | |
| 29 (3, 1, UpperBoundary, 4, 1, LowerBoundary), | |
| 30 (1, 2, UpperBoundary, 3, 2, LowerBoundary), | |
| 31 (2, 2, UpperBoundary, 4, 2, LowerBoundary), | |
| 32 ]) | |
| 33 | |
| 34 @test MultiBlockGrid([g₁₁, g₁₂, g₂₁, g₂₂], C) isa MultiBlockGrid{SVector{2,Float64},2} | |
| 35 | |
| 36 # Matrix | |
| 37 g₁₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 38 g₁₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 39 g₂₁ = equidistant_grid((0,0),(1,1),5,5) | |
| 40 g₂₂ = equidistant_grid((0,0),(1,1),5,5) | |
| 41 | |
| 42 C = map(((i1,d1,b1,i2,d2,b2),)->connection(CartesianIndex(i1),CartesianBoundary{d1,b1}(), CartesianIndex(i2), CartesianBoundary{d2,b2}()),[ | |
| 43 ((1,1), 1, UpperBoundary, (1,2), 1, LowerBoundary), | |
| 44 ((2,1), 1, UpperBoundary, (2,2), 1, LowerBoundary), | |
| 45 ((1,1), 2, UpperBoundary, (1,2), 2, LowerBoundary), | |
| 46 ((2,1), 2, UpperBoundary, (2,2), 2, LowerBoundary), | |
| 47 ]) | |
| 48 | |
| 49 @test MultiBlockGrid([g₁₁ g₁₂; g₂₁ g₂₂], C) isa MultiBlockGrid{SVector{2,Float64},2} | |
| 50 | |
| 51 # Dictionary | |
| 52 @test MultiBlockGrid(Dict(:a=>g₁, :b=>g₂), [connection(:a, UpperBoundary(), :b, LowerBoundary())]) isa MultiBlockGrid{Float64,1} | |
| 53 end | 67 end |
| 54 | 68 |
| 55 @testset "Base.getindex" begin | 69 @testset "Base.getindex" begin |
| 56 @test_broken false | 70 @test_broken false |
| 57 end | 71 end |
