comparison test/SbpOperators/boundaryops/normal_derivative_test.jl @ 1680:b30db2ea34ed feature/sbp_operators/laplace_curvilinear

Add concistency tests for normal_derivative and and fix bug regarding sign of boundary
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 30 Jun 2024 15:57:22 +0200
parents f4dc17cfafce
children de2c4b2663b4
comparison
equal deleted inserted replaced
1679:529b533a1dbb 1680:b30db2ea34ed
64 @testset "MappedGrid" begin 64 @testset "MappedGrid" begin
65 c = Chart(unitsquare()) do (ξ,η) 65 c = Chart(unitsquare()) do (ξ,η)
66 @SVector[2ξ + η*(1-η), 3η+(1+η/2)*ξ^2] 66 @SVector[2ξ + η*(1-η), 3η+(1+η/2)*ξ^2]
67 end 67 end
68 Grids.jacobian(c::typeof(c), (ξ,η)) = @SMatrix[2 1-2η; (2+η)*ξ 3+ξ^2/2] 68 Grids.jacobian(c::typeof(c), (ξ,η)) = @SMatrix[2 1-2η; (2+η)*ξ 3+ξ^2/2]
69
70 mg = equidistant_grid(c, 10,13) 69 mg = equidistant_grid(c, 10,13)
71 70
72 b_w, b_e, b_s, b_n = boundary_identifiers(mg)
73 71
74 @test_broken normal_derivative(mg, stencil_set, b_w) isa LazyTensor{<:Any, 1, 2} 72 # x̄((ξ, η)) = @SVector[ξ, η*(1+ξ*(ξ-1))]
75 @test_broken normal_derivative(mg, stencil_set, b_e) isa LazyTensor{<:Any, 1, 2} 73 # J((ξ, η)) = @SMatrix[
76 @test_broken normal_derivative(mg, stencil_set, b_s) isa LazyTensor{<:Any, 1, 2} 74 # 1 0;
77 @test_broken normal_derivative(mg, stencil_set, b_n) isa LazyTensor{<:Any, 1, 2} 75 # η*(2ξ-1) 1+ξ*(ξ-1);
76 # ]
77 # mg = mapped_grid(x̄, J, 20, 21)
78
79
80 # x̄((ξ, η)) = @SVector[ξ,η]
81 # J((ξ, η)) = @SMatrix[
82 # 1 0;
83 # 0 1;
84 # ]
85 # mg = mapped_grid(identity, J, 10, 11)
86
87 for bid ∈ boundary_identifiers(mg)
88 @testset let bid=bid
89 @test normal_derivative(mg, stencil_set, bid) isa LazyTensor{<:Any, 1, 2}
90 end
91 end
92
93 @testset "Consistency" begin
94 v = map(identity, mg)
95
96 @testset "4nd order" begin
97 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4)
98
99 for bid ∈ boundary_identifiers(mg)
100 @testset let bid=bid
101 d = normal_derivative(mg, stencil_set, bid)
102 @test d*v ≈ normal(mg, bid) rtol=1e-13
103 end
104 end
105 end
106 end
78 107
79 @testset "Accuracy" begin 108 @testset "Accuracy" begin
80 v = map(x̄ -> NaN, mg) 109 v = map(x̄ -> NaN, mg)
81 dₙv = map(x̄ -> NaN, mg) 110 dₙv = map(x̄ -> NaN, mg)
82 111