Mercurial > repos > public > sbplib_julia
comparison test/testSbpOperators.jl @ 620:bfc893d03cbf feature/volume_and_boundary_operators
Add NormalDerivative as a BoundaryOperator and reintroduce tests.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 07 Dec 2020 14:05:47 +0100 |
parents | 332f65c1abf3 |
children | 60d7c1752cfa |
comparison
equal
deleted
inserted
replaced
619:332f65c1abf3 | 620:bfc893d03cbf |
---|---|
498 @test e_s'*g_x == G_s | 498 @test e_s'*g_x == G_s |
499 @test e_n'*g_x == G_n | 499 @test e_n'*g_x == G_n |
500 end | 500 end |
501 end | 501 end |
502 end | 502 end |
503 # | 503 |
504 # @testset "NormalDerivative" begin | 504 @testset "NormalDerivative" begin |
505 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 505 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
506 # g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0)) | 506 g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0)) |
507 # | 507 |
508 # d_w = NormalDerivative(op, g, CartesianBoundary{1,Lower}()) | 508 d_w = NormalDerivative(g, op.dClosure, CartesianBoundary{1,Lower}()) |
509 # d_e = NormalDerivative(op, g, CartesianBoundary{1,Upper}()) | 509 d_e = NormalDerivative(g, op.dClosure, CartesianBoundary{1,Upper}()) |
510 # d_s = NormalDerivative(op, g, CartesianBoundary{2,Lower}()) | 510 d_s = NormalDerivative(g, op.dClosure, CartesianBoundary{2,Lower}()) |
511 # d_n = NormalDerivative(op, g, CartesianBoundary{2,Upper}()) | 511 d_n = NormalDerivative(g, op.dClosure, CartesianBoundary{2,Upper}()) |
512 # | 512 |
513 # | 513 |
514 # v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y) | 514 v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y) |
515 # v∂x = evalOn(g, (x,y)-> 2*x + y) | 515 v∂x = evalOn(g, (x,y)-> 2*x + y) |
516 # v∂y = evalOn(g, (x,y)-> 2*(y-1) + x) | 516 v∂y = evalOn(g, (x,y)-> 2*(y-1) + x) |
517 # | 517 |
518 # @test d_w isa TensorMapping{T,2,1} where T | 518 @test d_w isa TensorMapping{T,1,2} where T |
519 # @test d_w' isa TensorMapping{T,1,2} where T | 519 |
520 # | 520 @test d_w*v ≈ v∂x[1,:] |
521 # @test domain_size(d_w, (3,2)) == (2,) | 521 @test d_e*v ≈ -v∂x[end,:] |
522 # @test domain_size(d_e, (3,2)) == (2,) | 522 @test d_s*v ≈ v∂y[:,1] |
523 # @test domain_size(d_s, (3,2)) == (3,) | 523 @test d_n*v ≈ -v∂y[:,end] |
524 # @test domain_size(d_n, (3,2)) == (3,) | 524 |
525 # | 525 |
526 # @test size(d_w'*v) == (6,) | 526 d_x_l = zeros(Float64, size(g)[1]) |
527 # @test size(d_e'*v) == (6,) | 527 d_x_u = zeros(Float64, size(g)[1]) |
528 # @test size(d_s'*v) == (5,) | 528 for i ∈ eachindex(d_x_l) |
529 # @test size(d_n'*v) == (5,) | 529 d_x_l[i] = op.dClosure[i-1] |
530 # | 530 d_x_u[i] = op.dClosure[length(d_x_u)-i] |
531 # @test d_w'*v .≈ v∂x[1,:] | 531 end |
532 # @test d_e'*v .≈ v∂x[5,:] | 532 |
533 # @test d_s'*v .≈ v∂y[:,1] | 533 d_y_l = zeros(Float64, size(g)[2]) |
534 # @test d_n'*v .≈ v∂y[:,6] | 534 d_y_u = zeros(Float64, size(g)[2]) |
535 # | 535 for i ∈ eachindex(d_y_l) |
536 # | 536 d_y_l[i] = op.dClosure[i-1] |
537 # d_x_l = zeros(Float64, 5) | 537 d_y_u[i] = op.dClosure[length(d_y_u)-i] |
538 # d_x_u = zeros(Float64, 5) | 538 end |
539 # for i ∈ eachindex(d_x_l) | 539 |
540 # d_x_l[i] = op.dClosure[i-1] | 540 function prod_matrix(x,y) |
541 # d_x_u[i] = -op.dClosure[length(d_x_u)-i] | 541 G = zeros(Float64, length(x), length(y)) |
542 # end | 542 for I ∈ CartesianIndices(G) |
543 # | 543 G[I] = x[I[1]]*y[I[2]] |
544 # d_y_l = zeros(Float64, 6) | 544 end |
545 # d_y_u = zeros(Float64, 6) | 545 |
546 # for i ∈ eachindex(d_y_l) | 546 return G |
547 # d_y_l[i] = op.dClosure[i-1] | 547 end |
548 # d_y_u[i] = -op.dClosure[length(d_y_u)-i] | 548 |
549 # end | 549 g_x = [1,2,3,4.0,5] |
550 # | 550 g_y = [5,4,3,2,1.0,11] |
551 # function prod_matrix(x,y) | 551 |
552 # G = zeros(Float64, length(x), length(y)) | 552 G_w = prod_matrix(d_x_l, g_y) |
553 # for I ∈ CartesianIndices(G) | 553 G_e = prod_matrix(d_x_u, g_y) |
554 # G[I] = x[I[1]]*y[I[2]] | 554 G_s = prod_matrix(g_x, d_y_l) |
555 # end | 555 G_n = prod_matrix(g_x, d_y_u) |
556 # | 556 |
557 # return G | 557 @test d_w'*g_y ≈ G_w |
558 # end | 558 @test_broken d_e'*g_y ≈ G_e |
559 # | 559 @test d_s'*g_x ≈ G_s |
560 # g_x = [1,2,3,4.0,5] | 560 @test_broken d_n'*g_x ≈ G_n |
561 # g_y = [5,4,3,2,1.0,11] | 561 end |
562 # | |
563 # G_w = prod_matrix(d_x_l, g_y) | |
564 # G_e = prod_matrix(d_x_u, g_y) | |
565 # G_s = prod_matrix(g_x, d_y_l) | |
566 # G_n = prod_matrix(g_x, d_y_u) | |
567 # | |
568 # | |
569 # @test size(d_w*g_y) == (UnknownDim,6) | |
570 # @test size(d_e*g_y) == (UnknownDim,6) | |
571 # @test size(d_s*g_x) == (5,UnknownDim) | |
572 # @test size(d_n*g_x) == (5,UnknownDim) | |
573 # | |
574 # # These tests should be moved to where they are possible (i.e we know what the grid should be) | |
575 # @test_broken d_w*g_y .≈ G_w | |
576 # @test_broken d_e*g_y .≈ G_e | |
577 # @test_broken d_s*g_x .≈ G_s | |
578 # @test_broken d_n*g_x .≈ G_n | |
579 # end | |
580 # | 562 # |
581 # @testset "BoundaryQuadrature" begin | 563 # @testset "BoundaryQuadrature" begin |
582 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | 564 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) |
583 # g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0)) | 565 # g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0)) |
584 # | 566 # |