Mercurial > repos > public > sbplib
comparison +grid/CurvilinearTest.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 |
comparison
equal
deleted
inserted
replaced
190:2c2ba1f3bbe3 | 191:7c1d3fc33f90 |
---|---|
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) | 83 function testGetBoundaryNames(testCase) |
84 testCase.verifyFail(); | 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 | |
85 end | 100 end |
86 | 101 |
87 function testGetBoundary(testCase) | 102 function testGetBoundary(testCase) |
88 testCase.verifyFail(); | 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 | |
89 end | 130 end |
90 | 131 |