comparison +grid/CurvilinearTest.m @ 200:ef41fde95ac4 feature/beams

Merged feature/grids into feature/beams.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 13 Jun 2016 16:59:02 +0200
parents 7c1d3fc33f90
children
comparison
equal deleted inserted replaced
181:419ec303e97d 200:ef41fde95ac4
65 [1 2 3 4 5 6; 7 8 9 10 11 12]', 65 [1 2 3 4 5 6; 7 8 9 10 11 12]',
66 }; 66 };
67 end 67 end
68 68
69 function testMappingInputError(testCase) 69 function testMappingInputError(testCase)
70 testCase.assumeFail(); 70 testCase.verifyFail();
71 end 71 end
72 72
73 function testScaling(testCase) 73 function testScaling(testCase)
74 in = {{1:2, 1:3}, {[1 2 3 4 5 6]', [7 8 9 10 11 12]'}}; 74 in = {{1:2, 1:3}, {[1 2 3 4 5 6]', [7 8 9 10 11 12]'}};
75 g = grid.Curvilinear(in{2},in{1}{:}); 75 g = grid.Curvilinear(in{2},in{1}{:});
78 78
79 g.logicalGrid.h = [2 1]; 79 g.logicalGrid.h = [2 1];
80 testCase.verifyEqual(g.scaling(),[2 1]); 80 testCase.verifyEqual(g.scaling(),[2 1]);
81 end 81 end
82 82
83 function testGetBoundaryNames(testCase)
84 in = {
85 {{1:10}, @(x) exp(x)},
86 {{1:10,1:6}, @(x,y) [exp(x+y); exp(x-y)]},
87 {{1:10,1:5,1:7}, @(x,y,z)[exp(x+y+z); exp(x-y-z); 2+x+y-z]},
88 };
89
90 out = {
91 {'l', 'r'},
92 {'w', 'e', 's', 'n'},
93 {'w', 'e', 's', 'n', 'd', 'u'},
94 };
95
96 for i = 1:length(in)
97 g = grid.Curvilinear(in{i}{2},in{i}{1}{:});
98 testCase.verifyEqual(g.getBoundaryNames(), out{i});
99 end
100 end
101
102 function testGetBoundary(testCase)
103 grids = {
104 {{1:10}, @(x) exp(x)},
105 {{1:10,1:6}, @(x,y) [exp(x+y); exp(x-y)]},
106 {{1:10,1:5,1:7}, @(x,y,z)[exp(x+y+z); exp(x-y-z); 2+x+y-z]},
107 };
108
109 boundaries = {
110 {'l', 'r'},
111 {'w', 'e', 's', 'n'},
112 {'w', 'e', 's', 'n', 'd', 'u'},
113 };
114
115
116 for ig = 1:length(grids)
117 g = grid.Curvilinear(grids{ig}{2},grids{ig}{1}{:});
118
119 logicalGrid = grid.Cartesian(grids{ig}{1}{:});
120
121 for ib = 1:length(boundaries{ig})
122
123 logicalBoundary = logicalGrid.getBoundary(boundaries{ig}{ib});
124
125 x = num2cell(logicalBoundary',2);
126 expectedBoundary = grids{ig}{2}(x{:})';
127 testCase.verifyEqual(g.getBoundary(boundaries{ig}{ib}), expectedBoundary);
128 end
129 end
130 end
131