changeset 514:14e722e8607d feature/boundary_ops

Clean up constructors
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 23 Nov 2020 21:19:08 +0100
parents 547639572208
children d55008f5e2f3
files src/SbpOperators/boundaryops/boundary_restriction.jl test/testSbpOperators.jl
diffstat 2 files changed, 18 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl	Mon Nov 23 20:22:14 2020 +0100
+++ b/src/SbpOperators/boundaryops/boundary_restriction.jl	Mon Nov 23 21:19:08 2020 +0100
@@ -1,17 +1,22 @@
-function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary) where {T,M}
+function boundary_restriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{1}) where {T,M}
+    r = region(boundary)
+    return e = BoundaryRestriction(grid, closureStencil, r())
+end
+
+function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{1}) where {T,M}
     r = region(boundary)
-    d = dim(boundary)
-    d_orth = 3-d # orthogonal dimension
-    e = BoundaryRestriction(restrict(grid, d), closureStencil, r())
-    I = IdentityMapping{T}(size(restrict(grid,d_orth)))
-    if d == 1
-        return e⊗I
-    elseif d == 2
-        return I⊗e
-    else
-        # throw error
-    end
+    e = BoundaryRestriction(restrict(grid, 1), closureStencil, r())
+    I = IdentityMapping{T}(size(restrict(grid,2)))
+    return e⊗I
 end
+
+function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{2}) where {T,M}
+    r = region(boundary)
+    e = BoundaryRestriction(restrict(grid, 2), closureStencil, r())
+    I = IdentityMapping{T}(size(restrict(grid,1)))
+    return I⊗e
+end
+
 export boundary_restriction
 
 """
@@ -25,7 +30,7 @@
 end
 export BoundaryRestriction
 
-function BoundaryRestriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, region::Region) where {T,M}
+function BoundaryRestriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, region::Region) where {T,M,R}
     return BoundaryRestriction{T,M,typeof(region)}(closureStencil,size(grid))
 end
 
--- a/test/testSbpOperators.jl	Mon Nov 23 20:22:14 2020 +0100
+++ b/test/testSbpOperators.jl	Mon Nov 23 21:19:08 2020 +0100
@@ -192,10 +192,6 @@
     @test_throws BoundsError (e_l*v)[Index{Lower}(3)]
     @test_throws BoundsError (e_r*v)[Index{Upper}(3)]
 
-
-
-
-
     g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0))
 
     e_w = boundary_restriction(g, op.eClosure, CartesianBoundary{1,Lower}())