Mercurial > repos > public > sbplib
comparison +scheme/LaplaceCurvilinear.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 | dc1bcbef2a86 |
comparison
equal
deleted
inserted
replaced
1007:9c8ed00732fd | 1042:8d73fcdb07a5 |
---|---|
397 | 397 |
398 % Returns the boundary operator op for the boundary specified by the string boundary. | 398 % Returns the boundary operator op for the boundary specified by the string boundary. |
399 % op -- string or a cell array of strings | 399 % op -- string or a cell array of strings |
400 % boundary -- string | 400 % boundary -- string |
401 function varargout = getBoundaryOperator(obj, op, boundary) | 401 function varargout = getBoundaryOperator(obj, op, boundary) |
402 assertIsMember(boundary, {'w', 'e', 's', 'n'}) | |
402 | 403 |
403 if ~iscell(op) | 404 if ~iscell(op) |
404 op = {op}; | 405 op = {op}; |
405 end | 406 end |
406 | 407 |
414 e = obj.e_e; | 415 e = obj.e_e; |
415 case 's' | 416 case 's' |
416 e = obj.e_s; | 417 e = obj.e_s; |
417 case 'n' | 418 case 'n' |
418 e = obj.e_n; | 419 e = obj.e_n; |
419 otherwise | |
420 error('No such boundary: boundary = %s',boundary); | |
421 end | 420 end |
422 varargout{i} = e; | 421 varargout{i} = e; |
423 | 422 |
424 case 'd' | 423 case 'd' |
425 switch boundary | 424 switch boundary |
429 d = obj.d_e; | 428 d = obj.d_e; |
430 case 's' | 429 case 's' |
431 d = obj.d_s; | 430 d = obj.d_s; |
432 case 'n' | 431 case 'n' |
433 d = obj.d_n; | 432 d = obj.d_n; |
434 otherwise | |
435 error('No such boundary: boundary = %s',boundary); | |
436 end | 433 end |
437 varargout{i} = d; | 434 varargout{i} = d; |
438 end | 435 end |
439 end | 436 end |
440 end | 437 end |
442 % Returns square boundary quadrature matrix, of dimension | 439 % Returns square boundary quadrature matrix, of dimension |
443 % corresponding to the number of boundary points | 440 % corresponding to the number of boundary points |
444 % | 441 % |
445 % boundary -- string | 442 % boundary -- string |
446 function H_b = getBoundaryQuadrature(obj, boundary) | 443 function H_b = getBoundaryQuadrature(obj, boundary) |
444 assertIsMember(boundary, {'w', 'e', 's', 'n'}) | |
447 | 445 |
448 switch boundary | 446 switch boundary |
449 case 'w' | 447 case 'w' |
450 H_b = obj.H_w; | 448 H_b = obj.H_w; |
451 case 'e' | 449 case 'e' |
452 H_b = obj.H_e; | 450 H_b = obj.H_e; |
453 case 's' | 451 case 's' |
454 H_b = obj.H_s; | 452 H_b = obj.H_s; |
455 case 'n' | 453 case 'n' |
456 H_b = obj.H_n; | 454 H_b = obj.H_n; |
457 otherwise | |
458 error('No such boundary: boundary = %s',boundary); | |
459 end | 455 end |
460 end | 456 end |
461 | 457 |
462 % Returns the indices of the boundary points in the grid matrix | 458 % Returns the indices of the boundary points in the grid matrix |
463 % boundary -- string | 459 % boundary -- string |
464 function I = getBoundaryIndices(obj, boundary) | 460 function I = getBoundaryIndices(obj, boundary) |
461 assertIsMember(boundary, {'w', 'e', 's', 'n'}) | |
462 | |
465 ind = grid.funcToMatrix(obj.grid, 1:prod(obj.m)); | 463 ind = grid.funcToMatrix(obj.grid, 1:prod(obj.m)); |
466 switch boundary | 464 switch boundary |
467 case 'w' | 465 case 'w' |
468 I = ind(1,:); | 466 I = ind(1,:); |
469 case 'e' | 467 case 'e' |
470 I = ind(end,:); | 468 I = ind(end,:); |
471 case 's' | 469 case 's' |
472 I = ind(:,1)'; | 470 I = ind(:,1)'; |
473 case 'n' | 471 case 'n' |
474 I = ind(:,end)'; | 472 I = ind(:,end)'; |
475 otherwise | |
476 error('No such boundary: boundary = %s',boundary); | |
477 end | 473 end |
478 end | 474 end |
479 | 475 |
480 % Returns borrowing constant gamma | 476 % Returns borrowing constant gamma |
481 % boundary -- string | 477 % boundary -- string |
482 function gamm = getBoundaryBorrowing(obj, boundary) | 478 function gamm = getBoundaryBorrowing(obj, boundary) |
479 assertIsMember(boundary, {'w', 'e', 's', 'n'}) | |
480 | |
483 switch boundary | 481 switch boundary |
484 case {'w','e'} | 482 case {'w','e'} |
485 gamm = obj.gamm_u; | 483 gamm = obj.gamm_u; |
486 case {'s','n'} | 484 case {'s','n'} |
487 gamm = obj.gamm_v; | 485 gamm = obj.gamm_v; |
488 otherwise | |
489 error('No such boundary: boundary = %s',boundary); | |
490 end | 486 end |
491 end | 487 end |
492 | 488 |
493 function N = size(obj) | 489 function N = size(obj) |
494 N = prod(obj.m); | 490 N = prod(obj.m); |