changeset 754:dc38e57ebd1b feature/laplace_opset

Add convenience functions for returning multiple boundary operators from Laplace
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sun, 21 Mar 2021 13:44:29 +0100
parents fc83d672be36
children 36adc15d3935
files src/SbpOperators/volumeops/laplace/laplace.jl test/SbpOperators/volumeops/laplace/laplace_test.jl
diffstat 2 files changed, 39 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/laplace/laplace.jl	Fri Mar 19 17:13:04 2021 +0100
+++ b/src/SbpOperators/volumeops/laplace/laplace.jl	Sun Mar 21 13:44:29 2021 +0100
@@ -58,12 +58,18 @@
 export inner_product
 inverse_inner_product(L::Laplace) = L.H_inv
 export inverse_inner_product
-boundary_restriction(L::Laplace,bid::BoundaryIdentifier) = L.e[bid]
+boundary_restriction(L::Laplace,id::BoundaryIdentifier) = L.e[id]
+boundary_restriction(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.e[ids[i]],N)
+boundary_restriction(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.e[ids[i]],N)
 export boundary_restriction
-normal_derivative(L::Laplace,bid::BoundaryIdentifier) = L.d[bid]
+normal_derivative(L::Laplace,id::BoundaryIdentifier) = L.d[id]
+normal_derivative(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.d[ids[i]],N)
+normal_derivative(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.d[ids[i]],N)
 export normal_derivative
 # TODO: boundary_inner_product?
-boundary_quadrature(L::Laplace,bid::BoundaryIdentifier) = L.H_boundary[bid]
+boundary_quadrature(L::Laplace,id::BoundaryIdentifier) = L.H_boundary[id]
+boundary_quadrature(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.H_boundary[ids[i]],N)
+boundary_quadrature(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.H_boundary[ids[i]],N)
 export boundary_quadrature
 
 """
--- a/test/SbpOperators/volumeops/laplace/laplace_test.jl	Fri Mar 19 17:13:04 2021 +0100
+++ b/test/SbpOperators/volumeops/laplace/laplace_test.jl	Sun Mar 21 13:44:29 2021 +0100
@@ -111,13 +111,22 @@
     @testset "boundary_restriction" begin
         L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
         (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D)
-        ids = boundary_identifiers(g_3D)
         @test boundary_restriction(L,id_l) == boundary_restriction(g_3D,op.eClosure,id_l)
         @test boundary_restriction(L,id_r) == boundary_restriction(g_3D,op.eClosure,id_r)
         @test boundary_restriction(L,id_s) == boundary_restriction(g_3D,op.eClosure,id_s)
         @test boundary_restriction(L,id_n) == boundary_restriction(g_3D,op.eClosure,id_n)
         @test boundary_restriction(L,id_b) == boundary_restriction(g_3D,op.eClosure,id_b)
         @test boundary_restriction(L,id_t) == boundary_restriction(g_3D,op.eClosure,id_t)
+
+        ids = boundary_identifiers(g_3D)
+        es = boundary_restriction(L,ids)
+        @test es ==  (boundary_restriction(L,id_l),
+                      boundary_restriction(L,id_r),
+                      boundary_restriction(L,id_s),
+                      boundary_restriction(L,id_n),
+                      boundary_restriction(L,id_b),
+                      boundary_restriction(L,id_t));
+        @test es == boundary_restriction(L,ids...)
     end
 
     @testset "normal_derivative" begin
@@ -129,6 +138,16 @@
         @test normal_derivative(L,id_n) == normal_derivative(g_3D,op.dClosure,id_n)
         @test normal_derivative(L,id_b) == normal_derivative(g_3D,op.dClosure,id_b)
         @test normal_derivative(L,id_t) == normal_derivative(g_3D,op.dClosure,id_t)
+
+        ids = boundary_identifiers(g_3D)
+        ds = normal_derivative(L,ids)
+        @test ds ==  (normal_derivative(L,id_l),
+                      normal_derivative(L,id_r),
+                      normal_derivative(L,id_s),
+                      normal_derivative(L,id_n),
+                      normal_derivative(L,id_b),
+                      normal_derivative(L,id_t));
+        @test ds == normal_derivative(L,ids...)
     end
 
     @testset "boundary_quadrature" begin
@@ -140,6 +159,16 @@
         @test boundary_quadrature(L,id_n) == inner_product(boundary_grid(g_3D,id_n),op.quadratureClosure)
         @test boundary_quadrature(L,id_b) == inner_product(boundary_grid(g_3D,id_b),op.quadratureClosure)
         @test boundary_quadrature(L,id_t) == inner_product(boundary_grid(g_3D,id_t),op.quadratureClosure)
+
+        ids = boundary_identifiers(g_3D)
+        H_gammas = boundary_quadrature(L,ids)
+        @test H_gammas ==  (boundary_quadrature(L,id_l),
+                            boundary_quadrature(L,id_r),
+                            boundary_quadrature(L,id_s),
+                            boundary_quadrature(L,id_n),
+                            boundary_quadrature(L,id_b),
+                            boundary_quadrature(L,id_t));
+        @test H_gammas == boundary_quadrature(L,ids...)
     end
 
     # Exact differentiation is measured point-wise. In other cases