changeset 617:f59e1732eacc feature/volume_and_boundary_operators

Merge with default
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 07 Dec 2020 12:07:29 +0100
parents d9324671b412 (current diff) 52749b687a67 (diff)
children c64793f77509
files src/SbpOperators/operators/d2_2nd.txt src/SbpOperators/operators/d2_4th.txt src/SbpOperators/operators/h_2nd.txt src/SbpOperators/operators/h_4th.txt test/testSbpOperators.jl
diffstat 14 files changed, 295 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/Manifest.toml	Mon Dec 07 11:57:36 2020 +0100
+++ b/Manifest.toml	Mon Dec 07 12:07:29 2020 +0100
@@ -1,12 +1,29 @@
 # This file is machine-generated - editing it directly is not advised
 
+[[Dates]]
+deps = ["Printf"]
+uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
+
 [[OffsetArrays]]
 git-tree-sha1 = "9011c7c98769c451f83869a4d66461e2f23bc80b"
 uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
 version = "1.2.1"
 
+[[Printf]]
+deps = ["Unicode"]
+uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
+
+[[TOML]]
+deps = ["Dates"]
+git-tree-sha1 = "d0ac7eaad0fb9f6ba023a1d743edca974ae637c4"
+uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
+version = "1.0.0"
+
 [[TiledIteration]]
 deps = ["OffsetArrays"]
 git-tree-sha1 = "98693daea9bb49aba71eaad6b168b152d2310358"
 uuid = "06e1c1a7-607b-532d-9fad-de7d9aa2abac"
 version = "0.2.4"
+
+[[Unicode]]
+uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
--- a/Project.toml	Mon Dec 07 11:57:36 2020 +0100
+++ b/Project.toml	Mon Dec 07 12:07:29 2020 +0100
@@ -4,6 +4,7 @@
 version = "0.1.0"
 
 [deps]
+TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
 TiledIteration = "06e1c1a7-607b-532d-9fad-de7d9aa2abac"
 
 [compat]
--- a/src/SbpOperators/d2.jl	Mon Dec 07 11:57:36 2020 +0100
+++ b/src/SbpOperators/d2.jl	Mon Dec 07 12:07:29 2020 +0100
@@ -1,4 +1,4 @@
-export D2, closuresize, readOperator
+export D2, closuresize
 
 @enum Parity begin
     odd = -1
--- a/src/SbpOperators/operators/d2_2nd.txt	Mon Dec 07 11:57:36 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-# D2 order 2
-
-boundary_stencils
-1 -2 1
-
-inner_stencil
-1 -2 1
-
-e
-1
-
-d1
--3/2 2 -1/2
--- a/src/SbpOperators/operators/d2_4th.txt	Mon Dec 07 11:57:36 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-# D2 order 4
-
-boundary_stencils
-     2    -5       4      -1     0     0
-     1    -2       1       0     0     0
- -4/43 59/43 -110/43   59/43 -4/43     0
- -1/49     0   59/49 -118/49 64/49 -4/49
-
-inner_stencil
--1/12     4/3  -5/2   4/3 -1/12
-
-e
-1
-
-d1
--11/6 3 -3/2 1/3
\ No newline at end of file
--- a/src/SbpOperators/operators/h_2nd.txt	Mon Dec 07 11:57:36 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-# H order 2
-
-closure
-1/2
-
-inner_stencil
-1
--- a/src/SbpOperators/operators/h_4th.txt	Mon Dec 07 11:57:36 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-# H order 4
-
-closure
-17/48 59/48 43/48 49/48
-
-inner_stencil
-1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SbpOperators/operators/standard_diagonal.toml	Mon Dec 07 12:07:29 2020 +0100
@@ -0,0 +1,36 @@
+[meta]
+authors = "Ken Mattson"
+descripion = "Standard operators for equidistant grids"
+type = "equidistant"
+
+[order2]
+H.inner = ["1"]
+H.closure = ["1/2"]
+
+D1.inner_stencil = ["-1/2", "0", "1/2"]
+D1.closure_stencils = [
+    ["-1", "1"],
+]
+
+D2.inner_stencil = ["1", "-2", "1"]
+D2.closure_stencils = [
+    ["1", "-2", "1"],
+]
+
+e.closure = ["1"]
+d1.closure = ["-3/2", "2", "-1/2"]
+
+[order4]
+H.inner = ["1"]
+H.closure = ["17/48", "59/48", "43/48", "49/48"]
+
+D2.inner_stencil = ["-1/12","4/3","-5/2","4/3","-1/12"]
+D2.closure_stencils = [
+    [     "2",    "-5",      "4",       "-1",     "0",     "0"],
+    [     "1",    "-2",      "1",        "0",     "0",     "0"],
+    [ "-4/43", "59/43", "-110/43",   "59/43", "-4/43",     "0"],
+    [ "-1/49",     "0",   "59/49", "-118/49", "64/49", "-4/49"],
+]
+
+e.closure = ["1"]
+d1.closure = ["-11/6", "3", "-3/2", "1/3"]
--- a/src/SbpOperators/readoperator.jl	Mon Dec 07 11:57:36 2020 +0100
+++ b/src/SbpOperators/readoperator.jl	Mon Dec 07 12:07:29 2020 +0100
@@ -1,30 +1,39 @@
-function readOperator(D2fn, Hfn)
-    d = readSectionedFile(D2fn)
-    h = readSectionedFile(Hfn)
+using TOML
+
+export read_D2_operator
+export read_stencil
+export read_stencils
+export read_tuple
+
+export get_stencil
+export get_stencils
+export get_tuple
+
+
+function read_D2_operator(fn; order)
+    operators = TOML.parsefile(fn)["order$order"]
+    D2 = operators["D2"]
+    H = operators["H"]
+    e = operators["e"]
+    d1 = operators["d1"]
 
     # Create inner stencil
