changeset 1033:0cb4c6b15d8e feature/dissipation_operators

Make closures have the same number of weights in all stencils
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 22 Mar 2022 11:27:45 +0100
parents 11767fbb29f4
children ed19c549c506
files src/SbpOperators/volumeops/derivatives/dissipation.jl test/SbpOperators/volumeops/derivatives/dissipation_test.jl
diffstat 2 files changed, 26 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/derivatives/dissipation.jl	Tue Mar 22 11:18:57 2022 +0100
+++ b/src/SbpOperators/volumeops/derivatives/dissipation.jl	Tue Mar 22 11:27:45 2022 +0100
@@ -27,8 +27,19 @@
 dissipation_lower_closure_stencils(interior_weights) = ntuple(i->Stencil(interior_weights..., center=i                       ), dissipation_lower_closure_size(interior_weights))
 dissipation_upper_closure_stencils(interior_weights) = ntuple(i->Stencil(interior_weights..., center=length(interior_weights)-dissipation_upper_closure_size(interior_weights)+i), dissipation_upper_closure_size(interior_weights))
 
-dissipation_transpose_lower_closure_stencils(interior_weights) =         ntuple(i->dissipation_transpose_lower_closure_stencil(interior_weights, i), length(interior_weights))
-dissipation_transpose_upper_closure_stencils(interior_weights) = reverse(ntuple(i->dissipation_transpose_upper_closure_stencil(interior_weights, i), length(interior_weights)))
+function dissipation_transpose_lower_closure_stencils(interior_weights)
+    closure = ntuple(i->dissipation_transpose_lower_closure_stencil(interior_weights, i), length(interior_weights))
+
+    N = maximum(s->length(s.weights), closure)
+    return right_pad.(closure, N)
+end
+
+function dissipation_transpose_upper_closure_stencils(interior_weights)
+    closure = reverse(ntuple(i->dissipation_transpose_upper_closure_stencil(interior_weights, i), length(interior_weights)))
+
+    N = maximum(s->length(s.weights), closure)
+    return left_pad.(closure, N)
+end
 
 
 function dissipation_transpose_lower_closure_stencil(interior_weights, i)
--- a/test/SbpOperators/volumeops/derivatives/dissipation_test.jl	Tue Mar 22 11:18:57 2022 +0100
+++ b/test/SbpOperators/volumeops/derivatives/dissipation_test.jl	Tue Mar 22 11:27:45 2022 +0100
@@ -145,18 +145,18 @@
 @testset "dissipation_transpose_lower_closure_stencils" begin
     cases = (
         (-1,1) => (
-            Stencil(-1,-1,    center=1),
+            Stencil(-1,-1, 0, center=1),
             Stencil( 1, 1,-1, center=2),
         ),
         (1,-2,1) => (
-            Stencil( 1, 1,    center=1),
-            Stencil(-2,-2, 1,  center=2),
+            Stencil( 1, 1, 0, 0, center=1),
+            Stencil(-2,-2, 1, 0, center=2),
             Stencil( 1, 1,-2, 1, center=3),
         ),
         (-1,3,-3,1) => (
-            Stencil(-1,-1,-1,          center=1),
-            Stencil( 3, 3, 3,-1,       center=2),
-            Stencil(-3,-3,-3, 3,-1,    center=3),
+            Stencil(-1,-1,-1, 0, 0, 0, center=1),
+            Stencil( 3, 3, 3,-1, 0, 0, center=2),
+            Stencil(-3,-3,-3, 3,-1, 0, center=3),
             Stencil( 1, 1, 1,-3, 3,-1, center=4),
         ),
     )
@@ -169,18 +169,18 @@
     cases = (
         (-1,1) => (
             Stencil( 1,-1, center = 1),
-            Stencil(    1, center = 1),
+            Stencil( 0, 1, center = 2),
         ),
         (1,-2,1) => (
-            Stencil( 1, -2, 1, 1, center=2),
-            Stencil(     1,-2,-2, center=2),
-            Stencil(        1, 1, center=2),
+            Stencil( 1,-2, 1, 1, center=2),
+            Stencil( 0, 1,-2,-2, center=3),
+            Stencil( 0, 0, 1, 1, center=4),
         ),
         (-1,3,-3,1) => (
             Stencil( 1,-3, 3,-1,-1, center=2),
-            Stencil(    1,-3, 3, 3, center=2),
-            Stencil(       1,-3,-3, center=2),
-            Stencil(          1, 1, center=2),
+            Stencil( 0, 1,-3, 3, 3, center=3),
+            Stencil( 0, 0, 1,-3,-3, center=4),
+            Stencil( 0, 0, 0, 1, 1, center=5),
         ),
     )
     @testset "interior_weights = $w" for (w, closure_stencils) ∈ cases