changeset 1596:84dc3b9b449b feature/boundary_conditions

Add positivity properties (the borrowing capacity) of the D2 operators to the operator toml as well as methods to parse them
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Sun, 26 May 2024 18:13:58 -0700
parents 611ae2308aa1
children 330c39505a94
files src/SbpOperators/SbpOperators.jl src/SbpOperators/operators/standard_diagonal.toml src/SbpOperators/stencil_set.jl test/SbpOperators/stencil_set_test.jl
diffstat 4 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/SbpOperators.jl	Sun May 26 17:35:52 2024 -0700
+++ b/src/SbpOperators/SbpOperators.jl	Sun May 26 18:13:58 2024 -0700
@@ -8,6 +8,7 @@
 export parse_nested_stencil
 export parse_scalar
 export parse_tuple
+export parse_named_tuple
 export sbp_operators_path
 
 # Operators
--- a/src/SbpOperators/operators/standard_diagonal.toml	Sun May 26 17:35:52 2024 -0700
+++ b/src/SbpOperators/operators/standard_diagonal.toml	Sun May 26 18:13:58 2024 -0700
@@ -39,6 +39,8 @@
         {s = [["2", "-1", "0"],["-3", "1",   "0"],["1","0","0"]], c = 1},
 ]
 
+Positivity.D2 = {theta_H = "1/2", theta_M = "0.3636363636", theta_R = "1.000000538455350", m_b = "2"}
+
 [[stencil_set]]
 
 order = 4
@@ -135,7 +137,7 @@
     ]}
 ]
 
-
+Positivity.D2 = {theta_H = "17/48", theta_M = "0.2505765857", theta_R = "0.577587500088313", m_b = "4"}
 
 [[stencil_set]]
 
@@ -150,3 +152,5 @@
 
 e.closure = ["1"]
 d1.closure = ["-25/12", "4", "-3", "4/3", "-1/4"]
+
+Positivity.D2 = {theta_H = "13649/43200", theta_M = "0.1878687080", theta_R = "0.3697", m_b = "7"}
--- a/src/SbpOperators/stencil_set.jl	Sun May 26 17:35:52 2024 -0700
+++ b/src/SbpOperators/stencil_set.jl	Sun May 26 18:13:58 2024 -0700
@@ -166,6 +166,17 @@
     return Tuple(parse_scalar.(parsed_toml))
 end
 
+"""
+    parse_named_tuple(parsed_toml)
+
+Parse the keys (names) and values (scalars) into a named tuple of rationals.
+
+See also [`parse_scalar`](@ref).
+"""
+function parse_named_tuple(parsed_toml)
+    NamedTuple(Symbol(key) => parse_scalar(val) for (key, val) in parsed_toml)
+end
+
 
 """
     parse_rational(parsed_toml)
--- a/test/SbpOperators/stencil_set_test.jl	Sun May 26 17:35:52 2024 -0700
+++ b/test/SbpOperators/stencil_set_test.jl	Sun May 26 18:13:58 2024 -0700
@@ -152,6 +152,14 @@
         @test_throws ArgumentError parse_tuple(toml["e3"])
         @test_throws ArgumentError parse_tuple(toml["e4"])
     end
+
+    @testset "parse_named_tuple" begin
+        toml = TOML.parse("""
+            NamedTuple = {a = "17/48", b = "0.2505765857"}
+        """)
+        @test parse_named_tuple(toml["NamedTuple"]) == (b = Rational(0.2505765857), a = 17//48)
+    end
+
 end
 
 @testset "parse_rational" begin