diff +grid/CartesianTest.m @ 191:7c1d3fc33f90 feature/grids

Added methods for returning boundary names and boundary coordinates from Cartesian and Curvilinear grids.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 04 Apr 2016 18:23:50 +0200
parents c5ca9bbfed41
children
line wrap: on
line diff
--- a/+grid/CartesianTest.m	Mon Mar 21 16:33:49 2016 +0100
+++ b/+grid/CartesianTest.m	Mon Apr 04 18:23:50 2016 +0200
@@ -197,9 +197,122 @@
 
 
 function testGetBoundaryNames(testCase)
-    testCase.verifyFail();
+    in = {
+        {[1 2 3]},
+        {[1 2 3], [4 5]},
+        {[1 2 3], [4 5], [6 7 8]},
+    };
+
+    out = {
+        {'l', 'r'},
+        {'w', 'e', 's', 'n'},
+        {'w', 'e', 's', 'n', 'd', 'u'},
+    };
+
+    for i = 1:length(in)
+        g = grid.Cartesian(in{i}{:});
+        testCase.verifyEqual(g.getBoundaryNames(), out{i});
+    end
 end
 
 function testGetBoundary(testCase)
-    testCase.verifyFail();
+    grids = {
+        {[1 2 3]},
+        {[1 2 3], [4 5]},
+        {[1 2 3], [4 5], [6 7 8]},
+    };
+
+    boundaries = {
+        {'l', 'r'},
+        {'w', 'e', 's', 'n'},
+        {'w', 'e', 's', 'n', 'd', 'u'},
+    };
+
+
+    % 1d
+    out{1,1} = 1;
+    out{1,2} = 3;
+
+    % 2d
+    out{2,1} = [
+        1,4;
+        1,5;
+    ];
+    out{2,2} = [
+        3,4;
+        3,5;
+    ];
+    out{2,3} = [
+        1,4;
+        2,4;
+        3,4;
+    ];
+    out{2,4} = [
+        1,5;
+        2,5;
+        3,5;
+    ];
+
+    % 3d
+    out{3,1} = [
+        1,4,6;
+        1,4,7;
+        1,4,8;
+        1,5,6;
+        1,5,7;
+        1,5,8;
+    ];
+    out{3,2} = [
+        3,4,6;
+        3,4,7;
+        3,4,8;
+        3,5,6;
+        3,5,7;
+        3,5,8;
+    ];
+    out{3,3} = [
+        1,4,6;
+        1,4,7;
+        1,4,8;
+        2,4,6;
+        2,4,7;
+        2,4,8;
+        3,4,6;
+        3,4,7;
+        3,4,8;
+    ];
+    out{3,4} = [
+        1,5,6;
+        1,5,7;
+        1,5,8;
+        2,5,6;
+        2,5,7;
+        2,5,8;
+        3,5,6;
+        3,5,7;
+        3,5,8;
+    ];
+    out{3,5} = [
+        1,4,6;
+        1,5,6;
+        2,4,6;
+        2,5,6;
+        3,4,6;
+        3,5,6;
+    ];
+    out{3,6} = [
+        1,4,8;
+        1,5,8;
+        2,4,8;
+        2,5,8;
+        3,4,8;
+        3,5,8;
+    ];
+
+    for ig = 1:length(grids)
+        g = grid.Cartesian(grids{ig}{:});
+        for ib = 1:length(boundaries{ig})
+            testCase.verifyEqual(g.getBoundary(boundaries{ig}{ib}), out{ig,ib});
+        end
+    end
 end