Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundaryops/boundary_restriction_test.jl @ 2057:8a2a0d678d6f feature/lazy_tensors/pretty_printing
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 10 Feb 2026 22:41:19 +0100 |
| parents | 471a948cd2b2 |
| children | f3d7e2d7a43f 5fb64e42138c |
comparison
equal
deleted
inserted
replaced
| 1110:c0bff9f6e0fb | 2057:8a2a0d678d6f |
|---|---|
| 1 using Test | 1 using Test |
| 2 | 2 |
| 3 using Sbplib.SbpOperators | 3 using Diffinitive.SbpOperators |
| 4 using Sbplib.Grids | 4 using Diffinitive.Grids |
| 5 using Sbplib.LazyTensors | 5 using Diffinitive.LazyTensors |
| 6 using Sbplib.RegionIndices | 6 using Diffinitive.RegionIndices |
| 7 using Sbplib.SbpOperators: BoundaryOperator, Stencil | 7 using Diffinitive.SbpOperators: BoundaryOperator, Stencil |
| 8 | 8 |
| 9 @testset "boundary_restriction" begin | 9 @testset "boundary_restriction" begin |
| 10 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order = 4) | 10 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order = 4) |
| 11 e_closure = parse_stencil(stencil_set["e"]["closure"]) | 11 e_closure = parse_stencil(stencil_set["e"]["closure"]) |
| 12 g_1D = EquidistantGrid(11, 0.0, 1.0) | 12 g_1D = equidistant_grid(0.0, 1.0, 11) |
| 13 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | 13 g_2D = equidistant_grid((0.0, 0.0), (1.0,1.0), 11, 15) |
| 14 | 14 |
| 15 @testset "boundary_restriction" begin | 15 @testset "boundary_restriction" begin |
| 16 @testset "1D" begin | 16 @testset "1D" begin |
| 17 e_l = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Lower}()) | 17 e_l = boundary_restriction(g_1D,stencil_set,LowerBoundary()) |
| 18 @test e_l == boundary_restriction(g_1D,stencil_set,CartesianBoundary{1,Lower}()) | 18 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),LowerBoundary()) |
| 19 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Lower()) | 19 @test e_l isa BoundaryOperator{T,LowerBoundary} where T |
| 20 @test e_l isa BoundaryOperator{T,Lower} where T | |
| 21 @test e_l isa LazyTensor{T,0,1} where T | 20 @test e_l isa LazyTensor{T,0,1} where T |
| 22 | 21 |
| 23 e_r = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}()) | 22 e_r = boundary_restriction(g_1D,stencil_set,UpperBoundary()) |
| 24 @test e_r == boundary_restriction(g_1D,stencil_set,CartesianBoundary{1,Upper}()) | 23 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),UpperBoundary()) |
| 25 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Upper()) | 24 @test e_r isa BoundaryOperator{T,UpperBoundary} where T |
| 26 @test e_r isa BoundaryOperator{T,Upper} where T | |
| 27 @test e_r isa LazyTensor{T,0,1} where T | 25 @test e_r isa LazyTensor{T,0,1} where T |
| 28 end | 26 end |
| 29 | 27 |
| 30 @testset "2D" begin | 28 @testset "2D" begin |
| 31 e_w = boundary_restriction(g_2D,e_closure,CartesianBoundary{1,Upper}()) | 29 e_w = boundary_restriction(g_2D,stencil_set,CartesianBoundary{1,UpperBoundary}()) |
| 32 @test e_w == boundary_restriction(g_2D,stencil_set,CartesianBoundary{1,Upper}()) | |
| 33 @test e_w isa InflatedTensor | 30 @test e_w isa InflatedTensor |
| 34 @test e_w isa LazyTensor{T,1,2} where T | 31 @test e_w isa LazyTensor{T,1,2} where T |
| 35 end | 32 end |
| 36 end | 33 end |
| 37 | 34 |
| 38 @testset "Application" begin | 35 @testset "Application" begin |
| 39 @testset "1D" begin | 36 @testset "1D" begin |
| 40 e_l, e_r = boundary_restriction.(Ref(g_1D), Ref(e_closure), boundary_identifiers(g_1D)) | 37 e_l, e_r = boundary_restriction.(Ref(g_1D), Ref(stencil_set), boundary_identifiers(g_1D)) |
| 41 v = evalOn(g_1D,x->1+x^2) | 38 v = eval_on(g_1D,x->1+x^2) |
| 42 u = fill(3.124) | 39 u = fill(3.124) |
| 43 | 40 |
| 44 @test (e_l*v)[] == v[1] | 41 @test (e_l*v)[] == v[1] |
| 45 @test (e_r*v)[] == v[end] | 42 @test (e_r*v)[] == v[end] |
| 46 @test (e_r*v)[1] == v[end] | 43 @test (e_r*v)[1] == v[end] |
| 47 end | 44 end |
| 48 | 45 |
| 49 @testset "2D" begin | 46 @testset "2D" begin |
| 50 e_w, e_e, e_s, e_n = boundary_restriction.(Ref(g_2D), Ref(e_closure), boundary_identifiers(g_2D)) | 47 e_w, e_e, e_s, e_n = boundary_restriction.(Ref(g_2D), Ref(stencil_set), boundary_identifiers(g_2D)) |
| 51 v = rand(11, 15) | 48 v = rand(11, 15) |
| 52 u = fill(3.124) | 49 u = fill(3.124) |
| 53 | 50 |
| 54 @test e_w*v == v[1,:] | 51 @test e_w*v == v[1,:] |
| 55 @test e_e*v == v[end,:] | 52 @test e_e*v == v[end,:] |
