Mercurial > repos > public > sbplib_julia
changeset 989:7bf3121c6864 feature/stencil_set_type
Add type StencilSet
line wrap: on
line diff
--- a/docs/src/operator_file_format.md Wed Mar 16 18:39:00 2022 +0100 +++ b/docs/src/operator_file_format.md Thu Mar 17 21:31:20 2022 +0100 @@ -16,7 +16,7 @@ ``` Advanced user might want to get access to the individual objects of an operator file. This can be accomplished using functions such as -* [`read_stencil_set`](@ref) +* [`StencilSet`](@ref) * [`parse_scalar`](@ref) * [`parse_stencil`](@ref) * [`parse_tuple`](@ref)
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/boundaryops/boundary_restriction.jl Thu Mar 17 21:31:20 2022 +0100 @@ -13,7 +13,7 @@ See also: [`boundary_operator`](@ref). """ -function boundary_restriction(grid, closure_stencil::Stencil, boundary) +function boundary_restriction(grid, closure_stencil, boundary) converted_stencil = convert(Stencil{eltype(grid)}, closure_stencil) return SbpOperators.boundary_operator(grid, converted_stencil, boundary) end @@ -21,7 +21,6 @@ """ boundary_restriction(grid, stencil_set, boundary) -Creates a `boundary_restriction` operator on `grid` given a parsed TOML -`stencil_set`. +Creates a `boundary_restriction` operator on `grid` given a `stencil_set`. """ -boundary_restriction(grid, stencil_set, boundary) = boundary_restriction(grid, parse_stencil(stencil_set["e"]["closure"]), boundary) +boundary_restriction(grid, stencil_set::StencilSet, boundary) = boundary_restriction(grid, parse_stencil(stencil_set["e"]["closure"]), boundary)
--- a/src/SbpOperators/boundaryops/normal_derivative.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/boundaryops/normal_derivative.jl Thu Mar 17 21:31:20 2022 +0100 @@ -10,7 +10,7 @@ See also: [`boundary_operator`](@ref). """ -function normal_derivative(grid, closure_stencil::Stencil, boundary) +function normal_derivative(grid, closure_stencil, boundary) direction = dim(boundary) h_inv = inverse_spacing(grid)[direction] return SbpOperators.boundary_operator(grid, scale(closure_stencil,h_inv), boundary) @@ -19,7 +19,6 @@ """ normal_derivative(grid, stencil_set, boundary) -Creates a `normal_derivative` operator on `grid` given a parsed TOML -`stencil_set`. +Creates a `normal_derivative` operator on `grid` given a `stencil_set`. """ -normal_derivative(grid, stencil_set, boundary) = normal_derivative(grid, parse_stencil(stencil_set["d1"]["closure"]), boundary) +normal_derivative(grid, stencil_set::StencilSet, boundary) = normal_derivative(grid, parse_stencil(stencil_set["d1"]["closure"]), boundary)
--- a/src/SbpOperators/readoperator.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/readoperator.jl Thu Mar 17 21:31:20 2022 +0100 @@ -1,6 +1,6 @@ using TOML -export read_stencil_set +export StencilSet export get_stencil_set export parse_stencil @@ -9,16 +9,25 @@ export sbp_operators_path +""" + StencilSet + +A `StencilSet` contains a set of associated stencils. The stencils +are are stored in a table, and can be accesed by indexing into the `StencilSet`. +""" +struct StencilSet + table +end """ - read_stencil_set(filename; filters) + StencilSet(filename; filters) -Picks out a stencil set from a TOML file based on some key-value +Creates a `StencilSet` from a TOML file based on some key-value filters. If more than one set matches the filters an error is raised. The -returned stencil set contains parsed TOML intended for functions like +table of the `StencilSet` is a parsed TOML intended for functions like `parse_scalar` and `parse_stencil`. -The stencil set is not parsed beyond the inital TOML parse. To get usable +The `StencilSet` table is not parsed beyond the inital TOML parse. To get usable stencils use the `parse_stencil` functions on the fields of the stencil set. The reason for this is that since stencil sets are intended to be very @@ -29,7 +38,8 @@ See also [`sbp_operators_path`](@ref), [`get_stencil_set`](@ref), [`parse_stencil`](@ref), [`parse_scalar`](@ref), [`parse_tuple`](@ref),. """ -read_stencil_set(filename; filters...) = get_stencil_set(TOML.parsefile(filename); filters...) +StencilSet(filename; filters...) = StencilSet(get_stencil_set(TOML.parsefile(filename); filters...)) +Base.getindex(set::StencilSet,I...) = set.table[I...] """ get_stencil_set(parsed_toml; filters...) @@ -37,7 +47,7 @@ Picks out a stencil set from an already parsed TOML based on some key-value filters. -See also [`read_stencil_set`](@ref). +See also [`StencilSet`](@ref). """ function get_stencil_set(parsed_toml; filters...) matches = findall(parsed_toml["stencil_set"]) do set @@ -63,7 +73,7 @@ Accepts parsed TOML and reads it as a stencil. -See also [`read_stencil_set`](@ref), [`parse_scalar`](@ref), [`parse_tuple`](@ref). +See also [`StencilSet`](@ref), [`parse_scalar`](@ref), [`parse_tuple`](@ref). """ function parse_stencil(parsed_toml) check_stencil_toml(parsed_toml) @@ -111,7 +121,7 @@ Parse a scalar, represented as a string or a number in the TOML, and return it as a `Rational` -See also [`read_stencil_set`](@ref), [`parse_stencil`](@ref) [`parse_tuple`](@ref). +See also [`StencilSet`](@ref), [`parse_stencil`](@ref) [`parse_tuple`](@ref). """ function parse_scalar(parsed_toml) try @@ -126,7 +136,7 @@ Parse an array as a tuple of scalars. -See also [`read_stencil_set`](@ref), [`parse_stencil`](@ref), [`parse_scalar`](@ref). +See also [`StencilSet`](@ref), [`parse_stencil`](@ref), [`parse_scalar`](@ref). """ function parse_tuple(parsed_toml) if !(parsed_toml isa Array) @@ -155,6 +165,6 @@ Calculate the path for the operators folder with included stencil sets. -See also [`read_stencil_set`](@ref) +See also [`StencilSet`](@ref) """ sbp_operators_path() = (@__DIR__) * "/operators/"
--- a/src/SbpOperators/volumeops/derivatives/first_derivative.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/volumeops/derivatives/first_derivative.jl Thu Mar 17 21:31:20 2022 +0100 @@ -18,14 +18,18 @@ end first_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = first_derivative(grid,inner_stencil,closure_stencils,1) + """ first_derivative(grid, stencil_set, direction) -Creates a `first_derivative` operator on `grid` along coordinate dimension `direction` given a parsed TOML -`stencil_set`. +Creates a `first_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`. """ -function first_derivative(grid::EquidistantGrid, stencil_set, direction) +function first_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction) inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"]) first_derivative(grid,inner_stencil,closure_stencils,direction); end + +# TODO: Not possible to remove ::Stencil from first_derivative(grid::EquidistantGrid{1},...) due to type deduction failing. +# Is this due to the type ambuguity of StencilSet? Possible to address in some other way? +# If not, should we drop ::StencilSet from the method above (it is not required)? \ No newline at end of file
--- a/src/SbpOperators/volumeops/derivatives/second_derivative.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/volumeops/derivatives/second_derivative.jl Thu Mar 17 21:31:20 2022 +0100 @@ -21,11 +21,14 @@ """ second_derivative(grid, stencil_set, direction) -Creates a `second_derivative` operator on `grid` along coordinate dimension `direction` given a parsed TOML -`stencil_set`. +Creates a `second_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`. """ -function second_derivative(grid::EquidistantGrid, stencil_set, direction) +function second_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) second_derivative(grid,inner_stencil,closure_stencils,direction); end + +# TODO: Not possible to remove ::Stencil from second_derivative(grid::EquidistantGrid{1},...) due to type deduction failing. +# Is this due to the type ambuguity of StencilSet? Possible to address in some other way? +# If not, should we drop ::StencilSet from the method above (it is not required)? \ No newline at end of file
--- a/src/SbpOperators/volumeops/inner_products/inner_product.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/volumeops/inner_products/inner_product.jl Thu Mar 17 21:31:20 2022 +0100 @@ -37,8 +37,7 @@ """ inner_product(grid, stencil_set) -Creates a `inner_product` operator on `grid` given a parsed TOML -`stencil_set`. +Creates a `inner_product` operator on `grid` given a `stencil_set`. """ function inner_product(grid, stencil_set) inner_stencil = parse_scalar(stencil_set["H"]["inner"])
--- a/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl Thu Mar 17 21:31:20 2022 +0100 @@ -33,8 +33,7 @@ """ inverse_inner_product(grid, stencil_set) -Creates a `inverse_inner_product` operator on `grid` given a parsed TOML -`stencil_set`. +Creates a `inverse_inner_product` operator on `grid` given a `stencil_set`. """ function inverse_inner_product(grid, stencil_set) inner_stencil = parse_scalar(stencil_set["H"]["inner"])
--- a/src/SbpOperators/volumeops/laplace/laplace.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/src/SbpOperators/volumeops/laplace/laplace.jl Thu Mar 17 21:31:20 2022 +0100 @@ -2,19 +2,20 @@ Laplace{T, Dim, TM} <: TensorMapping{T, Dim, Dim} Implements the Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a -`TensorMapping`. Additionally `Laplace` stores the stencil set (parsed from TOML) +`TensorMapping`. Additionally `Laplace` stores the `StencilSet` used to construct the `TensorMapping`. """ struct Laplace{T, Dim, TM<:TensorMapping{T, Dim, Dim}} <: TensorMapping{T, Dim, Dim} D::TM # Difference operator - stencil_set # Stencil set of the operator + stencil_set::StencilSet # Stencil set of the operator end """ Laplace(grid::Equidistant, stencil_set) -Creates the `Laplace` operator `Δ` on `grid` given a parsed TOML -`stencil_set`. See also [`laplace`](@ref). +Creates the `Laplace` operator `Δ` on `grid` given a `stencil_set`. + +See also [`laplace`](@ref). """ function Laplace(grid::EquidistantGrid, stencil_set) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"])
--- a/test/SbpOperators/boundaryops/boundary_restriction_test.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/test/SbpOperators/boundaryops/boundary_restriction_test.jl Thu Mar 17 21:31:20 2022 +0100 @@ -4,10 +4,10 @@ using Sbplib.Grids using Sbplib.LazyTensors using Sbplib.RegionIndices -import Sbplib.SbpOperators.BoundaryOperator +using Sbplib.SbpOperators: BoundaryOperator, Stencil @testset "boundary_restriction" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order = 4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order = 4) e_closure = parse_stencil(stencil_set["e"]["closure"]) g_1D = EquidistantGrid(11, 0.0, 1.0) g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
--- a/test/SbpOperators/boundaryops/normal_derivative_test.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/test/SbpOperators/boundaryops/normal_derivative_test.jl Thu Mar 17 21:31:20 2022 +0100 @@ -10,7 +10,7 @@ g_1D = EquidistantGrid(11, 0.0, 1.0) g_2D = EquidistantGrid((11,12), (0.0, 0.0), (1.0,1.0)) @testset "normal_derivative" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) d_closure = parse_stencil(stencil_set["d1"]["closure"]) @testset "1D" begin d_l = normal_derivative(g_1D, d_closure, CartesianBoundary{1,Lower}()) @@ -38,7 +38,7 @@ v∂y = evalOn(g_2D, (x,y)-> 2*(y-1) + x) # TODO: Test for higher order polynomials? @testset "2nd order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=2) d_closure = parse_stencil(stencil_set["d1"]["closure"]) d_w, d_e, d_s, d_n = normal_derivative.(Ref(g_2D), Ref(d_closure), boundary_identifiers(g_2D)) @@ -49,7 +49,7 @@ end @testset "4th order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) d_closure = parse_stencil(stencil_set["d1"]["closure"]) d_w, d_e, d_s, d_n = normal_derivative.(Ref(g_2D), Ref(d_closure), boundary_identifiers(g_2D))
--- a/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Thu Mar 17 21:31:20 2022 +0100 @@ -22,7 +22,7 @@ @testset "first_derivative" begin @testset "Constructors" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=2) g₁ = EquidistantGrid(11, 0., 1.) g₂ = EquidistantGrid((11,14), (0.,1.), (1.,3.)) @@ -42,7 +42,7 @@ N = 20 g = EquidistantGrid(N, 0//1,2//1) @testset for order ∈ [2,4] - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order) D₁ = first_derivative(g, stencil_set, 1) @testset "boundary x^$k" for k ∈ 0:order÷2 @@ -72,7 +72,7 @@ g = EquidistantGrid(30, 0.,1.) v = evalOn(g, x->exp(x)) @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)] - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order) D₁ = first_derivative(g, stencil_set, 1) @test D₁*v ≈ v rtol=tol
--- a/test/SbpOperators/volumeops/derivatives/second_derivative_test.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/test/SbpOperators/volumeops/derivatives/second_derivative_test.jl Thu Mar 17 21:31:20 2022 +0100 @@ -8,7 +8,7 @@ @testset "SecondDerivative" begin operator_path = sbp_operators_path()*"standard_diagonal.toml" - stencil_set = read_stencil_set(operator_path; order=4) + stencil_set = StencilSet(operator_path; order=4) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) Lx = 3.5 @@ -50,7 +50,7 @@ # 2nd order interior stencil, 1nd order boundary stencil, # implies that L*v should be exact for monomials up to order 2. @testset "2nd order" begin - stencil_set = read_stencil_set(operator_path; order=2) + stencil_set = StencilSet(operator_path; order=2) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) Dₓₓ = second_derivative(g_1D,inner_stencil,closure_stencils) @@ -63,7 +63,7 @@ # 4th order interior stencil, 2nd order boundary stencil, # implies that L*v should be exact for monomials up to order 3. @testset "4th order" begin - stencil_set = read_stencil_set(operator_path; order=4) + stencil_set = StencilSet(operator_path; order=4) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) Dₓₓ = second_derivative(g_1D,inner_stencil,closure_stencils) @@ -91,7 +91,7 @@ # 2nd order interior stencil, 1st order boundary stencil, # implies that L*v should be exact for binomials up to order 2. @testset "2nd order" begin - stencil_set = read_stencil_set(operator_path; order=2) + stencil_set = StencilSet(operator_path; order=2) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) Dyy = second_derivative(g_2D,inner_stencil,closure_stencils,2) @@ -104,7 +104,7 @@ # 4th order interior stencil, 2nd order boundary stencil, # implies that L*v should be exact for binomials up to order 3. @testset "4th order" begin - stencil_set = read_stencil_set(operator_path; order=4) + stencil_set = StencilSet(operator_path; order=4) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) Dyy = second_derivative(g_2D,inner_stencil,closure_stencils,2)
--- a/test/SbpOperators/volumeops/inner_products/inner_product_test.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/test/SbpOperators/volumeops/inner_products/inner_product_test.jl Thu Mar 17 21:31:20 2022 +0100 @@ -15,7 +15,7 @@ g_3D = EquidistantGrid((10,10, 10), (0.0, 0.0, 0.0), (Lx,Ly,Lz)) integral(H,v) = sum(H*v) @testset "inner_product" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) @testset "0D" begin @@ -41,7 +41,7 @@ end @testset "Sizes" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) @testset "1D" begin @@ -66,7 +66,7 @@ u = evalOn(g_1D,x->sin(x)) @testset "2nd order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=2) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_1D, quadrature_interior, quadrature_closure) @@ -77,7 +77,7 @@ end @testset "4th order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_1D, quadrature_interior, quadrature_closure) @@ -93,7 +93,7 @@ v = b*ones(Float64, size(g_2D)) u = evalOn(g_2D,(x,y)->sin(x)+cos(y)) @testset "2nd order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=2) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_2D, quadrature_interior, quadrature_closure) @@ -101,7 +101,7 @@ @test integral(H,u) ≈ π rtol = 1e-4 end @testset "4th order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_2D, quadrature_interior, quadrature_closure)
--- a/test/SbpOperators/volumeops/inner_products/inverse_inner_product_test.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/test/SbpOperators/volumeops/inner_products/inverse_inner_product_test.jl Thu Mar 17 21:31:20 2022 +0100 @@ -12,7 +12,7 @@ g_1D = EquidistantGrid(77, 0.0, Lx) g_2D = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) @testset "inverse_inner_product" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) @testset "0D" begin @@ -38,7 +38,7 @@ end @testset "Sizes" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) @testset "1D" begin @@ -58,7 +58,7 @@ v = evalOn(g_1D,x->sin(x)) u = evalOn(g_1D,x->x^3-x^2+1) @testset "2nd order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=2) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_1D, quadrature_interior, quadrature_closure) @@ -67,7 +67,7 @@ @test Hi*H*u ≈ u rtol = 1e-15 end @testset "4th order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_1D, quadrature_interior, quadrature_closure) @@ -80,7 +80,7 @@ v = evalOn(g_2D,(x,y)->sin(x)+cos(y)) u = evalOn(g_2D,(x,y)->x*y + x^5 - sqrt(y)) @testset "2nd order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=2) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_2D, quadrature_interior, quadrature_closure) @@ -89,7 +89,7 @@ @test Hi*H*u ≈ u rtol = 1e-15 end @testset "4th order" begin - stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4) + stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=4) quadrature_interior = parse_scalar(stencil_set["H"]["inner"]) quadrature_closure = parse_tuple(stencil_set["H"]["closure"]) H = inner_product(g_2D, quadrature_interior, quadrature_closure)
--- a/test/SbpOperators/volumeops/laplace/laplace_test.jl Wed Mar 16 18:39:00 2022 +0100 +++ b/test/SbpOperators/volumeops/laplace/laplace_test.jl Thu Mar 17 21:31:20 2022 +0100 @@ -6,7 +6,7 @@ # Default stencils (4th order) operator_path = sbp_operators_path()*"standard_diagonal.toml" -stencil_set = read_stencil_set(operator_path; order=4) +stencil_set = StencilSet(operator_path; order=4) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) g_1D = EquidistantGrid(101, 0.0, 1.) @@ -42,7 +42,7 @@ # 2nd order interior stencil, 1st order boundary stencil, # implies that L*v should be exact for binomials up to order 2. @testset "2nd order" begin - stencil_set = read_stencil_set(operator_path; order=2) + stencil_set = StencilSet(operator_path; order=2) Δ = Laplace(g_3D, stencil_set) @test Δ*polynomials[1] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 @test Δ*polynomials[2] ≈ zeros(Float64, size(g_3D)...) atol = 5e-9 @@ -53,7 +53,7 @@ # 4th order interior stencil, 2nd order boundary stencil, # implies that L*v should be exact for binomials up to order 3. @testset "4th order" begin - stencil_set = read_stencil_set(operator_path; order=4) + stencil_set = StencilSet(operator_path; order=4) Δ = Laplace(g_3D, stencil_set) # NOTE: high tolerances for checking the "exact" differentiation # due to accumulation of round-off errors/cancellation errors?