Mercurial > repos > public > sbplib
comparison +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 |
comparison
equal
deleted
inserted
replaced
190:2c2ba1f3bbe3 | 191:7c1d3fc33f90 |
---|---|
195 | 195 |
196 end | 196 end |
197 | 197 |
198 | 198 |
199 function testGetBoundaryNames(testCase) | 199 function testGetBoundaryNames(testCase) |
200 testCase.verifyFail(); | 200 in = { |
201 {[1 2 3]}, | |
202 {[1 2 3], [4 5]}, | |
203 {[1 2 3], [4 5], [6 7 8]}, | |
204 }; | |
205 | |
206 out = { | |
207 {'l', 'r'}, | |
208 {'w', 'e', 's', 'n'}, | |
209 {'w', 'e', 's', 'n', 'd', 'u'}, | |
210 }; | |
211 | |
212 for i = 1:length(in) | |
213 g = grid.Cartesian(in{i}{:}); | |
214 testCase.verifyEqual(g.getBoundaryNames(), out{i}); | |
215 end | |
201 end | 216 end |
202 | 217 |
203 function testGetBoundary(testCase) | 218 function testGetBoundary(testCase) |
204 testCase.verifyFail(); | 219 grids = { |
205 end | 220 {[1 2 3]}, |
221 {[1 2 3], [4 5]}, | |
222 {[1 2 3], [4 5], [6 7 8]}, | |
223 }; | |
224 | |
225 boundaries = { | |
226 {'l', 'r'}, | |
227 {'w', 'e', 's', 'n'}, | |
228 {'w', 'e', 's', 'n', 'd', 'u'}, | |
229 }; | |
230 | |
231 | |
232 % 1d | |
233 out{1,1} = 1; | |
234 out{1,2} = 3; | |
235 | |
236 % 2d | |
237 out{2,1} = [ | |
238 1,4; | |
239 1,5; | |
240 ]; | |
241 out{2,2} = [ | |
242 3,4; | |
243 3,5; | |
244 ]; | |
245 out{2,3} = [ | |
246 1,4; | |
247 2,4; | |
248 3,4; | |
249 ]; | |
250 out{2,4} = [ | |
251 1,5; | |
252 2,5; | |
253 3,5; | |
254 ]; | |
255 | |
256 % 3d | |
257 out{3,1} = [ | |
258 1,4,6; | |
259 1,4,7; | |
260 1,4,8; | |
261 1,5,6; | |
262 1,5,7; | |
263 1,5,8; | |
264 ]; | |
265 out{3,2} = [ | |
266 3,4,6; | |
267 3,4,7; | |
268 3,4,8; | |
269 3,5,6; | |
270 3,5,7; | |
271 3,5,8; | |
272 ]; | |
273 out{3,3} = [ | |
274 1,4,6; | |
275 1,4,7; | |
276 1,4,8; | |
277 2,4,6; | |
278 2,4,7; | |
279 2,4,8; | |
280 3,4,6; | |
281 3,4,7; | |
282 3,4,8; | |
283 ]; | |
284 out{3,4} = [ | |
285 1,5,6; | |
286 1,5,7; | |
287 1,5,8; | |
288 2,5,6; | |
289 2,5,7; | |
290 2,5,8; | |
291 3,5,6; | |
292 3,5,7; | |
293 3,5,8; | |
294 ]; | |
295 out{3,5} = [ | |
296 1,4,6; | |
297 1,5,6; | |
298 2,4,6; | |
299 2,5,6; | |
300 3,4,6; | |
301 3,5,6; | |
302 ]; | |
303 out{3,6} = [ | |
304 1,4,8; | |
305 1,5,8; | |
306 2,4,8; | |
307 2,5,8; | |
308 3,4,8; | |
309 3,5,8; | |
310 ]; | |
311 | |
312 for ig = 1:length(grids) | |
313 g = grid.Cartesian(grids{ig}{:}); | |
314 for ib = 1:length(boundaries{ig}) | |
315 testCase.verifyEqual(g.getBoundary(boundaries{ig}{ib}), out{ig,ib}); | |
316 end | |
317 end | |
318 end |