comparison test/SbpOperators/boundaryops/boundary_restriction_test.jl @ 934:af670581b464 feature/laplace_opset

Add tests for constructing boundary operators from stencil sets
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 25 Feb 2022 16:35:16 +0100
parents 47425442bbc5
children 7168d28b03e3
comparison
equal deleted inserted replaced
933:d83f685f1031 934:af670581b464
1 using Test 1 using Test
2 2
3 using Sbplib.SbpOperators 3 using Sbplib.SbpOperators
4 using Sbplib.Grids 4 using Sbplib.Grids
5 using Sbplib.LazyTensors 5 using Sbplib.LazyTensors
6 6 using Sbplib.RegionIndices
7 import Sbplib.SbpOperators.BoundaryOperator 7 import Sbplib.SbpOperators.BoundaryOperator
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"])
13 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) 13 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
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,e_closure,CartesianBoundary{1,Lower}())
18 @test e_l == boundary_restriction(g_1D,stencil_set,CartesianBoundary{1,Lower}())
18 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Lower()) 19 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Lower())
19 @test e_l isa BoundaryOperator{T,Lower} where T 20 @test e_l isa BoundaryOperator{T,Lower} where T
20 @test e_l isa TensorMapping{T,0,1} where T 21 @test e_l isa TensorMapping{T,0,1} where T
21 22
22 e_r = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}()) 23 e_r = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}())
24 @test e_r == boundary_restriction(g_1D,stencil_set,CartesianBoundary{1,Upper}())
23 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Upper()) 25 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Upper())
24 @test e_r isa BoundaryOperator{T,Upper} where T 26 @test e_r isa BoundaryOperator{T,Upper} where T
25 @test e_r isa TensorMapping{T,0,1} where T 27 @test e_r isa TensorMapping{T,0,1} where T
26 end 28 end
27 29
28 @testset "2D" begin 30 @testset "2D" begin
29 e_w = boundary_restriction(g_2D,e_closure,CartesianBoundary{1,Upper}()) 31 e_w = boundary_restriction(g_2D,e_closure,CartesianBoundary{1,Upper}())
32 @test e_w == boundary_restriction(g_2D,stencil_set,CartesianBoundary{1,Upper}())
30 @test e_w isa InflatedTensorMapping 33 @test e_w isa InflatedTensorMapping
31 @test e_w isa TensorMapping{T,1,2} where T 34 @test e_w isa TensorMapping{T,1,2} where T
32 end 35 end
33 end 36 end
34 37