Mercurial > repos > public > sbplib_julia
comparison test/testSbpOperators.jl @ 690:1accc3e051d0 refactor/operator_naming
Start changing the name of functions creating operators that are not types to lower case. E.g SecondDerivative->second_derivative
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 12 Feb 2021 16:16:45 +0100 |
parents | e14627e79a54 |
children | 6ab473e0ea80 |
comparison
equal
deleted
inserted
replaced
674:621460cf8279 | 690:1accc3e051d0 |
---|---|
239 g_1D = EquidistantGrid(121, 0.0, Lx) | 239 g_1D = EquidistantGrid(121, 0.0, Lx) |
240 g_2D = EquidistantGrid((121,123), (0.0, 0.0), (Lx, Ly)) | 240 g_2D = EquidistantGrid((121,123), (0.0, 0.0), (Lx, Ly)) |
241 | 241 |
242 @testset "Constructors" begin | 242 @testset "Constructors" begin |
243 @testset "1D" begin | 243 @testset "1D" begin |
244 Dₓₓ = SecondDerivative(g_1D,op.innerStencil,op.closureStencils) | 244 Dₓₓ = second_derivative(g_1D,op.innerStencil,op.closureStencils) |
245 @test Dₓₓ == SecondDerivative(g_1D,op.innerStencil,op.closureStencils,1) | 245 @test Dₓₓ == second_derivative(g_1D,op.innerStencil,op.closureStencils,1) |
246 @test Dₓₓ isa VolumeOperator | 246 @test Dₓₓ isa VolumeOperator |
247 end | 247 end |
248 @testset "2D" begin | 248 @testset "2D" begin |
249 Dₓₓ = SecondDerivative(g_2D,op.innerStencil,op.closureStencils,1) | 249 Dₓₓ = second_derivative(g_2D,op.innerStencil,op.closureStencils,1) |
250 D2 = SecondDerivative(g_1D,op.innerStencil,op.closureStencils) | 250 D2 = second_derivative(g_1D,op.innerStencil,op.closureStencils) |
251 I = IdentityMapping{Float64}(size(g_2D)[2]) | 251 I = IdentityMapping{Float64}(size(g_2D)[2]) |
252 @test Dₓₓ == D2⊗I | 252 @test Dₓₓ == D2⊗I |
253 @test Dₓₓ isa TensorMapping{T,2,2} where T | 253 @test Dₓₓ isa TensorMapping{T,2,2} where T |
254 end | 254 end |
255 end | 255 end |
270 | 270 |
271 # 2nd order interior stencil, 1nd order boundary stencil, | 271 # 2nd order interior stencil, 1nd order boundary stencil, |
272 # implies that L*v should be exact for monomials up to order 2. | 272 # implies that L*v should be exact for monomials up to order 2. |
273 @testset "2nd order" begin | 273 @testset "2nd order" begin |
274 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) | 274 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) |
275 Dₓₓ = SecondDerivative(g_1D,op.innerStencil,op.closureStencils) | 275 Dₓₓ = second_derivative(g_1D,op.innerStencil,op.closureStencils) |
276 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 276 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
277 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 277 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
278 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 | 278 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 |
279 @test Dₓₓ*v ≈ vₓₓ rtol = 5e-2 norm = l2 | 279 @test Dₓₓ*v ≈ vₓₓ rtol = 5e-2 norm = l2 |
280 end | 280 end |
281 | 281 |
282 # 4th order interior stencil, 2nd order boundary stencil, | 282 # 4th order interior stencil, 2nd order boundary stencil, |
283 # implies that L*v should be exact for monomials up to order 3. | 283 # implies that L*v should be exact for monomials up to order 3. |
284 @testset "4th order" begin | 284 @testset "4th order" begin |
285 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 285 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
286 Dₓₓ = SecondDerivative(g_1D,op.innerStencil,op.closureStencils) | 286 Dₓₓ = second_derivative(g_1D,op.innerStencil,op.closureStencils) |
287 # NOTE: high tolerances for checking the "exact" differentiation | 287 # NOTE: high tolerances for checking the "exact" differentiation |
288 # due to accumulation of round-off errors/cancellation errors? | 288 # due to accumulation of round-off errors/cancellation errors? |
289 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 289 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
290 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 290 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
291 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 | 291 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 |
307 | 307 |
308 # 2nd order interior stencil, 1st order boundary stencil, | 308 # 2nd order interior stencil, 1st order boundary stencil, |
309 # implies that L*v should be exact for binomials up to order 2. | 309 # implies that L*v should be exact for binomials up to order 2. |
310 @testset "2nd order" begin | 310 @testset "2nd order" begin |
311 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) | 311 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) |
312 Dyy = SecondDerivative(g_2D,op.innerStencil,op.closureStencils,2) | 312 Dyy = second_derivative(g_2D,op.innerStencil,op.closureStencils,2) |
313 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 313 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
314 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 314 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
315 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 | 315 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 |
316 @test Dyy*v ≈ v_yy rtol = 5e-2 norm = l2 | 316 @test Dyy*v ≈ v_yy rtol = 5e-2 norm = l2 |
317 end | 317 end |
318 | 318 |
319 # 4th order interior stencil, 2nd order boundary stencil, | 319 # 4th order interior stencil, 2nd order boundary stencil, |
320 # implies that L*v should be exact for binomials up to order 3. | 320 # implies that L*v should be exact for binomials up to order 3. |
321 @testset "4th order" begin | 321 @testset "4th order" begin |
322 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 322 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
323 Dyy = SecondDerivative(g_2D,op.innerStencil,op.closureStencils,2) | 323 Dyy = second_derivative(g_2D,op.innerStencil,op.closureStencils,2) |
324 # NOTE: high tolerances for checking the "exact" differentiation | 324 # NOTE: high tolerances for checking the "exact" differentiation |
325 # due to accumulation of round-off errors/cancellation errors? | 325 # due to accumulation of round-off errors/cancellation errors? |
326 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 326 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
327 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 327 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
328 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 | 328 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 |
337 g_1D = EquidistantGrid(101, 0.0, 1.) | 337 g_1D = EquidistantGrid(101, 0.0, 1.) |
338 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.)) | 338 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.)) |
339 @testset "Constructors" begin | 339 @testset "Constructors" begin |
340 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 340 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
341 @testset "1D" begin | 341 @testset "1D" begin |
342 L = Laplace(g_1D, op.innerStencil, op.closureStencils) | 342 L = laplace(g_1D, op.innerStencil, op.closureStencils) |
343 @test L == SecondDerivative(g_1D, op.innerStencil, op.closureStencils) | 343 @test L == second_derivative(g_1D, op.innerStencil, op.closureStencils) |
344 @test L isa TensorMapping{T,1,1} where T | 344 @test L isa TensorMapping{T,1,1} where T |
345 end | 345 end |
346 @testset "3D" begin | 346 @testset "3D" begin |
347 L = Laplace(g_3D, op.innerStencil, op.closureStencils) | 347 L = laplace(g_3D, op.innerStencil, op.closureStencils) |
348 @test L isa TensorMapping{T,3,3} where T | 348 @test L isa TensorMapping{T,3,3} where T |
349 Dxx = SecondDerivative(g_3D, op.innerStencil, op.closureStencils,1) | 349 Dxx = second_derivative(g_3D, op.innerStencil, op.closureStencils,1) |
350 Dyy = SecondDerivative(g_3D, op.innerStencil, op.closureStencils,2) | 350 Dyy = second_derivative(g_3D, op.innerStencil, op.closureStencils,2) |
351 Dzz = SecondDerivative(g_3D, op.innerStencil, op.closureStencils,3) | 351 Dzz = second_derivative(g_3D, op.innerStencil, op.closureStencils,3) |
352 @test L == Dxx + Dyy + Dzz | 352 @test L == Dxx + Dyy + Dzz |
353 end | 353 end |
354 end | 354 end |
355 | 355 |
356 # Exact differentiation is measured point-wise. In other cases | 356 # Exact differentiation is measured point-wise. In other cases |
368 | 368 |
369 # 2nd order interior stencil, 1st order boundary stencil, | 369 # 2nd order interior stencil, 1st order boundary stencil, |
370 # implies that L*v should be exact for binomials up to order 2. | 370 # implies that L*v should be exact for binomials up to order 2. |
371 @testset "2nd order" begin | 371 @testset "2nd order" begin |
372 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) | 372 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) |
373 L = Laplace(g_3D,op.innerStencil,op.closureStencils) | 373 L = laplace(g_3D,op.innerStencil,op.closureStencils) |
374 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 374 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |
375 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 375 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |
376 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9 | 376 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9 |
377 @test L*v ≈ Δv rtol = 5e-2 norm = l2 | 377 @test L*v ≈ Δv rtol = 5e-2 norm = l2 |
378 end | 378 end |
379 | 379 |
380 # 4th order interior stencil, 2nd order boundary stencil, | 380 # 4th order interior stencil, 2nd order boundary stencil, |
381 # implies that L*v should be exact for binomials up to order 3. | 381 # implies that L*v should be exact for binomials up to order 3. |
382 @testset "4th order" begin | 382 @testset "4th order" begin |
383 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 383 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
384 L = Laplace(g_3D,op.innerStencil,op.closureStencils) | 384 L = laplace(g_3D,op.innerStencil,op.closureStencils) |
385 # NOTE: high tolerances for checking the "exact" differentiation | 385 # NOTE: high tolerances for checking the "exact" differentiation |
386 # due to accumulation of round-off errors/cancellation errors? | 386 # due to accumulation of round-off errors/cancellation errors? |
387 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 387 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |
388 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 388 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |
389 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9 | 389 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9 |
569 @test op_l == BoundaryOperator(g_1D,closure_stencil,Lower()) | 569 @test op_l == BoundaryOperator(g_1D,closure_stencil,Lower()) |
570 @test op_l == boundary_operator(g_1D,closure_stencil,CartesianBoundary{1,Lower}()) | 570 @test op_l == boundary_operator(g_1D,closure_stencil,CartesianBoundary{1,Lower}()) |
571 @test op_l isa TensorMapping{T,0,1} where T | 571 @test op_l isa TensorMapping{T,0,1} where T |
572 | 572 |
573 op_r = BoundaryOperator{Upper}(closure_stencil,size(g_1D)[1]) | 573 op_r = BoundaryOperator{Upper}(closure_stencil,size(g_1D)[1]) |
574 @test op_r == BoundaryRestriction(g_1D,closure_stencil,Upper()) | 574 @test op_r == BoundaryOperator(g_1D,closure_stencil,Upper()) |
575 @test op_r == boundary_operator(g_1D,closure_stencil,CartesianBoundary{1,Upper}()) | 575 @test op_r == boundary_operator(g_1D,closure_stencil,CartesianBoundary{1,Upper}()) |
576 @test op_r isa TensorMapping{T,0,1} where T | 576 @test op_r isa TensorMapping{T,0,1} where T |
577 end | 577 end |
578 | 578 |
579 @testset "2D" begin | 579 @testset "2D" begin |
700 @inferred apply_transpose(op_r, u, Index(11,Upper)) | 700 @inferred apply_transpose(op_r, u, Index(11,Upper)) |
701 end | 701 end |
702 | 702 |
703 end | 703 end |
704 | 704 |
705 @testset "BoundaryRestriction" begin | 705 @testset "boundary_restriction" begin |
706 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 706 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
707 g_1D = EquidistantGrid(11, 0.0, 1.0) | 707 g_1D = EquidistantGrid(11, 0.0, 1.0) |
708 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | 708 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) |
709 | 709 |
710 @testset "Constructors" begin | 710 @testset "boundary_restriction" begin |
711 @testset "1D" begin | 711 @testset "1D" begin |
712 e_l = BoundaryRestriction(g_1D,op.eClosure,Lower()) | 712 e_l = boundary_restriction(g_1D,op.eClosure,Lower()) |
713 @test e_l == BoundaryRestriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}()) | 713 @test e_l == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}()) |
714 @test e_l == BoundaryOperator(g_1D,op.eClosure,Lower()) | 714 @test e_l == BoundaryOperator(g_1D,op.eClosure,Lower()) |
715 @test e_l isa BoundaryOperator{T,Lower} where T | 715 @test e_l isa BoundaryOperator{T,Lower} where T |
716 @test e_l isa TensorMapping{T,0,1} where T | 716 @test e_l isa TensorMapping{T,0,1} where T |
717 | 717 |
718 e_r = BoundaryRestriction(g_1D,op.eClosure,Upper()) | 718 e_r = boundary_restriction(g_1D,op.eClosure,Upper()) |
719 @test e_r == BoundaryRestriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}()) | 719 @test e_r == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}()) |
720 @test e_r == BoundaryOperator(g_1D,op.eClosure,Upper()) | 720 @test e_r == BoundaryOperator(g_1D,op.eClosure,Upper()) |
721 @test e_r isa BoundaryOperator{T,Upper} where T | 721 @test e_r isa BoundaryOperator{T,Upper} where T |
722 @test e_r isa TensorMapping{T,0,1} where T | 722 @test e_r isa TensorMapping{T,0,1} where T |
723 end | 723 end |
724 | 724 |
725 @testset "2D" begin | 725 @testset "2D" begin |
726 e_w = BoundaryRestriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}()) | 726 e_w = boundary_restriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}()) |
727 @test e_w isa InflatedTensorMapping | 727 @test e_w isa InflatedTensorMapping |
728 @test e_w isa TensorMapping{T,1,2} where T | 728 @test e_w isa TensorMapping{T,1,2} where T |
729 end | 729 end |
730 end | 730 end |
731 | 731 |
732 @testset "Application" begin | 732 @testset "Application" begin |
733 @testset "1D" begin | 733 @testset "1D" begin |
734 e_l = BoundaryRestriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}()) | 734 e_l = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}()) |
735 e_r = BoundaryRestriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}()) | 735 e_r = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}()) |
736 | 736 |
737 v = evalOn(g_1D,x->1+x^2) | 737 v = evalOn(g_1D,x->1+x^2) |
738 u = fill(3.124) | 738 u = fill(3.124) |
739 | 739 |
740 @test (e_l*v)[] == v[1] | 740 @test (e_l*v)[] == v[1] |
741 @test (e_r*v)[] == v[end] | 741 @test (e_r*v)[] == v[end] |
742 @test (e_r*v)[1] == v[end] | 742 @test (e_r*v)[1] == v[end] |
743 end | 743 end |
744 | 744 |
745 @testset "2D" begin | 745 @testset "2D" begin |
746 e_w = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{1,Lower}()) | 746 e_w = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Lower}()) |
747 e_e = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}()) | 747 e_e = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}()) |
748 e_s = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}()) | 748 e_s = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}()) |
749 e_n = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}()) | 749 e_n = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}()) |
750 | 750 |
751 v = rand(11, 15) | 751 v = rand(11, 15) |
752 u = fill(3.124) | 752 u = fill(3.124) |
753 | 753 |
754 @test e_w*v == v[1,:] | 754 @test e_w*v == v[1,:] |
757 @test e_n*v == v[:,end] | 757 @test e_n*v == v[:,end] |
758 end | 758 end |
759 end | 759 end |
760 end | 760 end |
761 | 761 |
762 @testset "NormalDerivative" begin | 762 @testset "normal_derivative" begin |
763 g_1D = EquidistantGrid(11, 0.0, 1.0) | 763 g_1D = EquidistantGrid(11, 0.0, 1.0) |
764 g_2D = EquidistantGrid((11,12), (0.0, 0.0), (1.0,1.0)) | 764 g_2D = EquidistantGrid((11,12), (0.0, 0.0), (1.0,1.0)) |
765 @testset "Constructors" begin | 765 @testset "normal_derivative" begin |
766 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 766 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
767 @testset "1D" begin | 767 @testset "1D" begin |
768 d_l = NormalDerivative(g_1D, op.dClosure, Lower()) | 768 d_l = normal_derivative(g_1D, op.dClosure, Lower()) |
769 @test d_l == NormalDerivative(g_1D, op.dClosure, CartesianBoundary{1,Lower}()) | 769 @test d_l == normal_derivative(g_1D, op.dClosure, CartesianBoundary{1,Lower}()) |
770 @test d_l isa BoundaryOperator{T,Lower} where T | 770 @test d_l isa BoundaryOperator{T,Lower} where T |
771 @test d_l isa TensorMapping{T,0,1} where T | 771 @test d_l isa TensorMapping{T,0,1} where T |
772 end | 772 end |
773 @testset "2D" begin | 773 @testset "2D" begin |
774 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 774 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
775 d_w = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{1,Lower}()) | 775 d_w = normal_derivative(g_2D, op.dClosure, CartesianBoundary{1,Lower}()) |
776 d_n = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{2,Upper}()) | 776 d_n = normal_derivative(g_2D, op.dClosure, CartesianBoundary{2,Upper}()) |
777 Ix = IdentityMapping{Float64}((size(g_2D)[1],)) | 777 Ix = IdentityMapping{Float64}((size(g_2D)[1],)) |
778 Iy = IdentityMapping{Float64}((size(g_2D)[2],)) | 778 Iy = IdentityMapping{Float64}((size(g_2D)[2],)) |
779 d_l = NormalDerivative(restrict(g_2D,1),op.dClosure,Lower()) | 779 d_l = normal_derivative(restrict(g_2D,1),op.dClosure,Lower()) |
780 d_r = NormalDerivative(restrict(g_2D,2),op.dClosure,Upper()) | 780 d_r = normal_derivative(restrict(g_2D,2),op.dClosure,Upper()) |
781 @test d_w == d_l⊗Iy | 781 @test d_w == d_l⊗Iy |
782 @test d_n == Ix⊗d_r | 782 @test d_n == Ix⊗d_r |
783 @test d_w isa TensorMapping{T,1,2} where T | 783 @test d_w isa TensorMapping{T,1,2} where T |
784 @test d_n isa TensorMapping{T,1,2} where T | 784 @test d_n isa TensorMapping{T,1,2} where T |
785 end | 785 end |
789 v∂x = evalOn(g_2D, (x,y)-> 2*x + y) | 789 v∂x = evalOn(g_2D, (x,y)-> 2*x + y) |
790 v∂y = evalOn(g_2D, (x,y)-> 2*(y-1) + x) | 790 v∂y = evalOn(g_2D, (x,y)-> 2*(y-1) + x) |
791 # TODO: Test for higher order polynomials? | 791 # TODO: Test for higher order polynomials? |
792 @testset "2nd order" begin | 792 @testset "2nd order" begin |
793 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) | 793 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) |
794 d_w = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{1,Lower}()) | 794 d_w = normal_derivative(g_2D, op.dClosure, CartesianBoundary{1,Lower}()) |
795 d_e = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{1,Upper}()) | 795 d_e = normal_derivative(g_2D, op.dClosure, CartesianBoundary{1,Upper}()) |
796 d_s = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{2,Lower}()) | 796 d_s = normal_derivative(g_2D, op.dClosure, CartesianBoundary{2,Lower}()) |
797 d_n = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{2,Upper}()) | 797 d_n = normal_derivative(g_2D, op.dClosure, CartesianBoundary{2,Upper}()) |
798 | 798 |
799 @test d_w*v ≈ v∂x[1,:] atol = 1e-13 | 799 @test d_w*v ≈ v∂x[1,:] atol = 1e-13 |
800 @test d_e*v ≈ -v∂x[end,:] atol = 1e-13 | 800 @test d_e*v ≈ -v∂x[end,:] atol = 1e-13 |
801 @test d_s*v ≈ v∂y[:,1] atol = 1e-13 | 801 @test d_s*v ≈ v∂y[:,1] atol = 1e-13 |
802 @test d_n*v ≈ -v∂y[:,end] atol = 1e-13 | 802 @test d_n*v ≈ -v∂y[:,end] atol = 1e-13 |
803 end | 803 end |
804 | 804 |
805 @testset "4th order" begin | 805 @testset "4th order" begin |
806 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 806 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
807 d_w = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{1,Lower}()) | 807 d_w = normal_derivative(g_2D, op.dClosure, CartesianBoundary{1,Lower}()) |
808 d_e = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{1,Upper}()) | 808 d_e = normal_derivative(g_2D, op.dClosure, CartesianBoundary{1,Upper}()) |
809 d_s = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{2,Lower}()) | 809 d_s = normal_derivative(g_2D, op.dClosure, CartesianBoundary{2,Lower}()) |
810 d_n = NormalDerivative(g_2D, op.dClosure, CartesianBoundary{2,Upper}()) | 810 d_n = normal_derivative(g_2D, op.dClosure, CartesianBoundary{2,Upper}()) |
811 | 811 |
812 @test d_w*v ≈ v∂x[1,:] atol = 1e-13 | 812 @test d_w*v ≈ v∂x[1,:] atol = 1e-13 |
813 @test d_e*v ≈ -v∂x[end,:] atol = 1e-13 | 813 @test d_e*v ≈ -v∂x[end,:] atol = 1e-13 |
814 @test d_s*v ≈ v∂y[:,1] atol = 1e-13 | 814 @test d_s*v ≈ v∂y[:,1] atol = 1e-13 |
815 @test d_n*v ≈ -v∂y[:,end] atol = 1e-13 | 815 @test d_n*v ≈ -v∂y[:,end] atol = 1e-13 |