comparison test/SbpOperators/volumeops/laplace/laplace_test.jl @ 864:9a2776352c2a

Merge operator_storage_array_of_table
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 19 Jan 2022 11:08:43 +0100
parents 24df68453890
children 1784b1c0af3e
comparison
equal deleted inserted replaced
858:5088de9b6d65 864:9a2776352c2a
6 6
7 @testset "Laplace" begin 7 @testset "Laplace" begin
8 g_1D = EquidistantGrid(101, 0.0, 1.) 8 g_1D = EquidistantGrid(101, 0.0, 1.)
9 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.)) 9 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.))
10 @testset "Constructors" begin 10 @testset "Constructors" begin
11 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) 11 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4)
12 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"])
13 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"])
12 @testset "1D" begin 14 @testset "1D" begin
13 L = laplace(g_1D, op.innerStencil, op.closureStencils) 15 L = laplace(g_1D, inner_stencil, closure_stencils)
14 @test L == second_derivative(g_1D, op.innerStencil, op.closureStencils) 16 @test L == second_derivative(g_1D, inner_stencil, closure_stencils)
15 @test L isa TensorMapping{T,1,1} where T 17 @test L isa TensorMapping{T,1,1} where T
16 end 18 end
17 @testset "3D" begin 19 @testset "3D" begin
18 L = laplace(g_3D, op.innerStencil, op.closureStencils) 20 L = laplace(g_3D, inner_stencil, closure_stencils)
19 @test L isa TensorMapping{T,3,3} where T 21 @test L isa TensorMapping{T,3,3} where T
20 Dxx = second_derivative(g_3D, op.innerStencil, op.closureStencils,1) 22 Dxx = second_derivative(g_3D, inner_stencil, closure_stencils, 1)
21 Dyy = second_derivative(g_3D, op.innerStencil, op.closureStencils,2) 23 Dyy = second_derivative(g_3D, inner_stencil, closure_stencils, 2)
22 Dzz = second_derivative(g_3D, op.innerStencil, op.closureStencils,3) 24 Dzz = second_derivative(g_3D, inner_stencil, closure_stencils, 3)
23 @test L == Dxx + Dyy + Dzz 25 @test L == Dxx + Dyy + Dzz
24 end 26 end
25 end 27 end
26 28
27 # Exact differentiation is measured point-wise. In other cases 29 # Exact differentiation is measured point-wise. In other cases
38 Δv = evalOn(g_3D,(x,y,z) -> -sin(x) - cos(y) + exp(z)) 40 Δv = evalOn(g_3D,(x,y,z) -> -sin(x) - cos(y) + exp(z))
39 41
40 # 2nd order interior stencil, 1st order boundary stencil, 42 # 2nd order interior stencil, 1st order boundary stencil,
41 # implies that L*v should be exact for binomials up to order 2. 43 # implies that L*v should be exact for binomials up to order 2.
42 @testset "2nd order" begin 44 @testset "2nd order" begin
43 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=2) 45 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2)
44 L = laplace(g_3D,op.innerStencil,op.closureStencils) 46 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"])
47 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"])
48 L = laplace(g_3D, inner_stencil, closure_stencils)
45 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 49 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9
46 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 50 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9
47 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9 51 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9
48 @test L*v ≈ Δv rtol = 5e-2 norm = l2 52 @test L*v ≈ Δv rtol = 5e-2 norm = l2
49 end 53 end
50 54
51 # 4th order interior stencil, 2nd order boundary stencil, 55 # 4th order interior stencil, 2nd order boundary stencil,
52 # implies that L*v should be exact for binomials up to order 3. 56 # implies that L*v should be exact for binomials up to order 3.
53 @testset "4th order" begin 57 @testset "4th order" begin
54 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) 58 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4)
55 L = laplace(g_3D,op.innerStencil,op.closureStencils) 59 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"])
60 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"])
61 L = laplace(g_3D, inner_stencil, closure_stencils)
56 # NOTE: high tolerances for checking the "exact" differentiation 62 # NOTE: high tolerances for checking the "exact" differentiation
57 # due to accumulation of round-off errors/cancellation errors? 63 # due to accumulation of round-off errors/cancellation errors?
58 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 64 @test L*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9
59 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 65 @test L*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9
60 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9 66 @test L*polynomials[3] ≈ polynomials[1] atol = 5e-9