annotate test/testSbpOperators.jl @ 617:f59e1732eacc feature/volume_and_boundary_operators

Merge with default
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 07 Dec 2020 12:07:29 +0100
parents 1db945cba3a2 eaa8c852ddf2
children 332f65c1abf3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
1 using Test
335
f4e3e71a4ff4 Fix `using` commands to refer to local modules within the Sbplib package/module
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
2 using Sbplib.SbpOperators
f4e3e71a4ff4 Fix `using` commands to refer to local modules within the Sbplib package/module
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
3 using Sbplib.Grids
f4e3e71a4ff4 Fix `using` commands to refer to local modules within the Sbplib package/module
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
4 using Sbplib.RegionIndices
f4e3e71a4ff4 Fix `using` commands to refer to local modules within the Sbplib package/module
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
5 using Sbplib.LazyTensors
395
737e597e0e6d Rewrite broken tests as testing that the norm is zero
Jonatan Werpers <jonatan@werpers.com>
parents: 389
diff changeset
6 using LinearAlgebra
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
7 using TOML
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
8
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
9 import Sbplib.SbpOperators.Stencil
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
10
338
2b0c9b30ea3b Add test sets for each submodule to make the test output nicer
Jonatan Werpers <jonatan@werpers.com>
parents: 335
diff changeset
11 @testset "SbpOperators" begin
2b0c9b30ea3b Add test sets for each submodule to make the test output nicer
Jonatan Werpers <jonatan@werpers.com>
parents: 335
diff changeset
12
584
4aa7fe13a984 Add scale() and eltype() methods for stencils
Jonatan Werpers <jonatan@werpers.com>
parents: 397
diff changeset
13 @testset "Stencil" begin
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
14 s = Stencil((-2,2), (1.,2.,2.,3.,4.))
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
15 @test s isa Stencil{Float64, 5}
584
4aa7fe13a984 Add scale() and eltype() methods for stencils
Jonatan Werpers <jonatan@werpers.com>
parents: 397
diff changeset
16
4aa7fe13a984 Add scale() and eltype() methods for stencils
Jonatan Werpers <jonatan@werpers.com>
parents: 397
diff changeset
17 @test eltype(s) == Float64
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
18 @test SbpOperators.scale(s, 2) == Stencil((-2,2), (2.,4.,4.,6.,8.))
595
03ef4d4740ab Add a constructor for Stencil where you can specify the center of the stencil
Jonatan Werpers <jonatan@werpers.com>
parents: 594
diff changeset
19
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
20 @test Stencil((1,2,3,4), center=1) == Stencil((0, 3),(1,2,3,4))
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
21 @test Stencil((1,2,3,4), center=2) == Stencil((-1, 2),(1,2,3,4))
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
22 @test Stencil((1,2,3,4), center=4) == Stencil((-3, 0),(1,2,3,4))
584
4aa7fe13a984 Add scale() and eltype() methods for stencils
Jonatan Werpers <jonatan@werpers.com>
parents: 397
diff changeset
23 end
4aa7fe13a984 Add scale() and eltype() methods for stencils
Jonatan Werpers <jonatan@werpers.com>
parents: 397
diff changeset
24
603
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
25 @testset "parse_rational" begin
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
26 @test SbpOperators.parse_rational("1") isa Rational
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
27 @test SbpOperators.parse_rational("1") == 1//1
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
28 @test SbpOperators.parse_rational("1/2") isa Rational
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
29 @test SbpOperators.parse_rational("1/2") == 1//2
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
30 @test SbpOperators.parse_rational("37/13") isa Rational
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
31 @test SbpOperators.parse_rational("37/13") == 37//13
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
32 end
fbff4009c08a Add tests for parse_rational()
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
33
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
34 @testset "readoperator" begin
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
35 toml_str = """
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
36 [meta]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
37 type = "equidistant"
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
38
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
39 [order2]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
40 H.inner = ["1"]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
41
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
42 D1.inner_stencil = ["-1/2", "0", "1/2"]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
43 D1.closure_stencils = [
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
44 ["-1", "1"],
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
45 ]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
46
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
47 d1.closure = ["-3/2", "2", "-1/2"]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
48
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
49 [order4]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
50 H.closure = ["17/48", "59/48", "43/48", "49/48"]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
51
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
52 D2.inner_stencil = ["-1/12","4/3","-5/2","4/3","-1/12"]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
53 D2.closure_stencils = [
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
54 [ "2", "-5", "4", "-1", "0", "0"],
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
55 [ "1", "-2", "1", "0", "0", "0"],
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
56 [ "-4/43", "59/43", "-110/43", "59/43", "-4/43", "0"],
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
57 [ "-1/49", "0", "59/49", "-118/49", "64/49", "-4/49"],
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
58 ]
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
59 """
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
60
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
61 parsed_toml = TOML.parse(toml_str)
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
62 @testset "get_stencil" begin
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
63 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil") == Stencil((-1/2, 0., 1/2), center=2)
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
64 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=1) == Stencil((-1/2, 0., 1/2); center=1)
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
65 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=3) == Stencil((-1/2, 0., 1/2); center=3)
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
66
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
67 @test get_stencil(parsed_toml, "order2", "H", "inner") == Stencil((1.,), center=1)
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
68
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
69 @test_throws AssertionError get_stencil(parsed_toml, "meta", "type")
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
70 @test_throws AssertionError get_stencil(parsed_toml, "order2", "D1", "closure_stencils")
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
71 end
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
72
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
73 @testset "get_stencils" begin
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
74 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(1,)) == (Stencil((-1., 1.), center=1),)
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
75 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(2,)) == (Stencil((-1., 1.), center=2),)
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
76 @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=[2]) == (Stencil((-1., 1.), center=2),)
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
77
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
78 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=[1,1,1,1]) == (
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
79 Stencil(( 2., -5., 4., -1., 0., 0.), center=1),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
80 Stencil(( 1., -2., 1., 0., 0., 0.), center=1),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
81 Stencil(( -4/43, 59/43, -110/43, 59/43, -4/43, 0.), center=1),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
82 Stencil(( -1/49, 0., 59/49, -118/49, 64/49, -4/49), center=1),
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
83 )
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
84
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
85 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(4,2,3,1)) == (
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
86 Stencil(( 2., -5., 4., -1., 0., 0.), center=4),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
87 Stencil(( 1., -2., 1., 0., 0., 0.), center=2),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
88 Stencil(( -4/43, 59/43, -110/43, 59/43, -4/43, 0.), center=3),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
89 Stencil(( -1/49, 0., 59/49, -118/49, 64/49, -4/49), center=1),
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
90 )
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
91
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
92 @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=1:4) == (
613
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
93 Stencil(( 2., -5., 4., -1., 0., 0.), center=1),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
94 Stencil(( 1., -2., 1., 0., 0., 0.), center=2),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
95 Stencil(( -4/43, 59/43, -110/43, 59/43, -4/43, 0.), center=3),
eaa8c852ddf2 Import Stecil in tests to make it less verbose
Jonatan Werpers <jonatan@werpers.com>
parents: 605
diff changeset
96 Stencil(( -1/49, 0., 59/49, -118/49, 64/49, -4/49), center=4),
604
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
97 )
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
98
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
99 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3))
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
100 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3,5,4))
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
101 @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "inner_stencil",centers=(1,2))
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
102 end
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
103
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
104 @testset "get_tuple" begin
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
105 @test get_tuple(parsed_toml, "order2", "d1", "closure") == (-3/2, 2, -1/2)
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
106
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
107 @test_throws AssertionError get_tuple(parsed_toml, "meta", "type")
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
108 end
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
109 end
6901d5375311 Add tests for get_stencil, get_stencils and get_tuple
Jonatan Werpers <jonatan@werpers.com>
parents: 595
diff changeset
110
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
111 # @testset "apply_quadrature" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
112 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
113 # h = 0.5
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
114 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
115 # @test apply_quadrature(op, h, 1.0, 10, 100) == h
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
116 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
117 # N = 10
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
118 # qc = op.quadratureClosure
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
119 # q = h.*(qc..., ones(N-2*closuresize(op))..., reverse(qc)...)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
120 # @assert length(q) == N
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
121 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
122 # for i ∈ 1:N
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
123 # @test apply_quadrature(op, h, 1.0, i, N) == q[i]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
124 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
125 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
126 # v = [2.,3.,2.,4.,5.,4.,3.,4.,5.,4.5]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
127 # for i ∈ 1:N
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
128 # @test apply_quadrature(op, h, v[i], i, N) == q[i]*v[i]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
129 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
130 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
131
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
132 @testset "SecondDerivative" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
133 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
134 L = 3.5
388
5223872485cd Clean up grid creation
Jonatan Werpers <jonatan@werpers.com>
parents: 387
diff changeset
135 g = EquidistantGrid(101, 0.0, L)
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
136 Dₓₓ = SecondDerivative(g,op.innerStencil,op.closureStencils)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
137
396
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
138 f0(x) = 1.
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
139 f1(x) = x
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
140 f2(x) = 1/2*x^2
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
141 f3(x) = 1/6*x^3
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
142 f4(x) = 1/24*x^4
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
143 f5(x) = sin(x)
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
144 f5ₓₓ(x) = -f5(x)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
145
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
146 v0 = evalOn(g,f0)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
147 v1 = evalOn(g,f1)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
148 v2 = evalOn(g,f2)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
149 v3 = evalOn(g,f3)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
150 v4 = evalOn(g,f4)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
151 v5 = evalOn(g,f5)
219
69a6049e14d9 Create package SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
152
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
153 @test Dₓₓ isa TensorMapping{T,1,1} where T
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
154 @test Dₓₓ' isa TensorMapping{T,1,1} where T
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
155
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
156 # 4th order interior stencil, 2nd order boundary stencil,
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
157 # implies that L*v should be exact for v - monomial up to order 3.
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
158 # Exact differentiation is measured point-wise. For other grid functions
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
159 # the error is measured in the l2-norm.
395
737e597e0e6d Rewrite broken tests as testing that the norm is zero
Jonatan Werpers <jonatan@werpers.com>
parents: 389
diff changeset
160 @test norm(Dₓₓ*v0) ≈ 0.0 atol=5e-10
737e597e0e6d Rewrite broken tests as testing that the norm is zero
Jonatan Werpers <jonatan@werpers.com>
parents: 389
diff changeset
161 @test norm(Dₓₓ*v1) ≈ 0.0 atol=5e-10
387
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
162 @test Dₓₓ*v2 ≈ v0 atol=5e-11
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
163 @test Dₓₓ*v3 ≈ v1 atol=5e-11
388
5223872485cd Clean up grid creation
Jonatan Werpers <jonatan@werpers.com>
parents: 387
diff changeset
164
5223872485cd Clean up grid creation
Jonatan Werpers <jonatan@werpers.com>
parents: 387
diff changeset
165 h = spacing(g)[1];
389
0433ab553d13 Rewrite l2 norm comparison to use the norm key word of isapprox
Jonatan Werpers <jonatan@werpers.com>
parents: 388
diff changeset
166 l2(v) = sqrt(h*sum(v.^2))
0433ab553d13 Rewrite l2 norm comparison to use the norm key word of isapprox
Jonatan Werpers <jonatan@werpers.com>
parents: 388
diff changeset
167 @test Dₓₓ*v4 ≈ v2 atol=5e-4 norm=l2
0433ab553d13 Rewrite l2 norm comparison to use the norm key word of isapprox
Jonatan Werpers <jonatan@werpers.com>
parents: 388
diff changeset
168 @test Dₓₓ*v5 ≈ -v5 atol=5e-4 norm=l2
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
169 end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
170
387
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
171
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
172 @testset "Laplace2D" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
173 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
174 Lx = 1.5
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
175 Ly = 3.2
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
176 g = EquidistantGrid((102,131), (0.0, 0.0), (Lx,Ly))
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
177 L = Laplace(g, op.innerStencil, op.closureStencils)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
178
254
4ca3794fffef Add apply_quadrature to SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 219
diff changeset
179
396
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
180 f0(x,y) = 2.
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
181 f1(x,y) = x+y
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
182 f2(x,y) = 1/2*x^2 + 1/2*y^2
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
183 f3(x,y) = 1/6*x^3 + 1/6*y^3
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
184 f4(x,y) = 1/24*x^4 + 1/24*y^4
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
185 f5(x,y) = sin(x) + cos(y)
9aff09ca0052 Remove some type annotations
Jonatan Werpers <jonatan@werpers.com>
parents: 395
diff changeset
186 f5ₓₓ(x,y) = -f5(x,y)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
187
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
188 v0 = evalOn(g,f0)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
189 v1 = evalOn(g,f1)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
190 v2 = evalOn(g,f2)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
191 v3 = evalOn(g,f3)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
192 v4 = evalOn(g,f4)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
193 v5 = evalOn(g,f5)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
194 v5ₓₓ = evalOn(g,f5ₓₓ)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
195
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
196 @test L isa TensorMapping{T,2,2} where T
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
197 @test L' isa TensorMapping{T,2,2} where T
254
4ca3794fffef Add apply_quadrature to SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 219
diff changeset
198
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
199 # 4th order interior stencil, 2nd order boundary stencil,
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
200 # implies that L*v should be exact for v - monomial up to order 3.
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
201 # Exact differentiation is measured point-wise. For other grid functions
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
202 # the error is measured in the H-norm.
612
1db945cba3a2 Remove extra argument to volume_operator in SecondDerivative()
Jonatan Werpers <jonatan@werpers.com>
parents: 610
diff changeset
203 @test norm(L*v0) ≈ 0 atol=1e-9
1db945cba3a2 Remove extra argument to volume_operator in SecondDerivative()
Jonatan Werpers <jonatan@werpers.com>
parents: 610
diff changeset
204 @test norm(L*v1) ≈ 0 atol=1e-9
387
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
205 @test L*v2 ≈ v0 # Seems to be more accurate
612
1db945cba3a2 Remove extra argument to volume_operator in SecondDerivative()
Jonatan Werpers <jonatan@werpers.com>
parents: 610
diff changeset
206 @test L*v3 ≈ v1 atol=1e-9
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
207
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
208 h = spacing(g)
389
0433ab553d13 Rewrite l2 norm comparison to use the norm key word of isapprox
Jonatan Werpers <jonatan@werpers.com>
parents: 388
diff changeset
209 l2(v) = sqrt(prod(h)*sum(v.^2))
0433ab553d13 Rewrite l2 norm comparison to use the norm key word of isapprox
Jonatan Werpers <jonatan@werpers.com>
parents: 388
diff changeset
210 @test L*v4 ≈ v2 atol=5e-4 norm=l2
0433ab553d13 Rewrite l2 norm comparison to use the norm key word of isapprox
Jonatan Werpers <jonatan@werpers.com>
parents: 388
diff changeset
211 @test L*v5 ≈ v5ₓₓ atol=5e-4 norm=l2
254
4ca3794fffef Add apply_quadrature to SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 219
diff changeset
212 end
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
213
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
214 @testset "DiagonalInnerProduct" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
215 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
216 L = 2.3
388
5223872485cd Clean up grid creation
Jonatan Werpers <jonatan@werpers.com>
parents: 387
diff changeset
217 g = EquidistantGrid(77, 0.0, L)
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
218 H = DiagonalInnerProduct(g,op.quadratureClosure)
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
219 v = ones(Float64, size(g))
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
220
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
221 @test H isa TensorMapping{T,1,1} where T
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
222 @test H' isa TensorMapping{T,1,1} where T
383
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
223 @test sum(H*v) ≈ L
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
224 @test H*v == H'*v
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
225 end
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
226
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
227 @testset "Quadrature" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
228 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
229 Lx = 2.3
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
230 Ly = 5.2
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
231 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly))
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
232
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
233 Q = Quadrature(g, op.quadratureClosure)
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
234
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
235 @test Q isa TensorMapping{T,2,2} where T
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
236 @test Q' isa TensorMapping{T,2,2} where T
382
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
237
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
238 v = ones(Float64, size(g))
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
239 @test sum(Q*v) ≈ Lx*Ly
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
240
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
241 v = 2*ones(Float64, size(g))
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
242 @test_broken sum(Q*v) ≈ 2*Lx*Ly
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
243
5c10cd0ed1fe testSbpOperators.jl: Add a test for Quadrature and mark some tests broken
Jonatan Werpers <jonatan@werpers.com>
parents: 379
diff changeset
244 @test Q*v == Q'*v
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 314
diff changeset
245 end
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
246
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
247 @testset "InverseDiagonalInnerProduct" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
248 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
249 L = 2.3
388
5223872485cd Clean up grid creation
Jonatan Werpers <jonatan@werpers.com>
parents: 387
diff changeset
250 g = EquidistantGrid(77, 0.0, L)
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
251 H = DiagonalInnerProduct(g, op.quadratureClosure)
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
252 Hi = InverseDiagonalInnerProduct(g,op.quadratureClosure)
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
253 v = evalOn(g, x->sin(x))
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
254
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
255 @test Hi isa TensorMapping{T,1,1} where T
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
256 @test Hi' isa TensorMapping{T,1,1} where T
387
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
257 @test Hi*H*v ≈ v
383
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
258 @test Hi*v == Hi'*v
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
259 end
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
260
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
261 @testset "InverseQuadrature" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
262 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
263 Lx = 7.3
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
264 Ly = 8.2
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
265 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly))
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
266
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
267 Q = Quadrature(g, op.quadratureClosure)
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
268 Qinv = InverseQuadrature(g, op.quadratureClosure)
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
269 v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y)
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
270
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 338
diff changeset
271 @test Qinv isa TensorMapping{T,2,2} where T
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
272 @test Qinv' isa TensorMapping{T,2,2} where T
383
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
273 @test_broken Qinv*(Q*v) ≈ v
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
274 @test Qinv*v == Qinv'*v
329
408c37b295c2 Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 328
diff changeset
275 end
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
276
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
277 @testset "BoundaryOperator" begin
617
f59e1732eacc Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 612 613
diff changeset
278 closure_stencil = Stencil((0,2), (2.,1.,3.))
568
34d9e10f0001 Make grid larger in test to make sure there all kinds of regions are represented
Jonatan Werpers <jonatan@werpers.com>
parents: 567
diff changeset
279 g_1D = EquidistantGrid(11, 0.0, 1.0)
34d9e10f0001 Make grid larger in test to make sure there all kinds of regions are represented
Jonatan Werpers <jonatan@werpers.com>
parents: 567
diff changeset
280 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
281
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
282 @testset "Constructors" begin
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
283 @testset "1D" begin
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
284 op_l = BoundaryOperator{Lower}(closure_stencil,size(g_1D)[1])
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
285 @test op_l == BoundaryOperator(g_1D,closure_stencil,Lower())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
286 @test op_l == boundary_operator(g_1D,closure_stencil,CartesianBoundary{1,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
287 @test op_l isa TensorMapping{T,0,1} where T
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
288
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
289 op_r = BoundaryOperator{Upper}(closure_stencil,size(g_1D)[1])
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
290 @test op_r == BoundaryRestriction(g_1D,closure_stencil,Upper())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
291 @test op_r == boundary_operator(g_1D,closure_stencil,CartesianBoundary{1,Upper}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
292 @test op_r isa TensorMapping{T,0,1} where T
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
293 end
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
294
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
295 @testset "2D" begin
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
296 e_w = boundary_operator(g_2D,closure_stencil,CartesianBoundary{1,Upper}())
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
297 @test e_w isa InflatedTensorMapping
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
298 @test e_w isa TensorMapping{T,1,2} where T
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
299 end
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
300 end
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
301
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
302 op_l = boundary_operator(g_1D, closure_stencil, CartesianBoundary{1,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
303 op_r = boundary_operator(g_1D, closure_stencil, CartesianBoundary{1,Upper}())
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
304
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
305 op_w = boundary_operator(g_2D, closure_stencil, CartesianBoundary{1,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
306 op_e = boundary_operator(g_2D, closure_stencil, CartesianBoundary{1,Upper}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
307 op_s = boundary_operator(g_2D, closure_stencil, CartesianBoundary{2,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
308 op_n = boundary_operator(g_2D, closure_stencil, CartesianBoundary{2,Upper}())
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
309
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
310 @testset "Sizes" begin
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
311 @testset "1D" begin
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
312 @test domain_size(op_l) == (11,)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
313 @test domain_size(op_r) == (11,)
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
314
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
315 @test range_size(op_l) == ()
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
316 @test range_size(op_r) == ()
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
317 end
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
318
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
319 @testset "2D" begin
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
320 @test domain_size(op_w) == (11,15)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
321 @test domain_size(op_e) == (11,15)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
322 @test domain_size(op_s) == (11,15)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
323 @test domain_size(op_n) == (11,15)
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
324
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
325 @test range_size(op_w) == (15,)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
326 @test range_size(op_e) == (15,)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
327 @test range_size(op_s) == (11,)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
328 @test range_size(op_n) == (11,)
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
329 end
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
330 end
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
331
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
332
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
333 @testset "Application" begin
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
334 @testset "1D" begin
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
335 v = evalOn(g_1D,x->1+x^2)
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
336 u = fill(3.124)
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
337 @test (op_l*v)[] == 2*v[1] + v[2] + 3*v[3]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
338 @test (op_r*v)[] == 2*v[end] + v[end-1] + 3*v[end-2]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
339 @test (op_r*v)[1] == 2*v[end] + v[end-1] + 3*v[end-2]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
340 @test op_l'*u == [2*u[]; u[]; 3*u[]; zeros(8)]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
341 @test op_r'*u == [zeros(8); 3*u[]; u[]; 2*u[]]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
342 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
343
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
344 @testset "2D" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
345 v = rand(size(g_2D)...)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
346 u = fill(3.124)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
347 @test op_w*v ≈ 2*v[1,:] + v[2,:] + 3*v[3,:] rtol = 1e-14
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
348 @test op_e*v ≈ 2*v[end,:] + v[end-1,:] + 3*v[end-2,:] rtol = 1e-14
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
349 @test op_s*v ≈ 2*v[:,1] + v[:,2] + 3*v[:,3] rtol = 1e-14
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
350 @test op_n*v ≈ 2*v[:,end] + v[:,end-1] + 3*v[:,end-2] rtol = 1e-14
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
351
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
352
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
353 g_x = rand(size(g_2D)[1])
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
354 g_y = rand(size(g_2D)[2])
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
355
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
356 G_w = zeros(Float64, size(g_2D)...)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
357 G_w[1,:] = 2*g_y
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
358 G_w[2,:] = g_y
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
359 G_w[3,:] = 3*g_y
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
360
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
361 G_e = zeros(Float64, size(g_2D)...)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
362 G_e[end,:] = 2*g_y
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
363 G_e[end-1,:] = g_y
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
364 G_e[end-2,:] = 3*g_y
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
365
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
366 G_s = zeros(Float64, size(g_2D)...)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
367 G_s[:,1] = 2*g_x
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
368 G_s[:,2] = g_x
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
369 G_s[:,3] = 3*g_x
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
370
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
371 G_n = zeros(Float64, size(g_2D)...)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
372 G_n[:,end] = 2*g_x
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
373 G_n[:,end-1] = g_x
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
374 G_n[:,end-2] = 3*g_x
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
375
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
376 @test op_w'*g_y == G_w
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
377 @test op_e'*g_y == G_e
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
378 @test op_s'*g_x == G_s
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
379 @test op_n'*g_x == G_n
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
380 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
381
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
382 @testset "Regions" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
383 u = fill(3.124)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
384 @test (op_l'*u)[Index(1,Lower)] == 2*u[]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
385 @test (op_l'*u)[Index(2,Lower)] == u[]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
386 @test (op_l'*u)[Index(6,Interior)] == 0
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
387 @test (op_l'*u)[Index(10,Upper)] == 0
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
388 @test (op_l'*u)[Index(11,Upper)] == 0
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
389
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
390 @test (op_r'*u)[Index(1,Lower)] == 0
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
391 @test (op_r'*u)[Index(2,Lower)] == 0
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
392 @test (op_r'*u)[Index(6,Interior)] == 0
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
393 @test (op_r'*u)[Index(10,Upper)] == u[]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
394 @test (op_r'*u)[Index(11,Upper)] == 2*u[]
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
395 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
396 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
397
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
398 @testset "Inferred" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
399 v = ones(Float64, 11)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
400 u = fill(1.)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
401
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
402 @inferred apply(op_l, v)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
403 @inferred apply(op_r, v)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
404
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
405 @inferred apply_transpose(op_l, u, 4)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
406 @inferred apply_transpose(op_l, u, Index(1,Lower))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
407 @inferred apply_transpose(op_l, u, Index(2,Lower))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
408 @inferred apply_transpose(op_l, u, Index(6,Interior))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
409 @inferred apply_transpose(op_l, u, Index(10,Upper))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
410 @inferred apply_transpose(op_l, u, Index(11,Upper))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
411
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
412 @inferred apply_transpose(op_r, u, 4)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
413 @inferred apply_transpose(op_r, u, Index(1,Lower))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
414 @inferred apply_transpose(op_r, u, Index(2,Lower))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
415 @inferred apply_transpose(op_r, u, Index(6,Interior))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
416 @inferred apply_transpose(op_r, u, Index(10,Upper))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
417 @inferred apply_transpose(op_r, u, Index(11,Upper))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
418 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
419
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
420 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
421
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
422 @testset "BoundaryRestriction" begin
617
f59e1732eacc Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 612 613
diff changeset
423 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
424 g_1D = EquidistantGrid(11, 0.0, 1.0)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
425 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
426
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
427 @testset "Constructors" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
428 @testset "1D" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
429 e_l = BoundaryRestriction(g_1D,op.eClosure,Lower())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
430 @test e_l == BoundaryRestriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
431 @test e_l == BoundaryOperator(g_1D,op.eClosure,Lower())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
432 @test e_l isa BoundaryOperator{T,Lower} where T
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
433 @test e_l isa TensorMapping{T,0,1} where T
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
434
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
435 e_r = BoundaryRestriction(g_1D,op.eClosure,Upper())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
436 @test e_r == BoundaryRestriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
437 @test e_r == BoundaryOperator(g_1D,op.eClosure,Upper())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
438 @test e_r isa BoundaryOperator{T,Upper} where T
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
439 @test e_r isa TensorMapping{T,0,1} where T
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
440 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
441
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
442 @testset "2D" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
443 e_w = BoundaryRestriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
444 @test e_w isa InflatedTensorMapping
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
445 @test e_w isa TensorMapping{T,1,2} where T
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
446 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
447 end
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
448
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
449 @testset "Application" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
450 @testset "1D" begin
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
451 e_l = BoundaryRestriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
452 e_r = BoundaryRestriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
453
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
454 v = evalOn(g_1D,x->1+x^2)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
455 u = fill(3.124)
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
456
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
457 @test (e_l*v)[] == v[1]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
458 @test (e_r*v)[] == v[end]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
459 @test (e_r*v)[1] == v[end]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
460 @test e_l'*u == [u[]; zeros(10)]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
461 @test e_r'*u == [zeros(10); u[]]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
462 end
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
463
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
464 @testset "2D" begin
610
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
465 e_w = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{1,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
466 e_e = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
467 e_s = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
468 e_n = BoundaryRestriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}())
e40e7439d1b4 Add a general boundary operator and make BoundaryRestriction a specialization of it.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 586
diff changeset
469
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
470 v = rand(11, 15)
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
471 u = fill(3.124)
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
472
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
473 @test e_w*v == v[1,:]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
474 @test e_e*v == v[end,:]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
475 @test e_s*v == v[:,1]
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
476 @test e_n*v == v[:,end]
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
477
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
478
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
479 g_x = rand(11)
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
480 g_y = rand(15)
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
481
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
482 G_w = zeros(Float64, (11,15))
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
483 G_w[1,:] = g_y
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
484
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
485 G_e = zeros(Float64, (11,15))
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
486 G_e[end,:] = g_y
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
487
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
488 G_s = zeros(Float64, (11,15))
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
489 G_s[:,1] = g_x
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
490
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
491 G_n = zeros(Float64, (11,15))
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
492 G_n[:,end] = g_x
565
15423a868d28 Restructure and extend tests for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 562
diff changeset
493
576
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
494 @test e_w'*g_y == G_w
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
495 @test e_e'*g_y == G_e
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
496 @test e_s'*g_x == G_s
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
497 @test e_n'*g_x == G_n
1d4417ced79f Put test sets around 1d and 2d tests
Jonatan Werpers <jonatan@werpers.com>
parents: 575
diff changeset
498 end
544
884be64e82d9 Add test case illustrating issue in split_index for region indices.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 519
diff changeset
499 end
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 397
diff changeset
500 end
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
501 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
502 # @testset "NormalDerivative" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
503 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
504 # g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0))
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
505 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
506 # d_w = NormalDerivative(op, g, CartesianBoundary{1,Lower}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
507 # d_e = NormalDerivative(op, g, CartesianBoundary{1,Upper}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
508 # d_s = NormalDerivative(op, g, CartesianBoundary{2,Lower}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
509 # d_n = NormalDerivative(op, g, CartesianBoundary{2,Upper}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
510 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
511 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
512 # v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
513 # v∂x = evalOn(g, (x,y)-> 2*x + y)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
514 # v∂y = evalOn(g, (x,y)-> 2*(y-1) + x)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
515 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
516 # @test d_w isa TensorMapping{T,2,1} where T
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
517 # @test d_w' isa TensorMapping{T,1,2} where T
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
518 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
519 # @test domain_size(d_w, (3,2)) == (2,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
520 # @test domain_size(d_e, (3,2)) == (2,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
521 # @test domain_size(d_s, (3,2)) == (3,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
522 # @test domain_size(d_n, (3,2)) == (3,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
523 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
524 # @test size(d_w'*v) == (6,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
525 # @test size(d_e'*v) == (6,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
526 # @test size(d_s'*v) == (5,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
527 # @test size(d_n'*v) == (5,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
528 #
387
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
529 # @test d_w'*v .≈ v∂x[1,:]
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
530 # @test d_e'*v .≈ v∂x[5,:]
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
531 # @test d_s'*v .≈ v∂y[:,1]
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
532 # @test d_n'*v .≈ v∂y[:,6]
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
533 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
534 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
535 # d_x_l = zeros(Float64, 5)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
536 # d_x_u = zeros(Float64, 5)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
537 # for i ∈ eachindex(d_x_l)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
538 # d_x_l[i] = op.dClosure[i-1]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
539 # d_x_u[i] = -op.dClosure[length(d_x_u)-i]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
540 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
541 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
542 # d_y_l = zeros(Float64, 6)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
543 # d_y_u = zeros(Float64, 6)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
544 # for i ∈ eachindex(d_y_l)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
545 # d_y_l[i] = op.dClosure[i-1]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
546 # d_y_u[i] = -op.dClosure[length(d_y_u)-i]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
547 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
548 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
549 # function prod_matrix(x,y)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
550 # G = zeros(Float64, length(x), length(y))
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
551 # for I ∈ CartesianIndices(G)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
552 # G[I] = x[I[1]]*y[I[2]]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
553 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
554 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
555 # return G
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
556 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
557 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
558 # g_x = [1,2,3,4.0,5]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
559 # g_y = [5,4,3,2,1.0,11]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
560 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
561 # G_w = prod_matrix(d_x_l, g_y)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
562 # G_e = prod_matrix(d_x_u, g_y)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
563 # G_s = prod_matrix(g_x, d_y_l)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
564 # G_n = prod_matrix(g_x, d_y_u)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
565 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
566 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
567 # @test size(d_w*g_y) == (UnknownDim,6)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
568 # @test size(d_e*g_y) == (UnknownDim,6)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
569 # @test size(d_s*g_x) == (5,UnknownDim)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
570 # @test size(d_n*g_x) == (5,UnknownDim)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
571 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
572 # # These tests should be moved to where they are possible (i.e we know what the grid should be)
387
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
573 # @test_broken d_w*g_y .≈ G_w
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
574 # @test_broken d_e*g_y .≈ G_e
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
575 # @test_broken d_s*g_x .≈ G_s
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
576 # @test_broken d_n*g_x .≈ G_n
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
577 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
578 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
579 # @testset "BoundaryQuadrature" begin
594
cc86b920531a Change the readoperator function to use the .toml format
Jonatan Werpers <jonatan@werpers.com>
parents: 586
diff changeset
580 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
581 # g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0))
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
582 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
583 # H_w = BoundaryQuadrature(op, g, CartesianBoundary{1,Lower}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
584 # H_e = BoundaryQuadrature(op, g, CartesianBoundary{1,Upper}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
585 # H_s = BoundaryQuadrature(op, g, CartesianBoundary{2,Lower}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
586 # H_n = BoundaryQuadrature(op, g, CartesianBoundary{2,Upper}())
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
587 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
588 # v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
589 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
590 # function get_quadrature(N)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
591 # qc = op.quadratureClosure
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
592 # q = (qc..., ones(N-2*closuresize(op))..., reverse(qc)...)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
593 # @assert length(q) == N
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
594 # return q
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
595 # end
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
596 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
597 # v_w = v[1,:]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
598 # v_e = v[10,:]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
599 # v_s = v[:,1]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
600 # v_n = v[:,11]
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
601 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
602 # q_x = spacing(g)[1].*get_quadrature(10)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
603 # q_y = spacing(g)[2].*get_quadrature(11)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
604 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
605 # @test H_w isa TensorOperator{T,1} where T
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
606 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
607 # @test domain_size(H_w, (3,)) == (3,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
608 # @test domain_size(H_n, (3,)) == (3,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
609 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
610 # @test range_size(H_w, (3,)) == (3,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
611 # @test range_size(H_n, (3,)) == (3,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
612 #
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
613 # @test size(H_w*v_w) == (11,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
614 # @test size(H_e*v_e) == (11,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
615 # @test size(H_s*v_s) == (10,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
616 # @test size(H_n*v_n) == (10,)
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
617 #
387
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
618 # @test H_w*v_w .≈ q_y.*v_w
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
619 # @test H_e*v_e .≈ q_y.*v_e
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
620 # @test H_s*v_s .≈ q_x.*v_s
4686c3509b54 Switch to using isapprox operator
Jonatan Werpers <jonatan@werpers.com>
parents: 385
diff changeset
621 # @test H_n*v_n .≈ q_x.*v_n
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
622 #
383
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
623 # @test H_w'*v_w == H_w'*v_w
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
624 # @test H_e'*v_e == H_e'*v_e
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
625 # @test H_s'*v_s == H_s'*v_s
aaf8e331cb80 Remove collects around TensorMappingApplications
Jonatan Werpers <jonatan@werpers.com>
parents: 382
diff changeset
626 # @test H_n'*v_n == H_n'*v_n
314
accb0876da12 Move tests for Laplace from DiffOps/test to SbpOperators/test and add test for Secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 254
diff changeset
627 # end
338
2b0c9b30ea3b Add test sets for each submodule to make the test output nicer
Jonatan Werpers <jonatan@werpers.com>
parents: 335
diff changeset
628
2b0c9b30ea3b Add test sets for each submodule to make the test output nicer
Jonatan Werpers <jonatan@werpers.com>
parents: 335
diff changeset
629 end