Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/volumeops/laplace/laplace_test.jl @ 1018:5ec49dd2c7c4 feature/stencil_set_type
Reintroduce read_stencil_set
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 22 Mar 2022 09:57:28 +0100 |
parents | b6238afd3bb0 |
children | 7fc8df5157a7 |
comparison
equal
deleted
inserted
replaced
991:37fd8c1cadb2 | 1018:5ec49dd2c7c4 |
---|---|
4 using Sbplib.Grids | 4 using Sbplib.Grids |
5 using Sbplib.LazyTensors | 5 using Sbplib.LazyTensors |
6 | 6 |
7 # Default stencils (4th order) | 7 # Default stencils (4th order) |
8 operator_path = sbp_operators_path()*"standard_diagonal.toml" | 8 operator_path = sbp_operators_path()*"standard_diagonal.toml" |
9 stencil_set = StencilSet(operator_path; order=4) | 9 stencil_set = read_stencil_set(operator_path; order=4) |
10 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | 10 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) |
11 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | 11 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) |
12 g_1D = EquidistantGrid(101, 0.0, 1.) | 12 g_1D = EquidistantGrid(101, 0.0, 1.) |
13 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.)) | 13 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.)) |
14 | 14 |
40 Δ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)) |
41 | 41 |
42 # 2nd order interior stencil, 1st order boundary stencil, | 42 # 2nd order interior stencil, 1st order boundary stencil, |
43 # 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. |
44 @testset "2nd order" begin | 44 @testset "2nd order" begin |
45 stencil_set = StencilSet(operator_path; order=2) | 45 stencil_set = read_stencil_set(operator_path; order=2) |
46 Δ = Laplace(g_3D, stencil_set) | 46 Δ = Laplace(g_3D, stencil_set) |
47 @test Δ*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 47 @test Δ*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |
48 @test Δ*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 48 @test Δ*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |
49 @test Δ*polynomials[3] ≈ polynomials[1] atol = 5e-9 | 49 @test Δ*polynomials[3] ≈ polynomials[1] atol = 5e-9 |
50 @test Δ*v ≈ Δv rtol = 5e-2 norm = l2 | 50 @test Δ*v ≈ Δv rtol = 5e-2 norm = l2 |
51 end | 51 end |
52 | 52 |
53 # 4th order interior stencil, 2nd order boundary stencil, | 53 # 4th order interior stencil, 2nd order boundary stencil, |
54 # implies that L*v should be exact for binomials up to order 3. | 54 # implies that L*v should be exact for binomials up to order 3. |
55 @testset "4th order" begin | 55 @testset "4th order" begin |
56 stencil_set = StencilSet(operator_path; order=4) | 56 stencil_set = read_stencil_set(operator_path; order=4) |
57 Δ = Laplace(g_3D, stencil_set) | 57 Δ = Laplace(g_3D, stencil_set) |
58 # NOTE: high tolerances for checking the "exact" differentiation | 58 # NOTE: high tolerances for checking the "exact" differentiation |
59 # due to accumulation of round-off errors/cancellation errors? | 59 # due to accumulation of round-off errors/cancellation errors? |
60 @test Δ*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 60 @test Δ*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |
61 @test Δ*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 | 61 @test Δ*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 |