changeset 895:d24b331547f3 feature/variable_derivatives

Add method for controlling the element type when parsing nested stencils
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 10 Feb 2022 11:08:39 +0100
parents 54e36688dab8
children 004324d7ed35
files src/SbpOperators/readoperator.jl test/SbpOperators/readoperator_test.jl
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/readoperator.jl	Thu Feb 10 10:57:00 2022 +0100
+++ b/src/SbpOperators/readoperator.jl	Thu Feb 10 11:08:39 2022 +0100
@@ -111,7 +111,9 @@
 """
     parse_nested_stencil(parsed_toml)
 
+Accept parsed TOML and read it as a nested tuple.
 
+See also [`read_stencil_set`](@ref), [`parse_stencil`](@ref).
 """
 function parse_nested_stencil(parsed_toml)
     if parsed_toml isa Array
@@ -124,6 +126,12 @@
     return NestedStencil(weights...; center)
 end
 
+"""
+    parse_nested_stencil(T, parsed_toml)
+
+Parse the input as a nested stencil with element type `T`.
+"""
+parse_nested_stencil(T, parsed_toml) = NestedStencil{T}(parse_nested_stencil(parsed_toml))
 
 
 """
--- a/test/SbpOperators/readoperator_test.jl	Thu Feb 10 10:57:00 2022 +0100
+++ b/test/SbpOperators/readoperator_test.jl	Thu Feb 10 11:08:39 2022 +0100
@@ -182,4 +182,7 @@
     @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))
     @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)
     @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)
+
+    @test parse_nested_stencil(Float64, toml["s1"]) == CenteredNestedStencil((1/2, 1/2, 0.),( -1/2, -1., -1/2),(0., 1/2, 1/2))
+    @test parse_nested_stencil(Int, toml["s2"]) == NestedStencil((2, -1, 0),( -3, 1, 0),(1, 0, 0), center = 1)
 end