Mercurial > repos > public > sbplib_julia
comparison test/testSbpOperators.jl @ 766:7624a1350ece operator_storage_array_of_table
Add parse_stencil
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 13 Feb 2021 22:17:55 +0100 |
parents | fdd48f6ace1c |
children | 7c87a33963c5 |
comparison
equal
deleted
inserted
replaced
765:fdd48f6ace1c | 766:7624a1350ece |
---|---|
103 @test get_stencil_set(parsed_toml; test = 1) == parsed_toml["stencil_set"][2] | 103 @test get_stencil_set(parsed_toml; test = 1) == parsed_toml["stencil_set"][2] |
104 @test get_stencil_set(parsed_toml; order = 4, test = 2) == parsed_toml["stencil_set"][3] | 104 @test get_stencil_set(parsed_toml; order = 4, test = 2) == parsed_toml["stencil_set"][3] |
105 | 105 |
106 @test_throws ArgumentError get_stencil_set(parsed_toml; test = 2) | 106 @test_throws ArgumentError get_stencil_set(parsed_toml; test = 2) |
107 @test_throws ArgumentError get_stencil_set(parsed_toml; order = 4) | 107 @test_throws ArgumentError get_stencil_set(parsed_toml; order = 4) |
108 end | |
109 | |
110 @testset "parse_stencil" begin | |
111 toml = """ | |
112 s1 = ["-1/12","4/3","-5/2","4/3","-1/12"] | |
113 s2 = {s = ["2", "-5", "4", "-1", "0", "0"], c = 1} | |
114 s3 = {s = ["1", "-2", "1", "0", "0", "0"], c = 2} | |
115 s4 = "not a stencil" | |
116 s5 = [-1, 4, 3] | |
117 s6 = {k = ["1", "-2", "1", "0", "0", "0"], c = 2} | |
118 s7 = {s = [-1, 4, 3], c = 2} | |
119 s8 = {s = ["1", "-2", "1", "0", "0", "0"], c = [2,2]} | |
120 """ | |
121 | |
122 @test parse_stencil(TOML.parse(toml)["s1"]) == CenteredStencil(-1/12, 4/3, -5/2, 4/3, -1/12) | |
123 @test parse_stencil(TOML.parse(toml)["s2"]) == Stencil(2., -5., 4., -1., 0., 0.; center=1) | |
124 @test parse_stencil(TOML.parse(toml)["s3"]) == Stencil(1., -2., 1., 0., 0., 0.; center=2) | |
125 | |
126 @test_throws ArgumentError parse_stencil(TOML.parse(toml)["s4"]) | |
127 @test_throws ArgumentError parse_stencil(TOML.parse(toml)["s5"]) | |
128 @test_throws ArgumentError parse_stencil(TOML.parse(toml)["s6"]) | |
129 @test_throws ArgumentError parse_stencil(TOML.parse(toml)["s7"]) | |
130 @test_throws ArgumentError parse_stencil(TOML.parse(toml)["s8"]) | |
131 | |
132 stencil_set = get_stencil_set(parsed_toml; order = 4, test = 1) | |
133 | |
134 @test parse_stencil.(stencil_set["D2"]["closure_stencils"]) == [ | |
135 Stencil( 2., -5., 4., -1., 0., 0.; center=1), | |
136 Stencil( 1., -2., 1., 0., 0., 0.; center=2), | |
137 Stencil(-4/43, 59/43, -110/43, 59/43, -4/43, 0.; center=3), | |
138 Stencil(-1/49, 0., 59/49, -118/49, 64/49, -4/49; center=4), | |
139 ] | |
108 end | 140 end |
109 | 141 |
110 @testset "get_stencil" begin | 142 @testset "get_stencil" begin |
111 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil") == Stencil(-1/2, 0., 1/2, center=2) | 143 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil") == Stencil(-1/2, 0., 1/2, center=2) |
112 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=1) == Stencil(-1/2, 0., 1/2; center=1) | 144 @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=1) == Stencil(-1/2, 0., 1/2; center=1) |