comparison test/SbpOperators/readoperator_test.jl @ 892:06c510d40ebb feature/variable_derivatives

Add parse_nested_stencil
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 10 Feb 2022 09:58:36 +0100
parents 760c11e81fd4
children d24b331547f3
comparison
equal deleted inserted replaced
891:f72cc96a58c6 892:06c510d40ebb
2 2
3 using TOML 3 using TOML
4 using Sbplib.SbpOperators 4 using Sbplib.SbpOperators
5 5
6 import Sbplib.SbpOperators.Stencil 6 import Sbplib.SbpOperators.Stencil
7 import Sbplib.SbpOperators.NestedStencil
7 8
8 @testset "readoperator" begin 9 @testset "readoperator" begin
9 toml_str = """ 10 toml_str = """
10 [meta] 11 [meta]
11 authors = "Ken Mattson" 12 authors = "Ken Mattson"
168 @test SbpOperators.parse_rational("0.5") == 1//2 169 @test SbpOperators.parse_rational("0.5") == 1//2
169 170
170 @test SbpOperators.parse_rational(2) isa Rational 171 @test SbpOperators.parse_rational(2) isa Rational
171 @test SbpOperators.parse_rational(2) == 2//1 172 @test SbpOperators.parse_rational(2) == 2//1
172 end 173 end
174
175 @testset "parse_nested_stencil" begin
176 toml = TOML.parse("""
177 s1 = [["1/2", "1/2", "0"],[ "-1/2", "-1", "-1/2"],["0", "1/2", "1/2"]]
178 s2 = {s = [[ "2", "-1", "0"],[ "-3", "1", "0"],["1", "0", "0"]], c = 1}
179 s3 = {s = [[ "2", "-1", "0"],[ "-3", "1", "0"],["1", "0", "0"]], c = 2}
180 """)
181
182 @test parse_nested_stencil(toml["s1"]) == CenteredNestedStencil((1//2, 1//2, 0//1),( -1//2, -1//1, -1//2),(0//1, 1//2, 1//2))
183 @test parse_nested_stencil(toml["s2"]) == NestedStencil((2//1, -1//1, 0//1),( -3//1, 1//1, 0//1),(1//1, 0//1, 0//1), center = 1)
184 @test parse_nested_stencil(toml["s3"]) == NestedStencil((2//1, -1//1, 0//1),( -3//1, 1//1, 0//1),(1//1, 0//1, 0//1), center = 2)
185 end