diff src/SbpOperators/stencil.jl @ 595:03ef4d4740ab refactor/toml_operator_format

Add a constructor for Stencil where you can specify the center of the stencil
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 02 Dec 2020 17:10:18 +0100
parents 4aa7fe13a984
children e14627e79a54
line wrap: on
line diff
--- a/src/SbpOperators/stencil.jl	Wed Dec 02 15:26:13 2020 +0100
+++ b/src/SbpOperators/stencil.jl	Wed Dec 02 17:10:18 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.