Mercurial > repos > public > sbplib
diff +scheme/Heat2dVariable.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 |
line wrap: on
line diff
--- a/+scheme/Heat2dVariable.m Wed Jan 16 11:31:04 2019 -0800 +++ b/+scheme/Heat2dVariable.m Tue Jan 22 16:47:34 2019 +0100 @@ -212,6 +212,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}; @@ -229,8 +230,6 @@ e = obj.e_l{2}; case 'n' e = obj.e_r{2}; - otherwise - error('No such boundary: boundary = %s',boundary); end varargout{i} = e; @@ -244,8 +243,6 @@ d = obj.d1_l{2}; case 'n' d = obj.d1_r{2}; - otherwise - error('No such boundary: boundary = %s',boundary); end varargout{i} = d; end @@ -257,6 +254,7 @@ % % boundary -- string function H_b = getBoundaryQuadrature(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) switch boundary case 'w' @@ -267,34 +265,32 @@ H_b = obj.H_boundary{2}; case 'n' H_b = obj.H_boundary{2}; - 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 borrowing constant gamma*h % boundary -- string function gamm = getBoundaryBorrowing(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) + switch boundary case {'w','e'} gamm = obj.h(1)*obj.alpha(1); case {'s','n'} gamm = obj.h(2)*obj.alpha(2); - otherwise - error('No such boundary: boundary = %s',boundary); end end