Mercurial > repos > public > sbplib_julia
comparison test/testSbpOperators.jl @ 765:fdd48f6ace1c operator_storage_array_of_table
Merge in default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 07 Feb 2021 21:32:21 +0100 |
parents | d34b515b0ae7 e14627e79a54 |
children | 7624a1350ece |
comparison
equal
deleted
inserted
replaced
764:d34b515b0ae7 | 765:fdd48f6ace1c |
---|---|
22 @test s isa Stencil{Float64, 5} | 22 @test s isa Stencil{Float64, 5} |
23 | 23 |
24 @test eltype(s) == Float64 | 24 @test eltype(s) == Float64 |
25 @test SbpOperators.scale(s, 2) == Stencil((-2,2), (2.,4.,4.,6.,8.)) | 25 @test SbpOperators.scale(s, 2) == Stencil((-2,2), (2.,4.,4.,6.,8.)) |
26 | 26 |
27 @test Stencil((1,2,3,4), center=1) == Stencil((0, 3),(1,2,3,4)) | 27 @test Stencil(1,2,3,4; center=1) == Stencil((0, 3),(1,2,3,4)) |
28 @test Stencil((1,2,3,4), center=2) == Stencil((-1, 2),(1,2,3,4)) | 28 @test Stencil(1,2,3,4; center=2) == Stencil((-1, 2),(1,2,3,4)) |
29 @test Stencil((1,2,3,4), center=4) == Stencil((-3, 0),(1,2,3,4)) | 29 @test Stencil(1,2,3,4; center=4) == Stencil((-3, 0),(1,2,3,4)) |
30 | |
31 @test CenteredStencil(1,2,3,4,5) == Stencil((-2, 2), (1,2,3,4,5)) | |
32 @test_throws ArgumentError CenteredStencil(1,2,3,4) | |
30 end | 33 end |
31 | 34 |
32 @testset "parse_rational" begin | 35 @testset "parse_rational" begin |
33 @test SbpOperators.parse_rational("1") isa Rational | 36 @test SbpOperators.parse_rational("1") isa Rational |
34 @test SbpOperators.parse_rational("1") == 1//1 | 37 @test SbpOperators.parse_rational("1") == 1//1 |
103 @test_throws ArgumentError get_stencil_set(parsed_toml; test = 2) | 106 @test_throws ArgumentError get_stencil_set(parsed_toml; test = 2) |
104 @test_throws ArgumentError get_stencil_set(parsed_toml; order = 4) | 107 @test_throws ArgumentError get_stencil_set(parsed_toml; order = 4) |
105 end | 108 end |
106 | 109 |
107 @testset "get_stencil" begin | 110 @testset "get_stencil" begin |
108 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil") == Stencil((-1/2, 0., 1/2), center=2) | 111 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil") == Stencil(-1/2, 0., 1/2, center=2) |
109 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=1) == Stencil((-1/2, 0., 1/2); center=1) | 112 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=1) == Stencil(-1/2, 0., 1/2; center=1) |
110 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=3) == Stencil((-1/2, 0., 1/2); center=3) | 113 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=3) == Stencil(-1/2, 0., 1/2; center=3) |
111 | 114 |
112 @test get_stencil(parsed_toml, "order2", "H", "inner") == Stencil((1.,), center=1) | 115 @test get_stencil(parsed_toml, "order2", "H", "inner") == Stencil(1.; center=1) |
113 | 116 |
114 @test_throws AssertionError get_stencil(parsed_toml, "meta", "type") | 117 @test_throws AssertionError get_stencil(parsed_toml, "meta", "type") |
115 @test_throws AssertionError get_stencil(parsed_toml, "order2", "D1", "closure_stencils") | 118 @test_throws AssertionError get_stencil(parsed_toml, "order2", "D1", "closure_stencils") |
116 end | 119 end |
117 | 120 |
118 @testset "get_stencils" begin | 121 @testset "get_stencils" begin |
119 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(1,)) == (Stencil((-1., 1.), center=1),) | 122 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(1,)) == (Stencil(-1., 1., center=1),) |
120 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(2,)) == (Stencil((-1., 1.), center=2),) | 123 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(2,)) == (Stencil(-1., 1., center=2),) |
121 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=[2]) == (Stencil((-1., 1.), center=2),) | 124 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=[2]) == (Stencil(-1., 1., center=2),) |
122 | 125 |
123 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=[1,1,1,1]) == ( | 126 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=[1,1,1,1]) == ( |
124 Stencil(( 2., -5., 4., -1., 0., 0.), center=1), | 127 Stencil( 2., -5., 4., -1., 0., 0., center=1), |
125 Stencil(( 1., -2., 1., 0., 0., 0.), center=1), | 128 Stencil( 1., -2., 1., 0., 0., 0., center=1), |
126 Stencil(( -4/43, 59/43, -110/43, 59/43, -4/43, 0.), center=1), | 129 Stencil( -4/43, 59/43, -110/43, 59/43, -4/43, 0., center=1), |
127 Stencil(( -1/49, 0., 59/49, -118/49, 64/49, -4/49), center=1), | 130 Stencil( -1/49, 0., 59/49, -118/49, 64/49, -4/49, center=1), |
128 ) | 131 ) |
129 | 132 |
130 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(4,2,3,1)) == ( | 133 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(4,2,3,1)) == ( |
131 Stencil(( 2., -5., 4., -1., 0., 0.), center=4), | 134 Stencil( 2., -5., 4., -1., 0., 0., center=4), |
132 Stencil(( 1., -2., 1., 0., 0., 0.), center=2), | 135 Stencil( 1., -2., 1., 0., 0., 0., center=2), |
133 Stencil(( -4/43, 59/43, -110/43, 59/43, -4/43, 0.), center=3), | 136 Stencil( -4/43, 59/43, -110/43, 59/43, -4/43, 0., center=3), |
134 Stencil(( -1/49, 0., 59/49, -118/49, 64/49, -4/49), center=1), | 137 Stencil( -1/49, 0., 59/49, -118/49, 64/49, -4/49, center=1), |
135 ) | 138 ) |
136 | 139 |
137 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=1:4) == ( | 140 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=1:4) == ( |
138 Stencil(( 2., -5., 4., -1., 0., 0.), center=1), | 141 Stencil( 2., -5., 4., -1., 0., 0., center=1), |
139 Stencil(( 1., -2., 1., 0., 0., 0.), center=2), | 142 Stencil( 1., -2., 1., 0., 0., 0., center=2), |
140 Stencil(( -4/43, 59/43, -110/43, 59/43, -4/43, 0.), center=3), | 143 Stencil( -4/43, 59/43, -110/43, 59/43, -4/43, 0., center=3), |
141 Stencil(( -1/49, 0., 59/49, -118/49, 64/49, -4/49), center=4), | 144 Stencil( -1/49, 0., 59/49, -118/49, 64/49, -4/49, center=4), |
142 ) | 145 ) |
143 | 146 |
144 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3)) | 147 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3)) |
145 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3,5,4)) | 148 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3,5,4)) |
146 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "inner_stencil",centers=(1,2)) | 149 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "inner_stencil",centers=(1,2)) |
152 @test_throws AssertionError get_tuple(parsed_toml, "meta", "type") | 155 @test_throws AssertionError get_tuple(parsed_toml, "meta", "type") |
153 end | 156 end |
154 end | 157 end |
155 | 158 |
156 @testset "VolumeOperator" begin | 159 @testset "VolumeOperator" begin |
157 inner_stencil = Stencil(1/4 .* (1.,2.,1.),center=2) | 160 inner_stencil = CenteredStencil(1/4, 2/4, 1/4) |
158 closure_stencils = (Stencil(1/2 .* (1.,1.),center=1),Stencil((0.,1.),center=2)) | 161 closure_stencils = (Stencil(1/2, 1/2; center=1), Stencil(0.,1.; center=2)) |
159 g_1D = EquidistantGrid(11,0.,1.) | 162 g_1D = EquidistantGrid(11,0.,1.) |
160 g_2D = EquidistantGrid((11,12),(0.,0.),(1.,1.)) | 163 g_2D = EquidistantGrid((11,12),(0.,0.),(1.,1.)) |
161 g_3D = EquidistantGrid((11,12,10),(0.,0.,0.),(1.,1.,1.)) | 164 g_3D = EquidistantGrid((11,12,10),(0.,0.,0.),(1.,1.,1.)) |
162 @testset "Constructors" begin | 165 @testset "Constructors" begin |
163 @testset "1D" begin | 166 @testset "1D" begin |
436 integral(H,v) = sum(H*v) | 439 integral(H,v) = sum(H*v) |
437 @testset "Constructors" begin | 440 @testset "Constructors" begin |
438 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 441 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
439 @testset "1D" begin | 442 @testset "1D" begin |
440 H = DiagonalQuadrature(g_1D,op.quadratureClosure) | 443 H = DiagonalQuadrature(g_1D,op.quadratureClosure) |
441 inner_stencil = Stencil((1.,),center=1) | 444 inner_stencil = CenteredStencil(1.) |
442 @test H == Quadrature(g_1D,inner_stencil,op.quadratureClosure) | 445 @test H == Quadrature(g_1D,inner_stencil,op.quadratureClosure) |
443 @test H isa TensorMapping{T,1,1} where T | 446 @test H isa TensorMapping{T,1,1} where T |
444 end | 447 end |
445 @testset "1D" begin | 448 @testset "1D" begin |
446 H = DiagonalQuadrature(g_2D,op.quadratureClosure) | 449 H = DiagonalQuadrature(g_2D,op.quadratureClosure) |
520 g_2D = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) | 523 g_2D = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) |
521 @testset "Constructors" begin | 524 @testset "Constructors" begin |
522 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 525 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
523 @testset "1D" begin | 526 @testset "1D" begin |
524 Hi = InverseDiagonalQuadrature(g_1D, op.quadratureClosure); | 527 Hi = InverseDiagonalQuadrature(g_1D, op.quadratureClosure); |
525 inner_stencil = Stencil((1.,),center=1) | 528 inner_stencil = CenteredStencil(1.) |
526 closures = () | 529 closures = () |
527 for i = 1:length(op.quadratureClosure) | 530 for i = 1:length(op.quadratureClosure) |
528 closures = (closures...,Stencil(op.quadratureClosure[i].range,1.0./op.quadratureClosure[i].weights)) | 531 closures = (closures...,Stencil(op.quadratureClosure[i].range,1.0./op.quadratureClosure[i].weights)) |
529 end | 532 end |
530 @test Hi == InverseQuadrature(g_1D,inner_stencil,closures) | 533 @test Hi == InverseQuadrature(g_1D,inner_stencil,closures) |