comparison src/SbpOperators/readoperator.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 568058183791
children d24b331547f3
comparison
equal deleted inserted replaced
891:f72cc96a58c6 892:06c510d40ebb
2 2
3 export read_stencil_set 3 export read_stencil_set
4 export get_stencil_set 4 export get_stencil_set
5 5
6 export parse_stencil 6 export parse_stencil
7 export parse_nested_stencil
7 export parse_scalar 8 export parse_scalar
8 export parse_tuple 9 export parse_tuple
9 10
10 export sbp_operators_path 11 export sbp_operators_path
11 12
104 if !(parsed_toml["c"] isa Int) 105 if !(parsed_toml["c"] isa Int)
105 throw(ArgumentError("the center of a stencil must be specified as an integer.")) 106 throw(ArgumentError("the center of a stencil must be specified as an integer."))
106 end 107 end
107 end 108 end
108 109
110
111 """
112 parse_nested_stencil(parsed_toml)
113
114
115 """
116 function parse_nested_stencil(parsed_toml)
117 if parsed_toml isa Array
118 weights = parse_stencil.(parsed_toml)
119 return CenteredNestedStencil(weights...)
120 end
121
122 center = parsed_toml["c"]
123 weights = parse_tuple.(parsed_toml["s"])
124 return NestedStencil(weights...; center)
125 end
126
127
128
109 """ 129 """
110 parse_scalar(parsed_toml) 130 parse_scalar(parsed_toml)
111 131
112 Parse a scalar, represented as a string or a number in the TOML, and return it as a `Rational` 132 Parse a scalar, represented as a string or a number in the TOML, and return it as a `Rational`
113 133