Mercurial > repos > public > sbplib_julia
comparison test/testSbpOperators.jl @ 594:cc86b920531a refactor/toml_operator_format
Change the readoperator function to use the .toml format
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 02 Dec 2020 15:26:13 +0100 |
parents | 8e4f86c4bf75 |
children | 03ef4d4740ab |
comparison
equal
deleted
inserted
replaced
593:fa03dae0ff0b | 594:cc86b920531a |
---|---|
14 @test eltype(s) == Float64 | 14 @test eltype(s) == Float64 |
15 @test SbpOperators.scale(s, 2) == SbpOperators.Stencil((-2,2), (2.,4.,4.,6.,8.)) | 15 @test SbpOperators.scale(s, 2) == SbpOperators.Stencil((-2,2), (2.,4.,4.,6.,8.)) |
16 end | 16 end |
17 | 17 |
18 # @testset "apply_quadrature" begin | 18 # @testset "apply_quadrature" begin |
19 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 19 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
20 # h = 0.5 | 20 # h = 0.5 |
21 # | 21 # |
22 # @test apply_quadrature(op, h, 1.0, 10, 100) == h | 22 # @test apply_quadrature(op, h, 1.0, 10, 100) == h |
23 # | 23 # |
24 # N = 10 | 24 # N = 10 |
35 # @test apply_quadrature(op, h, v[i], i, N) == q[i]*v[i] | 35 # @test apply_quadrature(op, h, v[i], i, N) == q[i]*v[i] |
36 # end | 36 # end |
37 # end | 37 # end |
38 | 38 |
39 @testset "SecondDerivative" begin | 39 @testset "SecondDerivative" begin |
40 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 40 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
41 L = 3.5 | 41 L = 3.5 |
42 g = EquidistantGrid(101, 0.0, L) | 42 g = EquidistantGrid(101, 0.0, L) |
43 Dₓₓ = SecondDerivative(g,op.innerStencil,op.closureStencils) | 43 Dₓₓ = SecondDerivative(g,op.innerStencil,op.closureStencils) |
44 | 44 |
45 f0(x) = 1. | 45 f0(x) = 1. |
75 @test Dₓₓ*v5 ≈ -v5 atol=5e-4 norm=l2 | 75 @test Dₓₓ*v5 ≈ -v5 atol=5e-4 norm=l2 |
76 end | 76 end |
77 | 77 |
78 | 78 |
79 @testset "Laplace2D" begin | 79 @testset "Laplace2D" begin |
80 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 80 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
81 Lx = 1.5 | 81 Lx = 1.5 |
82 Ly = 3.2 | 82 Ly = 3.2 |
83 g = EquidistantGrid((102,131), (0.0, 0.0), (Lx,Ly)) | 83 g = EquidistantGrid((102,131), (0.0, 0.0), (Lx,Ly)) |
84 L = Laplace(g, op.innerStencil, op.closureStencils) | 84 L = Laplace(g, op.innerStencil, op.closureStencils) |
85 | 85 |
117 @test L*v4 ≈ v2 atol=5e-4 norm=l2 | 117 @test L*v4 ≈ v2 atol=5e-4 norm=l2 |
118 @test L*v5 ≈ v5ₓₓ atol=5e-4 norm=l2 | 118 @test L*v5 ≈ v5ₓₓ atol=5e-4 norm=l2 |
119 end | 119 end |
120 | 120 |
121 @testset "DiagonalInnerProduct" begin | 121 @testset "DiagonalInnerProduct" begin |
122 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 122 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
123 L = 2.3 | 123 L = 2.3 |
124 g = EquidistantGrid(77, 0.0, L) | 124 g = EquidistantGrid(77, 0.0, L) |
125 H = DiagonalInnerProduct(g,op.quadratureClosure) | 125 H = DiagonalInnerProduct(g,op.quadratureClosure) |
126 v = ones(Float64, size(g)) | 126 v = ones(Float64, size(g)) |
127 | 127 |
130 @test sum(H*v) ≈ L | 130 @test sum(H*v) ≈ L |
131 @test H*v == H'*v | 131 @test H*v == H'*v |
132 end | 132 end |
133 | 133 |
134 @testset "Quadrature" begin | 134 @testset "Quadrature" begin |
135 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 135 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
136 Lx = 2.3 | 136 Lx = 2.3 |
137 Ly = 5.2 | 137 Ly = 5.2 |
138 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) | 138 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) |
139 | 139 |
140 Q = Quadrature(g, op.quadratureClosure) | 140 Q = Quadrature(g, op.quadratureClosure) |
150 | 150 |
151 @test Q*v == Q'*v | 151 @test Q*v == Q'*v |
152 end | 152 end |
153 | 153 |
154 @testset "InverseDiagonalInnerProduct" begin | 154 @testset "InverseDiagonalInnerProduct" begin |
155 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 155 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
156 L = 2.3 | 156 L = 2.3 |
157 g = EquidistantGrid(77, 0.0, L) | 157 g = EquidistantGrid(77, 0.0, L) |
158 H = DiagonalInnerProduct(g, op.quadratureClosure) | 158 H = DiagonalInnerProduct(g, op.quadratureClosure) |
159 Hi = InverseDiagonalInnerProduct(g,op.quadratureClosure) | 159 Hi = InverseDiagonalInnerProduct(g,op.quadratureClosure) |
160 v = evalOn(g, x->sin(x)) | 160 v = evalOn(g, x->sin(x)) |
164 @test Hi*H*v ≈ v | 164 @test Hi*H*v ≈ v |
165 @test Hi*v == Hi'*v | 165 @test Hi*v == Hi'*v |
166 end | 166 end |
167 | 167 |
168 @testset "InverseQuadrature" begin | 168 @testset "InverseQuadrature" begin |
169 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 169 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
170 Lx = 7.3 | 170 Lx = 7.3 |
171 Ly = 8.2 | 171 Ly = 8.2 |
172 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) | 172 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) |
173 | 173 |
174 Q = Quadrature(g, op.quadratureClosure) | 174 Q = Quadrature(g, op.quadratureClosure) |
180 @test_broken Qinv*(Q*v) ≈ v | 180 @test_broken Qinv*(Q*v) ≈ v |
181 @test Qinv*v == Qinv'*v | 181 @test Qinv*v == Qinv'*v |
182 end | 182 end |
183 | 183 |
184 @testset "BoundaryRestrictrion" begin | 184 @testset "BoundaryRestrictrion" begin |
185 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 185 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
186 g_1D = EquidistantGrid(11, 0.0, 1.0) | 186 g_1D = EquidistantGrid(11, 0.0, 1.0) |
187 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | 187 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) |
188 | 188 |
189 @testset "Constructors" begin | 189 @testset "Constructors" begin |
190 @testset "1D" begin | 190 @testset "1D" begin |
318 end | 318 end |
319 | 319 |
320 end | 320 end |
321 # | 321 # |
322 # @testset "NormalDerivative" begin | 322 # @testset "NormalDerivative" begin |
323 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 323 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
324 # g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0)) | 324 # g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0)) |
325 # | 325 # |
326 # d_w = NormalDerivative(op, g, CartesianBoundary{1,Lower}()) | 326 # d_w = NormalDerivative(op, g, CartesianBoundary{1,Lower}()) |
327 # d_e = NormalDerivative(op, g, CartesianBoundary{1,Upper}()) | 327 # d_e = NormalDerivative(op, g, CartesianBoundary{1,Upper}()) |
328 # d_s = NormalDerivative(op, g, CartesianBoundary{2,Lower}()) | 328 # d_s = NormalDerivative(op, g, CartesianBoundary{2,Lower}()) |
395 # @test_broken d_s*g_x .≈ G_s | 395 # @test_broken d_s*g_x .≈ G_s |
396 # @test_broken d_n*g_x .≈ G_n | 396 # @test_broken d_n*g_x .≈ G_n |
397 # end | 397 # end |
398 # | 398 # |
399 # @testset "BoundaryQuadrature" begin | 399 # @testset "BoundaryQuadrature" begin |
400 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 400 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
401 # g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0)) | 401 # g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0)) |
402 # | 402 # |
403 # H_w = BoundaryQuadrature(op, g, CartesianBoundary{1,Lower}()) | 403 # H_w = BoundaryQuadrature(op, g, CartesianBoundary{1,Lower}()) |
404 # H_e = BoundaryQuadrature(op, g, CartesianBoundary{1,Upper}()) | 404 # H_e = BoundaryQuadrature(op, g, CartesianBoundary{1,Upper}()) |
405 # H_s = BoundaryQuadrature(op, g, CartesianBoundary{2,Lower}()) | 405 # H_s = BoundaryQuadrature(op, g, CartesianBoundary{2,Lower}()) |