-    innerStencilWeights = stringToTuple(Float64, d["inner_stencil"][1])
-    width = length(innerStencilWeights)
-    r = (-div(width,2), div(width,2))
-
-    innerStencil = Stencil(r, innerStencilWeights)
+    innerStencil = get_stencil(operators, "D2", "inner_stencil")
 
     # Create boundary stencils
-    boundarySize = length(d["boundary_stencils"])
+    boundarySize = length(D2["closure_stencils"])
     closureStencils = Vector{typeof(innerStencil)}() # TBD: is the the right way to get the correct type?
 
     for i ∈ 1:boundarySize
-        stencilWeights = stringToTuple(Float64, d["boundary_stencils"][i])
-        width = length(stencilWeights)
-        r = (1-i,width-i)
-        closureStencils = (closureStencils..., Stencil(r, stencilWeights))
+        closureStencils = (closureStencils..., get_stencil(operators, "D2", "closure_stencils", i; center=i))
     end
 
-    quadratureClosure = pad_tuple(stringToTuple(Float64, h["closure"][1]), boundarySize)
-    eClosure = Stencil((0,boundarySize-1), pad_tuple(stringToTuple(Float64, d["e"][1]), boundarySize))
-    dClosure = Stencil((0,boundarySize-1), pad_tuple(stringToTuple(Float64, d["d1"][1]), boundarySize))
+    # TODO: Get rid of the padding here. Any padding should be handled by the consturctor accepting the stencils.
+    quadratureClosure = pad_tuple(toml_string_array_to_tuple(Float64, H["closure"]), boundarySize)
+    eClosure = Stencil(pad_tuple(toml_string_array_to_tuple(Float64, e["closure"]), boundarySize), center=1)
+    dClosure = Stencil(pad_tuple(toml_string_array_to_tuple(Float64, d1["closure"]), boundarySize), center=1)
 
