Mercurial > repos > public > sbplib
comparison +scheme/Schrodinger2d.m @ 1042:8d73fcdb07a5 feature/getBoundaryOp
Add asserts to boundary identifier inputs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Jan 2019 16:47:34 +0100 |
parents | 78db023a7fe3 |
children |
comparison
equal
deleted
inserted
replaced
1007:9c8ed00732fd | 1042:8d73fcdb07a5 |
---|---|
288 | 288 |
289 % Returns the boundary operator op for the boundary specified by the string boundary. | 289 % Returns the boundary operator op for the boundary specified by the string boundary. |
290 % op -- string or a cell array of strings | 290 % op -- string or a cell array of strings |
291 % boundary -- string | 291 % boundary -- string |
292 function varargout = getBoundaryOperator(obj, op, boundary) | 292 function varargout = getBoundaryOperator(obj, op, boundary) |
293 assertIsMember(boundary, {'w', 'e', 's', 'n'}) | |
293 | 294 |
294 if ~iscell(op) | 295 if ~iscell(op) |
295 op = {op}; | 296 op = {op}; |
296 end | 297 end |
297 | 298 |
305 e = obj.e_e; | 306 e = obj.e_e; |
306 case 's' | 307 case 's' |
307 e = obj.e_s; | 308 e = obj.e_s; |
308 case 'n' | 309 case 'n' |
309 e = obj.e_n; | 310 e = obj.e_n; |
310 otherwise | |
311 error('No such boundary: boundary = %s',boundary); | |
312 end | 311 end |
313 varargout{i} = e; | 312 varargout{i} = e; |
314 | 313 |
315 case 'd' | 314 case 'd' |
316 switch boundary | 315 switch boundary |
320 d = obj.d_e; | 319 d = obj.d_e; |
321 case 's' | 320 case 's' |
322 d = obj.d_s; | 321 d = obj.d_s; |
323 case 'n' | 322 case 'n' |
324 d = obj.d_n; | 323 d = obj.d_n; |
325 otherwise | |
326 error('No such boundary: boundary = %s',boundary); | |
327 end | 324 end |
328 varargout{i} = d; | 325 varargout{i} = d; |
329 end | 326 end |
330 end | 327 end |
331 end | 328 end |
333 % Returns square boundary quadrature matrix, of dimension | 330 % Returns square boundary quadrature matrix, of dimension |
334 % corresponding to the number of boundary points | 331 % corresponding to the number of boundary points |
335 % | 332 % |
336 % boundary -- string | 333 % boundary -- string |
337 function H_b = getBoundaryQuadrature(obj, boundary) | 334 function H_b = getBoundaryQuadrature(obj, boundary) |
335 assertIsMember(boundary, {'w', 'e', 's', 'n'}) | |
338 | 336 |
339 switch boundary | 337 switch boundary |
340 case 'w' | 338 case 'w' |
341 H_b = obj.H_boundary{1}; | 339 H_b = obj.H_boundary{1}; |
342 case 'e' | 340 case 'e' |
343 H_b = obj.H_boundary{1}; | 341 H_b = obj.H_boundary{1}; |
344 case 's' | 342 case 's' |
345 H_b = obj.H_boundary{2}; | 343 H_b = obj.H_boundary{2}; |
346 case 'n' | 344 case 'n' |
347 H_b = obj.H_boundary{2}; | 345 H_b = obj.H_boundary{2}; |
348 otherwise | |
349 error('No such boundary: boundary = %s',boundary); | |
350 end | 346 end |
351 end | 347 end |
352 | 348 |
353 % Returns the boundary sign. The right boundary is considered the positive boundary | 349 % Returns the boundary sign. The right boundary is considered the positive boundary |
354 % boundary -- string | 350 % boundary -- string |
355 function s = getBoundarySign(obj, boundary) | 351 function s = getBoundarySign(obj, boundary) |
352 assertIsMember(boundary, {'w', 'e', 's', 'n'}) | |
353 | |
356 switch boundary | 354 switch boundary |
357 case {'e','n'} | 355 case {'e','n'} |
358 s = 1; | 356 s = 1; |
359 case {'w','s'} | 357 case {'w','s'} |
360 s = -1; | 358 s = -1; |
361 otherwise | |
362 error('No such boundary: boundary = %s',boundary); | |
363 end | 359 end |
364 end | 360 end |
365 | 361 |
366 function N = size(obj) | 362 function N = size(obj) |
367 N = prod(obj.m); | 363 N = prod(obj.m); |