changeset 1046:19ed046aec52 feature/getBoundaryOp

Clean up getBoundaryOps for a few schemes
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 22 Jan 2019 17:37:07 +0100
parents dc1bcbef2a86
children 6bc55a773e7c
files +scheme/Beam.m +scheme/Laplace1d.m +scheme/LaplaceCurvilinear.m
diffstat 3 files changed, 7 insertions(+), 95 deletions(-) [+]
line wrap: on
line diff
diff -r dc1bcbef2a86 -r 19ed046aec52 +scheme/Beam.m
--- a/+scheme/Beam.m	Tue Jan 22 17:12:22 2019 +0100
+++ b/+scheme/Beam.m	Tue Jan 22 17:37:07 2019 +0100
@@ -249,47 +249,10 @@
         % op        -- string
         % boundary  -- string
         function o = getBoundaryOperator(obj, op, boundary)
+            assertIsMember(op, {'e', 'd1', 'd2', 'd3'})
             assertIsMember(boundary, {'l', 'r'})
 
-            switch op
-                case 'e'
-                    switch boundary
-                    case 'l'
-                        e = obj.e_l;
-                    case 'r'
-                        e = obj.e_r;
-                    end
-                    o = e;
-
-                case 'd1'
-                    switch boundary
-                    case 'l'
-                        d1 = obj.d1_l;
-                    case 'r'
-                        d1 = obj.d1_r;
-                    end
-                    o = d1;
-                end
-
-                case 'd2'
-                    switch boundary
-                    case 'l'
-                        d2 = obj.d2_l;
-                    case 'r'
-                        d2 = obj.d2_r;
-                    end
-                    o = d2;
-                end
-
-                case 'd3'
-                    switch boundary
-                    case 'l'
-                        d3 = obj.d3_l;
-                    case 'r'
-                        d3 = obj.d3_r;
-                    end
-                    o = d3;
-            end
+            o = obj.([op, '_', boundary]);
         end
 
         % Returns the boundary sign. The right boundary is considered the positive boundary
diff -r dc1bcbef2a86 -r 19ed046aec52 +scheme/Laplace1d.m
--- a/+scheme/Laplace1d.m	Tue Jan 22 17:12:22 2019 +0100
+++ b/+scheme/Laplace1d.m	Tue Jan 22 17:37:07 2019 +0100
@@ -118,27 +118,10 @@
         % op        -- string
         % boundary  -- string
         function o = getBoundaryOperator(obj, op, boundary)
+            assertIsMember(op, {'e', 'd'})
             assertIsMember(boundary, {'l', 'r'})
 
-            switch op
-                case 'e'
-                    switch boundary
-                    case 'l'
-                        e = obj.e_l;
-                    case 'r'
-                        e = obj.e_r;
-                    end
-                    o = e;
-
-                case 'd'
-                    switch boundary
-                    case 'l'
-                        d = obj.d_l;
-                    case 'r'
-                        d = obj.d_r;
-                    end
-                    o = d;
-            end
+            o = obj.([op, '_', boundary])
         end
 
         % Returns the boundary sign. The right boundary is considered the positive boundary
diff -r dc1bcbef2a86 -r 19ed046aec52 +scheme/LaplaceCurvilinear.m
--- a/+scheme/LaplaceCurvilinear.m	Tue Jan 22 17:12:22 2019 +0100
+++ b/+scheme/LaplaceCurvilinear.m	Tue Jan 22 17:37:07 2019 +0100
@@ -401,35 +401,10 @@
         % op        -- string
         % boundary  -- string
         function o = getBoundaryOperator(obj, op, boundary)
+            assertIsMember(op, {'e', 'd'})
             assertIsMember(boundary, {'w', 'e', 's', 'n'})
 
-            switch op
-                case 'e'
-                    switch boundary
-                    case 'w'
-                        e = obj.e_w;
-                    case 'e'
-                        e = obj.e_e;
-                    case 's'
-                        e = obj.e_s;
-                    case 'n'
-                        e = obj.e_n;
-                    end
-                    o = e;
-
-                case 'd'
-                    switch boundary
-                    case 'w'
-                        d = obj.d_w;
-                    case 'e'
-                        d = obj.d_e;
-                    case 's'
-                        d = obj.d_s;
-                    case 'n'
-                        d = obj.d_n;
-                    end
-                    o = d;
-            end
+            o = obj.([op, '_', boundary]);
         end
 
         % Returns square boundary quadrature matrix, of dimension
@@ -439,16 +414,7 @@
         function H_b = getBoundaryQuadrature(obj, boundary)
             assertIsMember(boundary, {'w', 'e', 's', 'n'})
 
-            switch boundary
-                case 'w'
-                    H_b = obj.H_w;
-                case 'e'
-                    H_b = obj.H_e;
-                case 's'
-                    H_b = obj.H_s;
-                case 'n'
-                    H_b = obj.H_n;
-            end
+            H_b = obj.('H_', boundary);
         end
 
         % Returns the indices of the boundary points in the grid matrix