-    d2 = D2(
+    d2 = SbpOperators.D2(
         quadratureClosure,
         innerStencil,
         closureStencils,
@@ -36,36 +45,100 @@
     return d2
 end
 
-function readSectionedFile(filename)::Dict{String, Vector{String}}
-    f = open(filename)
-    sections = Dict{String, Vector{String}}()
-    currentKey = ""
+
+"""
+    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.
+
+See also: [`read_stencils`](@ref), [`read_tuple`](@ref), [`get_stencil`](@ref).
 
-    for ln ∈ eachline(f)
-        if ln == "" || ln[1] == '#' # Skip comments and empty lines
-            continue
-        end
+# 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)
+
+"""
+    read_stencils(fn, path...; centers)
+
+Read stencils at `path` from the file `fn`.
+Centers of the stencils are specified as a tuple or array in `centers`.
 
-        if isletter(ln[1]) # Found start of new section
-            if ~haskey(sections, ln)
-                sections[ln] =  Vector{String}()
-            end
-            currentKey = ln
-            continue
-        end
+See also: [`read_stencil`](@ref), [`read_tuple`](@ref), [`get_stencils`](@ref).
+"""
+read_stencils(fn, path...; centers) = get_stencils(TOML.parsefile(fn), path...; centers=centers)
+
+"""
+    read_tuple(fn, path...)
+
+Read tuple at `path` from the file `fn`.
+
+See also: [`read_stencil`](@ref), [`read_stencils`](@ref), [`get_tuple`](@ref).
+"""
+read_tuple(fn, path...) = get_tuple(TOML.parsefile(fn), path...)
 
-        push!(sections[currentKey], ln)
+"""
+    get_stencil(parsed_toml, path...; center=nothing)
+
+Same as [`read_stencil`](@ref)) but takes already parsed toml.
+"""
+get_stencil(parsed_toml, path...; center=nothing) = get_stencil(parsed_toml[path[1]], path[2:end]...; center=center)
+function get_stencil(parsed_toml; center=nothing)
+    @assert parsed_toml isa Vector{String}
+    stencil_weights = Float64.(parse_rational.(parsed_toml))
+
+    width = length(stencil_weights)
+
+    if isnothing(center)
+        center = div(width,2)+1
     end
 
-    return sections
+    return Stencil(Tuple(stencil_weights), center=center)
 end
 
-function stringToTuple(T::DataType, s::String)
-    return Tuple(stringToVector(T,s))
+"""
+    get_stencils(parsed_toml, path...; centers)
+
+Same as [`read_stencils`](@ref)) but takes already parsed toml.
+"""
+get_stencils(parsed_toml, path...; centers) = get_stencils(parsed_toml[path[1]], path[2:end]...; centers=centers)
+function get_stencils(parsed_toml; centers)
+    @assert parsed_toml isa Vector{Vector{String}}
+    @assert length(centers) == length(parsed_toml)
+
+    stencils = ()
+    for i ∈ 1:length(parsed_toml)
+        stencil = get_stencil(parsed_toml[i], center = centers[i])
+        stencils = (stencils..., stencil)
+    end
+
+    return stencils
 end
 
-function stringToVector(T::DataType, s::String)
-    return T.(eval.(Meta.parse.(split(s))))
+"""
+    get_tuple(parsed_toml, path...)
+
+Same as [`read_tuple`](@ref)) but takes already parsed toml.
+"""
+get_tuple(parsed_toml, path...) = get_tuple(parsed_toml[path[1]], path[2:end]...)
+function get_tuple(parsed_toml)
+    @assert parsed_toml isa Vector{String}
+    t = Tuple(Float64.(parse_rational.(parsed_toml)))
+    return t
+end
+
+# TODO: Probably should be deleted once we have gotten rid of read_D2_operator()
+function toml_string_array_to_tuple(::Type{T}, arr::AbstractVector{String}) where T
+    return Tuple(T.(parse_rational.(arr)))
+end
+
+function parse_rational(str)
+    expr = Meta.parse(replace(str, "/"=>"//"))
+    return eval(:(Rational($expr)))
 end
 
 function pad_tuple(t::NTuple{N, T}, n::Integer) where {N,T}
--- a/src/SbpOperators/stencil.jl	Mon Dec 07 11:57:36 2020 +0100
+++ b/src/SbpOperators/stencil.jl	Mon Dec 07 12:07:29 2020 +0100
@@ -9,6 +9,18 @@
 end
 
 """
+    Stencil(weights::NTuple; center::Int)
+
+Create a stencil with the given weights with element `center` as the center of the stencil.
+"""
+function Stencil(weights::NTuple; center::Int)
+    N = length(weights)
+    range = (1, N) .- center
+
+    return Stencil(range, weights)
+end
+
+"""
     scale(s::Stencil, a)
 
 Scale the weights of the stencil `s` with `a` and return a new stencil.
--- a/test/Manifest.toml	Mon Dec 07 11:57:36 2020 +0100
+++ b/test/Manifest.toml	Mon Dec 07 12:07:29 2020 +0100
@@ -109,6 +109,12 @@
 uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
 version = "0.10.3"
 
+[[TOML]]
+deps = ["Dates"]
+git-tree-sha1 = "d0ac7eaad0fb9f6ba023a1d743edca974ae637c4"
+uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
+version = "1.0.0"
+
 [[Test]]
 deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
 uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
--- a/test/Project.toml	Mon Dec 07 11:57:36 2020 +0100
+++ b/test/Project.toml	Mon Dec 07 12:07:29 2020 +0100
@@ -1,5 +1,6 @@
 [deps]
 LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
+TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
 Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
 TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04"
 Tullio = "bc48ee85-29a4-5162-ae0b-a64e1601d4bc"
--- a/test/testDiffOps.jl	Mon Dec 07 11:57:36 2020 +0100
+++ b/test/testDiffOps.jl	Mon Dec 07 12:07:29 2020 +0100
@@ -8,7 +8,7 @@
 @testset "DiffOps" begin
 #
 # @testset "BoundaryValue" begin
