changeset 597:98cd99237176 refactor/toml_operator_format

Add a function for reading a stencil directly from the a file
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 02 Dec 2020 17:30:18 +0100
parents a9744aa5e235
children 19e1b169aa9c
files src/SbpOperators/readoperator.jl
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/readoperator.jl	Wed Dec 02 17:12:04 2020 +0100
+++ b/src/SbpOperators/readoperator.jl	Wed Dec 02 17:30:18 2020 +0100
@@ -34,6 +34,21 @@
     return d2
 end
 
+
+"""
+    read_stencil(fn, path...; [center])
+
+Read a stencil at `path` from the file with name `fn`.
+If a center is specified the given element of the stecil is set as the center.
+
+# Examples
+```
+read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "D2", "inner_stencil")
+read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "d1", "closure"; center=1)
+```
+"""
+read_stencil(fn, path...; center=nothing) = get_stencil(TOML.parsefile(fn), path...; center=center)
+
 function get_stencil(parsed_toml, path...; center=nothing)
     if length(path) == 0
         @assert parsed_toml isa Vector