Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/readoperator.jl @ 991:37fd8c1cadb2 feature/stencil_set_type
Make StencilSet(filename; filters...) an outer constructor again
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 18 Mar 2022 13:29:35 +0100 |
parents | b6238afd3bb0 |
children | 5ec49dd2c7c4 |
comparison
equal
deleted
inserted
replaced
990:b6238afd3bb0 | 991:37fd8c1cadb2 |
---|---|
12 """ | 12 """ |
13 StencilSet | 13 StencilSet |
14 | 14 |
15 A `StencilSet` contains a set of associated stencils. The stencils | 15 A `StencilSet` contains a set of associated stencils. The stencils |
16 are are stored in a table, and can be accesed by indexing into the `StencilSet`. | 16 are are stored in a table, and can be accesed by indexing into the `StencilSet`. |
17 """ | |
18 struct StencilSet | |
19 table | |
20 end | |
21 Base.getindex(set::StencilSet,I...) = set.table[I...] | |
17 | 22 |
23 | |
24 """ | |
18 StencilSet(filename; filters) | 25 StencilSet(filename; filters) |
19 | 26 |
20 Creates a `StencilSet` from a TOML file based on some key-value | 27 Creates a `StencilSet` from a TOML file based on some key-value |
21 filters. If more than one set matches the filters an error is raised. The | 28 filters. If more than one set matches the filters an error is raised. The |
22 table of the `StencilSet` is a parsed TOML intended for functions like | 29 table of the `StencilSet` is a parsed TOML intended for functions like |
31 | 38 |
32 For more information see [Operator file format](@ref) in the documentation. | 39 For more information see [Operator file format](@ref) in the documentation. |
33 | 40 |
34 See also [`sbp_operators_path`](@ref), [`get_stencil_set`](@ref), [`parse_stencil`](@ref), [`parse_scalar`](@ref), [`parse_tuple`](@ref),. | 41 See also [`sbp_operators_path`](@ref), [`get_stencil_set`](@ref), [`parse_stencil`](@ref), [`parse_scalar`](@ref), [`parse_tuple`](@ref),. |
35 """ | 42 """ |
36 struct StencilSet | 43 StencilSet(filename; filters...) = StencilSet(get_stencil_set(TOML.parsefile(filename); filters...)) |
37 table | |
38 function StencilSet(filename; filters...) | |
39 return new(get_stencil_set(TOML.parsefile(filename); filters...)) | |
40 end | |
41 end | |
42 | 44 |
43 Base.getindex(set::StencilSet,I...) = set.table[I...] | |
44 | 45 |
45 """ | 46 """ |
46 get_stencil_set(parsed_toml; filters...) | 47 get_stencil_set(parsed_toml; filters...) |
47 | 48 |
48 Picks out a stencil set from an already parsed TOML based on some key-value | 49 Picks out a stencil set from an already parsed TOML based on some key-value |