-#     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+#     op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
 #     g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0))
 #
 #     e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}())
@@ -69,7 +69,7 @@
 # end
 #
 # @testset "NormalDerivative" begin
-#     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+#     op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
 #     g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0))
 #
 #     d_w = NormalDerivative(op, g, CartesianBoundary{1,Lower}())
@@ -146,7 +146,7 @@
 # end
 #
 # @testset "BoundaryQuadrature" begin
-#     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+#     op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
 #     g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0))
 #
 #     H_w = BoundaryQuadrature(op, g, CartesianBoundary{1,Lower}())
--- a/test/testSbpOperators.jl	Mon Dec 07 11:57:36 2020 +0100
+++ b/test/testSbpOperators.jl	Mon Dec 07 12:07:29 2020 +0100
@@ -4,19 +4,112 @@
 using Sbplib.RegionIndices
 using Sbplib.LazyTensors
 using LinearAlgebra
+using TOML
+
+import Sbplib.SbpOperators.Stencil
 
 @testset "SbpOperators" begin
 
 @testset "Stencil" begin
-    s = SbpOperators.Stencil((-2,2), (1.,2.,2.,3.,4.))
-    @test s isa SbpOperators.Stencil{Float64, 5}
+    s = Stencil((-2,2), (1.,2.,2.,3.,4.))
+    @test s isa Stencil{Float64, 5}
 
     @test eltype(s) == Float64
-    @test SbpOperators.scale(s, 2) == SbpOperators.Stencil((-2,2), (2.,4.,4.,6.,8.))
+    @test SbpOperators.scale(s, 2) == Stencil((-2,2), (2.,4.,4.,6.,8.))
+
+    @test Stencil((1,2,3,4), center=1) == Stencil((0, 3),(1,2,3,4))
+    @test Stencil((1,2,3,4), center=2) == Stencil((-1, 2),(1,2,3,4))
+    @test Stencil((1,2,3,4), center=4) == Stencil((-3, 0),(1,2,3,4))
+end
+
+@testset "parse_rational" begin
+    @test SbpOperators.parse_rational("1") isa Rational
+    @test SbpOperators.parse_rational("1") == 1//1
+    @test SbpOperators.parse_rational("1/2") isa Rational
+    @test SbpOperators.parse_rational("1/2") == 1//2
+    @test SbpOperators.parse_rational("37/13") isa Rational
+    @test SbpOperators.parse_rational("37/13") == 37//13
+end
+
+@testset "readoperator" begin
+    toml_str = """
+        [meta]
+        type = "equidistant"
+
+        [order2]
+        H.inner = ["1"]
+
+        D1.inner_stencil = ["-1/2", "0", "1/2"]
+        D1.closure_stencils = [
+            ["-1", "1"],
+        ]
+
+        d1.closure = ["-3/2", "2", "-1/2"]
+
+        [order4]
+        H.closure = ["17/48", "59/48", "43/48", "49/48"]
+
+        D2.inner_stencil = ["-1/12","4/3","-5/2","4/3","-1/12"]
+        D2.closure_stencils = [
+            [     "2",    "-5",      "4",       "-1",     "0",     "0"],
+            [     "1",    "-2",      "1",        "0",     "0",     "0"],
+            [ "-4/43", "59/43", "-110/43",   "59/43", "-4/43",     "0"],
+            [ "-1/49",     "0",   "59/49", "-118/49", "64/49", "-4/49"],
+        ]
+    """
+
+    parsed_toml = TOML.parse(toml_str)
+    @testset "get_stencil" begin
+        @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil") == Stencil((-1/2, 0., 1/2), center=2)
+        @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=1) == Stencil((-1/2, 0., 1/2); center=1)
+        @test get_stencil(parsed_toml, "order2", "D1", "inner_stencil", center=3) == Stencil((-1/2, 0., 1/2); center=3)
+
+        @test get_stencil(parsed_toml, "order2", "H", "inner") == Stencil((1.,), center=1)
+
+        @test_throws AssertionError get_stencil(parsed_toml, "meta", "type")
+        @test_throws AssertionError get_stencil(parsed_toml, "order2", "D1", "closure_stencils")
+    end
+
+    @testset "get_stencils" begin
+        @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(1,)) == (Stencil((-1., 1.), center=1),)
+        @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=(2,)) == (Stencil((-1., 1.), center=2),)
+        @test get_stencils(parsed_toml, "order2", "D1", "closure_stencils", centers=[2]) == (Stencil((-1., 1.), center=2),)
+
+        @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=[1,1,1,1]) == (
+            Stencil((    2.,    -5.,      4.,     -1.,    0.,    0.), center=1),
+            Stencil((    1.,    -2.,      1.,      0.,    0.,    0.), center=1),
+            Stencil(( -4/43,  59/43, -110/43,   59/43, -4/43,    0.), center=1),
+            Stencil(( -1/49,     0.,   59/49, -118/49, 64/49, -4/49), center=1),
+        )
+
+        @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(4,2,3,1)) == (
+            Stencil((    2.,    -5.,      4.,     -1.,    0.,    0.), center=4),
+            Stencil((    1.,    -2.,      1.,      0.,    0.,    0.), center=2),
+            Stencil(( -4/43,  59/43, -110/43,   59/43, -4/43,    0.), center=3),
+            Stencil(( -1/49,     0.,   59/49, -118/49, 64/49, -4/49), center=1),
+        )
+
+        @test get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=1:4) == (
+            Stencil((    2.,    -5.,      4.,     -1.,    0.,    0.), center=1),
+            Stencil((    1.,    -2.,      1.,      0.,    0.,    0.), center=2),
+            Stencil(( -4/43,  59/43, -110/43,   59/43, -4/43,    0.), center=3),
+            Stencil(( -1/49,     0.,   59/49, -118/49, 64/49, -4/49), center=4),
+        )
+
+        @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3))
+        @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "closure_stencils",centers=(1,2,3,5,4))
+        @test_throws AssertionError get_stencils(parsed_toml, "order4", "D2", "inner_stencil",centers=(1,2))
+    end
+
+    @testset "get_tuple" begin
+        @test get_tuple(parsed_toml, "order2", "d1", "closure") == (-3/2, 2, -1/2)
+
+        @test_throws AssertionError get_tuple(parsed_toml, "meta", "type")
+    end
 end
 
 # @testset "apply_quadrature" begin
