Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundaryops/boundary_restriction_test.jl @ 772:bea2feebbeca operator_storage_array_of_table
Fix boundaryops tests
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 15 Jul 2021 00:28:09 +0200 |
parents | 6114274447f5 |
children | beae513ef8b3 |
comparison
equal
deleted
inserted
replaced
771:d0c1d0b4da52 | 772:bea2feebbeca |
---|---|
6 using Sbplib.LazyTensors | 6 using Sbplib.LazyTensors |
7 | 7 |
8 import Sbplib.SbpOperators.BoundaryOperator | 8 import Sbplib.SbpOperators.BoundaryOperator |
9 | 9 |
10 @testset "boundary_restriction" begin | 10 @testset "boundary_restriction" begin |
11 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 11 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order = 4) |
12 e_closure = parse_stencil(stencil_set["e"]["closure"]) | |
12 g_1D = EquidistantGrid(11, 0.0, 1.0) | 13 g_1D = EquidistantGrid(11, 0.0, 1.0) |
13 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | 14 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) |
14 | 15 |
15 @testset "boundary_restriction" begin | 16 @testset "boundary_restriction" begin |
16 @testset "1D" begin | 17 @testset "1D" begin |
17 e_l = boundary_restriction(g_1D,op.eClosure,Lower()) | 18 e_l = boundary_restriction(g_1D,e_closure,Lower()) |
18 @test e_l == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}()) | 19 @test e_l == boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Lower}()) |
19 @test e_l == BoundaryOperator(g_1D,op.eClosure,Lower()) | 20 @test e_l == BoundaryOperator(g_1D,e_closure,Lower()) |
20 @test e_l isa BoundaryOperator{T,Lower} where T | 21 @test e_l isa BoundaryOperator{T,Lower} where T |
21 @test e_l isa TensorMapping{T,0,1} where T | 22 @test e_l isa TensorMapping{T,0,1} where T |
22 | 23 |
23 e_r = boundary_restriction(g_1D,op.eClosure,Upper()) | 24 e_r = boundary_restriction(g_1D,e_closure,Upper()) |
24 @test e_r == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}()) | 25 @test e_r == boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}()) |
25 @test e_r == BoundaryOperator(g_1D,op.eClosure,Upper()) | 26 @test e_r == BoundaryOperator(g_1D,e_closure,Upper()) |
26 @test e_r isa BoundaryOperator{T,Upper} where T | 27 @test e_r isa BoundaryOperator{T,Upper} where T |
27 @test e_r isa TensorMapping{T,0,1} where T | 28 @test e_r isa TensorMapping{T,0,1} where T |
28 end | 29 end |
29 | 30 |
30 @testset "2D" begin | 31 @testset "2D" begin |
31 e_w = boundary_restriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}()) | 32 e_w = boundary_restriction(g_2D,e_closure,CartesianBoundary{1,Upper}()) |
32 @test e_w isa InflatedTensorMapping | 33 @test e_w isa InflatedTensorMapping |
33 @test e_w isa TensorMapping{T,1,2} where T | 34 @test e_w isa TensorMapping{T,1,2} where T |
34 end | 35 end |
35 end | 36 end |
36 | 37 |
37 @testset "Application" begin | 38 @testset "Application" begin |
38 @testset "1D" begin | 39 @testset "1D" begin |
39 e_l = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}()) | 40 e_l = boundary_restriction(g_1D, e_closure, CartesianBoundary{1,Lower}()) |
40 e_r = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}()) | 41 e_r = boundary_restriction(g_1D, e_closure, CartesianBoundary{1,Upper}()) |
41 | 42 |
42 v = evalOn(g_1D,x->1+x^2) | 43 v = evalOn(g_1D,x->1+x^2) |
43 u = fill(3.124) | 44 u = fill(3.124) |
44 | 45 |
45 @test (e_l*v)[] == v[1] | 46 @test (e_l*v)[] == v[1] |
46 @test (e_r*v)[] == v[end] | 47 @test (e_r*v)[] == v[end] |
47 @test (e_r*v)[1] == v[end] | 48 @test (e_r*v)[1] == v[end] |
48 end | 49 end |
49 | 50 |
50 @testset "2D" begin | 51 @testset "2D" begin |
51 e_w = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Lower}()) | 52 e_w = boundary_restriction(g_2D, e_closure, CartesianBoundary{1,Lower}()) |
52 e_e = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}()) | 53 e_e = boundary_restriction(g_2D, e_closure, CartesianBoundary{1,Upper}()) |
53 e_s = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}()) | 54 e_s = boundary_restriction(g_2D, e_closure, CartesianBoundary{2,Lower}()) |
54 e_n = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}()) | 55 e_n = boundary_restriction(g_2D, e_closure, CartesianBoundary{2,Upper}()) |
55 | 56 |
56 v = rand(11, 15) | 57 v = rand(11, 15) |
57 u = fill(3.124) | 58 u = fill(3.124) |
58 | 59 |
59 @test e_w*v == v[1,:] | 60 @test e_w*v == v[1,:] |