Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/readoperator.jl @ 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 |
comparison
equal
deleted
inserted
replaced
596:a9744aa5e235 | 597:98cd99237176 |
---|---|
31 even | 31 even |
32 ) | 32 ) |
33 | 33 |
34 return d2 | 34 return d2 |
35 end | 35 end |
36 | |
37 | |
38 """ | |
39 read_stencil(fn, path...; [center]) | |
40 | |
41 Read a stencil at `path` from the file with name `fn`. | |
42 If a center is specified the given element of the stecil is set as the center. | |
43 | |
44 # Examples | |
45 ``` | |
46 read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "D2", "inner_stencil") | |
47 read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "d1", "closure"; center=1) | |
48 ``` | |
49 """ | |
50 read_stencil(fn, path...; center=nothing) = get_stencil(TOML.parsefile(fn), path...; center=center) | |
36 | 51 |
37 function get_stencil(parsed_toml, path...; center=nothing) | 52 function get_stencil(parsed_toml, path...; center=nothing) |
38 if length(path) == 0 | 53 if length(path) == 0 |
39 @assert parsed_toml isa Vector | 54 @assert parsed_toml isa Vector |
40 stencil_weights = Float64.(parse_rational.(parsed_toml)) | 55 stencil_weights = Float64.(parse_rational.(parsed_toml)) |