-#     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+#     op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
 #     h = 0.5
 #
 #     @test apply_quadrature(op, h, 1.0, 10, 100) == h
@@ -37,7 +130,7 @@
 # end
 
 @testset "SecondDerivative" begin
-    op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+    op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
     L = 3.5
     g = EquidistantGrid(101, 0.0, L)
     Dₓₓ = SecondDerivative(g,op.innerStencil,op.closureStencils)
@@ -77,7 +170,7 @@
 
 
 @testset "Laplace2D" begin
-    op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+    op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
     Lx = 1.5
     Ly = 3.2
     g = EquidistantGrid((102,131), (0.0, 0.0), (Lx,Ly))
@@ -119,7 +212,7 @@
 end
 
 @testset "DiagonalInnerProduct" begin
-    op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+    op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
     L = 2.3
     g = EquidistantGrid(77, 0.0, L)
     H = DiagonalInnerProduct(g,op.quadratureClosure)
@@ -132,7 +225,7 @@
 end
 
 @testset "Quadrature" begin
-    op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+    op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
     Lx = 2.3
     Ly = 5.2
     g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly))
@@ -152,7 +245,7 @@
 end
 
 @testset "InverseDiagonalInnerProduct" begin
-    op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+    op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
     L = 2.3
     g = EquidistantGrid(77, 0.0, L)
     H = DiagonalInnerProduct(g, op.quadratureClosure)
@@ -166,7 +259,7 @@
 end
 
 @testset "InverseQuadrature" begin
-    op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+    op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
     Lx = 7.3
     Ly = 8.2
     g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly))
@@ -182,7 +275,7 @@
 end
 
 @testset "BoundaryOperator" begin
-    closure_stencil = SbpOperators.Stencil((0,2), (2.,1.,3.))
+    closure_stencil = Stencil((0,2), (2.,1.,3.))
     g_1D = EquidistantGrid(11, 0.0, 1.0)
     g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
 
@@ -327,7 +420,7 @@
 end
 
 @testset "BoundaryRestriction" begin
-    op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+    op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
     g_1D = EquidistantGrid(11, 0.0, 1.0)
     g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
 
@@ -407,7 +500,7 @@
 end
 #
 # @testset "NormalDerivative" begin
-#     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+#     op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
 #     g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0))
 #
 #     d_w = NormalDerivative(op, g, CartesianBoundary{1,Lower}())
@@ -484,7 +577,7 @@
 # end
 #
 # @testset "BoundaryQuadrature" begin
-#     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
+#     op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
 #     g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0))
 #
 #     H_w = BoundaryQuadrature(op, g, CartesianBoundary{1,Lower}())