Mercurial > repos > public > sbplib_julia
comparison DiffOps/test/runtests.jl @ 283:12a12a5cd973 boundary_conditions
Fix tests for Laplace2D.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 09 Jan 2020 13:38:06 +0100 |
parents | ce6a2f3f732a |
children | 0b8e041a1873 |
comparison
equal
deleted
inserted
replaced
282:ce6a2f3f732a | 283:12a12a5cd973 |
---|---|
7 | 7 |
8 @testset "Laplace2D" begin | 8 @testset "Laplace2D" begin |
9 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 9 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
10 Lx = 3.5 | 10 Lx = 3.5 |
11 Ly = 7.2 | 11 Ly = 7.2 |
12 g = EquidistantGrid((21,42), (0.0, 0.0), (Lx,Ly)) | 12 g = EquidistantGrid((42,41), (0.0, 0.0), (Lx,Ly)) |
13 L = Laplace(g, 1., op) | 13 L = Laplace(g, 1., op) |
14 H = quadrature(L) | |
14 | 15 |
15 f0(x::Float64,y::Float64) = 2. | 16 f0(x::Float64,y::Float64) = 2. |
16 f1(x::Float64,y::Float64) = x+y | 17 f1(x::Float64,y::Float64) = x+y |
17 f2(x::Float64,y::Float64) = 1/2*x^2 + 1/2*y^2 | 18 f2(x::Float64,y::Float64) = 1/2*x^2 + 1/2*y^2 |
18 f3(x::Float64,y::Float64) = 1/6*x^3 + 1/6*y^3 | 19 f3(x::Float64,y::Float64) = 1/6*x^3 + 1/6*y^3 |
19 f4(x::Float64,y::Float64) = 1/24*x^4 + 1/24*y^4 | 20 f4(x::Float64,y::Float64) = 1/24*x^4 + 1/24*y^4 |
20 f5(x::Float64,y::Float64) = x^5 + 2*y^3 + 3/2*x^2 + y + 7 | 21 f5(x::Float64,y::Float64) = sin(x) + cos(y) |
21 f5ₓₓ(x::Float64,y::Float64) = 20*x^3 + 12*y + 3 | 22 f5ₓₓ(x::Float64,y::Float64) = -f5(x,y) |
22 | 23 |
23 v0 = evalOn(g,f0) | 24 v0 = evalOn(g,f0) |
24 v1 = evalOn(g,f1) | 25 v1 = evalOn(g,f1) |
25 v2 = evalOn(g,f2) | 26 v2 = evalOn(g,f2) |
26 v3 = evalOn(g,f3) | 27 v3 = evalOn(g,f3) |
28 v5 = evalOn(g,f5) | 29 v5 = evalOn(g,f5) |
29 v5ₓₓ = evalOn(g,f5ₓₓ) | 30 v5ₓₓ = evalOn(g,f5ₓₓ) |
30 | 31 |
31 @test L isa TensorOperator{T,2} where T | 32 @test L isa TensorOperator{T,2} where T |
32 @test L' isa TensorMapping{T,2,2} where T | 33 @test L' isa TensorMapping{T,2,2} where T |
34 | |
33 # TODO: Should perhaps set tolerance level for isapporx instead? | 35 # TODO: Should perhaps set tolerance level for isapporx instead? |
34 equalitytol = 0.5*1e-11 | 36 # Are these tolerance levels resonable or should tests be constructed |
35 accuracytol = 1e-4 | 37 # differently? |
36 @test all(collect(L*v0) .<= equalitytol) | 38 equalitytol = 0.5*1e-10 |
37 @test all(collect(L*v1) .<= equalitytol) | 39 accuracytol = 0.5*1e-3 |
40 # 4th order interior stencil, 2nd order boundary stencil, | |
41 # implies that L*v should be exact for v - monomial up to order 3. | |
42 # Exact differentiation is measured point-wise. For other grid functions | |
43 # the error is measured in the H-norm. | |
44 @test all(abs.(collect(L*v0)) .<= equalitytol) | |
45 @test all(abs.(collect(L*v1)) .<= equalitytol) | |
38 @test all(collect(L*v2) .≈ v0) # Seems to be more accurate | 46 @test all(collect(L*v2) .≈ v0) # Seems to be more accurate |
39 @test all((collect(L*v3) - v1) .<= equalitytol) | 47 @test all(abs.((collect(L*v3) - v1)) .<= equalitytol) |
40 @show maximum(abs.(collect(L*v4) - v2)) | 48 e4 = collect(L*v4) - v2 |
41 @show maximum(abs.(collect(L*v5) - v5ₓₓ)) | 49 e5 = collect(L*v5) - v5ₓₓ |
42 @test_broken all((collect(L*v4) - v2) .<= accuracytol) #TODO: Should be equality? | 50 @test sum(collect(H*e4.^2)) <= accuracytol |
43 @test_broken all((collect(L*v5) - v5ₓₓ) .<= accuracytol) #TODO: This is just wrong | 51 @test sum(collect(H*e5.^2)) <= accuracytol |
44 end | 52 end |
45 | 53 |
46 @testset "Quadrature" begin | 54 @testset "Quadrature" begin |
47 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 55 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
48 Lx = 2.3 | 56 Lx = 2.3 |