Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundaryops/boundary_restriction_test.jl @ 975:5be8e25c81b3 feature/tensormapping_application_promotion
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 15 Mar 2022 07:37:11 +0100 |
parents | 775d5513da8f |
children | 7bf3121c6864 1ba8a398af9c |
comparison
equal
deleted
inserted
replaced
957:86889fc5b63f | 975:5be8e25c81b3 |
---|---|
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.RegionIndices | 6 using Sbplib.RegionIndices |
6 using Sbplib.LazyTensors | |
7 | |
8 import Sbplib.SbpOperators.BoundaryOperator | 7 import Sbplib.SbpOperators.BoundaryOperator |
9 | 8 |
10 @testset "boundary_restriction" begin | 9 @testset "boundary_restriction" begin |
11 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) |
12 e_closure = parse_stencil(stencil_set["e"]["closure"]) | 11 e_closure = parse_stencil(stencil_set["e"]["closure"]) |
13 g_1D = EquidistantGrid(11, 0.0, 1.0) | 12 g_1D = EquidistantGrid(11, 0.0, 1.0) |
14 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)) |
15 | 14 |
16 @testset "boundary_restriction" begin | 15 @testset "boundary_restriction" begin |
17 @testset "1D" begin | 16 @testset "1D" begin |
18 e_l = boundary_restriction(g_1D,e_closure,Lower()) | 17 e_l = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Lower}()) |
19 @test e_l == boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Lower}()) | 18 @test e_l == boundary_restriction(g_1D,stencil_set,CartesianBoundary{1,Lower}()) |
20 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Lower()) | 19 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Lower()) |
21 @test e_l isa BoundaryOperator{T,Lower} where T | 20 @test e_l isa BoundaryOperator{T,Lower} where T |
22 @test e_l isa TensorMapping{T,0,1} where T | 21 @test e_l isa TensorMapping{T,0,1} where T |
23 | 22 |
24 e_r = boundary_restriction(g_1D,e_closure,Upper()) | 23 e_r = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}()) |
25 @test e_r == boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}()) | 24 @test e_r == boundary_restriction(g_1D,stencil_set,CartesianBoundary{1,Upper}()) |
26 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Upper()) | 25 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Upper()) |
27 @test e_r isa BoundaryOperator{T,Upper} where T | 26 @test e_r isa BoundaryOperator{T,Upper} where T |
28 @test e_r isa TensorMapping{T,0,1} where T | 27 @test e_r isa TensorMapping{T,0,1} where T |
29 end | 28 end |
30 | 29 |
31 @testset "2D" begin | 30 @testset "2D" begin |
32 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}()) | |
33 @test e_w isa InflatedTensorMapping | 33 @test e_w isa InflatedTensorMapping |
34 @test e_w isa TensorMapping{T,1,2} where T | 34 @test e_w isa TensorMapping{T,1,2} where T |
35 end | 35 end |
36 end | 36 end |
37 | 37 |
38 @testset "Application" begin | 38 @testset "Application" begin |
39 @testset "1D" begin | 39 @testset "1D" begin |
40 e_l = boundary_restriction(g_1D, e_closure, CartesianBoundary{1,Lower}()) | 40 e_l, e_r = boundary_restriction.(Ref(g_1D), Ref(e_closure), boundary_identifiers(g_1D)) |
41 e_r = boundary_restriction(g_1D, e_closure, CartesianBoundary{1,Upper}()) | |
42 | |
43 v = evalOn(g_1D,x->1+x^2) | 41 v = evalOn(g_1D,x->1+x^2) |
44 u = fill(3.124) | 42 u = fill(3.124) |
45 | 43 |
46 @test (e_l*v)[] == v[1] | 44 @test (e_l*v)[] == v[1] |
47 @test (e_r*v)[] == v[end] | 45 @test (e_r*v)[] == v[end] |
48 @test (e_r*v)[1] == v[end] | 46 @test (e_r*v)[1] == v[end] |
49 end | 47 end |
50 | 48 |
51 @testset "2D" begin | 49 @testset "2D" begin |
52 e_w = boundary_restriction(g_2D, e_closure, CartesianBoundary{1,Lower}()) | 50 e_w, e_e, e_s, e_n = boundary_restriction.(Ref(g_2D), Ref(e_closure), boundary_identifiers(g_2D)) |
53 e_e = boundary_restriction(g_2D, e_closure, CartesianBoundary{1,Upper}()) | |
54 e_s = boundary_restriction(g_2D, e_closure, CartesianBoundary{2,Lower}()) | |
55 e_n = boundary_restriction(g_2D, e_closure, CartesianBoundary{2,Upper}()) | |
56 | |
57 v = rand(11, 15) | 51 v = rand(11, 15) |
58 u = fill(3.124) | 52 u = fill(3.124) |
59 | 53 |
60 @test e_w*v == v[1,:] | 54 @test e_w*v == v[1,:] |
61 @test e_e*v == v[end,:] | 55 @test e_e*v == v[end,:] |