Mercurial > repos > public > sbplib
diff +scheme/Wave2d.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 | 5afc774fb7c4 |
line wrap: on
line diff
--- a/+scheme/Wave2d.m Wed Jan 16 11:31:04 2019 -0800 +++ b/+scheme/Wave2d.m Tue Jan 22 16:47:34 2019 +0100 @@ -200,6 +200,7 @@ % op -- string or a cell array of strings % boundary -- string function varargout = getBoundaryOperator(obj, op, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) if ~iscell(op) op = {op}; @@ -217,8 +218,6 @@ e = obj.e_s; case 'n' e = obj.e_n; - otherwise - error('No such boundary: boundary = %s',boundary); end varargout{i} = e; @@ -232,8 +231,6 @@ d = obj.d1_s; case 'n' d = obj.d1_n; - otherwise - error('No such boundary: boundary = %s',boundary); end varargout{i} = d; end @@ -246,6 +243,7 @@ % % boundary -- string function H_b = getBoundaryQuadrature(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) switch boundary case 'w' @@ -256,39 +254,39 @@ H_b = obj.H_x; case 'n' H_b = obj.H_x; - otherwise - error('No such boundary: boundary = %s',boundary); end end % Returns borrowing constant gamma % boundary -- string function gamm = getBoundaryBorrowing(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) + switch boundary case {'w','e'} gamm = obj.gamm_x; case {'s','n'} gamm = obj.gamm_y; - otherwise - error('No such boundary: boundary = %s',boundary); end end % Returns the boundary sign. The right boundary is considered the positive boundary % boundary -- string function s = getBoundarySign(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) + switch boundary case {'e','n'} s = 1; case {'w','s'} s = -1; - otherwise - error('No such boundary: boundary = %s',boundary); end end % Returns the halfnorm_inv used in SATs. TODO: better notation function Hinv = getHalfnormInv(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) + switch boundary case 'w' Hinv = obj.Hix; @@ -298,8 +296,6 @@ Hinv = obj.Hiy; case 'n' Hinv = obj.Hiy; - otherwise - error('No such boundary: boundary = %s',boundary); end end