Mercurial > repos > public > sbplib_julia
comparison test/Grids/multiblockgrids_test.jl @ 2020:7f7207b9bd6c feature/grids/multiblock_grids
Add constructor tests for 2d grids and using matrix for the grid collection
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 12 Mar 2025 10:48:58 +0100 |
| parents | fb2dc185c197 |
| children | d6618d628515 |
comparison
equal
deleted
inserted
replaced
| 2019:fb2dc185c197 | 2020:7f7207b9bd6c |
|---|---|
| 1 using Diffinitive.Grids | 1 using Diffinitive.Grids |
| 2 using StaticArrays | |
| 2 | 3 |
| 3 @testset "MultiBlockGrid" begin | 4 @testset "MultiBlockGrid" begin |
| 4 @test MultiBlockGrid <: Grid | 5 @test MultiBlockGrid <: Grid |
| 5 | 6 |
| 6 @testset "Constructors" begin | 7 @testset "Constructors" begin |
| 8 # Vector | |
| 7 g₁ = equidistant_grid(0,1,5) | 9 g₁ = equidistant_grid(0,1,5) |
| 8 g₂ = equidistant_grid(0,1,5) | 10 g₂ = equidistant_grid(0,1,5) |
| 9 g₃ = equidistant_grid(0,1,5) | 11 g₃ = equidistant_grid(0,1,5) |
| 10 | 12 |
| 11 | |
| 12 # Vector | |
| 13 C = connection.([ | 13 C = connection.([ |
| 14 (1, UpperBoundary(), 2, LowerBoundary()), | 14 (1, UpperBoundary(), 2, LowerBoundary()), |
| 15 (2, UpperBoundary(), 3, LowerBoundary()), | 15 (2, UpperBoundary(), 3, LowerBoundary()), |
| 16 ]) | 16 ]) |
| 17 | 17 |
| 18 @test MultiBlockGrid([g₁,g₂,g₃], C) isa Grid{Float64,1} | 18 @test MultiBlockGrid([g₁,g₂,g₃], C) isa Grid{Float64,1} |
| 19 @test MultiBlockGrid([g₁,g₂,g₃], C) isa MultiBlockGrid{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} | |
| 20 | 50 |
| 21 # Dictionary | 51 # Dictionary |
| 22 @test MultiBlockGrid(Dict(:a=>g₁, :b=>g₂), [connection(:a, UpperBoundary(), :b, LowerBoundary())]) isa MultiBlockGrid{Float64,1} | 52 @test MultiBlockGrid(Dict(:a=>g₁, :b=>g₂), [connection(:a, UpperBoundary(), :b, LowerBoundary())]) isa MultiBlockGrid{Float64,1} |
| 23 end | 53 end |
| 24 | 54 |
