Mercurial > repos > public > sbplib
comparison +scheme/Laplace1d.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 | 2b1b944deae1 |
children | 5afc774fb7c4 |
comparison
equal
deleted
inserted
replaced
1007:9c8ed00732fd | 1042:8d73fcdb07a5 |
---|---|
115 | 115 |
116 % Returns the boundary operator op for the boundary specified by the string boundary. | 116 % Returns the boundary operator op for the boundary specified by the string boundary. |
117 % op -- string or a cell array of strings | 117 % op -- string or a cell array of strings |
118 % boundary -- string | 118 % boundary -- string |
119 function varargout = getBoundaryOperator(obj, op, boundary) | 119 function varargout = getBoundaryOperator(obj, op, boundary) |
120 assertIsMember(boundary, {'l', 'r'}) | |
120 | 121 |
121 if ~iscell(op) | 122 if ~iscell(op) |
122 op = {op}; | 123 op = {op}; |
123 end | 124 end |
124 | 125 |
128 switch boundary | 129 switch boundary |
129 case 'l' | 130 case 'l' |
130 e = obj.e_l; | 131 e = obj.e_l; |
131 case 'r' | 132 case 'r' |
132 e = obj.e_r; | 133 e = obj.e_r; |
133 otherwise | |
134 error('No such boundary: boundary = %s',boundary); | |
135 end | 134 end |
136 varargout{i} = e; | 135 varargout{i} = e; |
137 | 136 |
138 case 'd' | 137 case 'd' |
139 switch boundary | 138 switch boundary |
140 case 'l' | 139 case 'l' |
141 d = obj.d_l; | 140 d = obj.d_l; |
142 case 'r' | 141 case 'r' |
143 d = obj.d_r; | 142 d = obj.d_r; |
144 otherwise | |
145 error('No such boundary: boundary = %s',boundary); | |
146 end | 143 end |
147 varargout{i} = d; | 144 varargout{i} = d; |
148 end | 145 end |
149 end | 146 end |
150 end | 147 end |
151 | 148 |
152 % Returns the boundary sign. The right boundary is considered the positive boundary | 149 % Returns the boundary sign. The right boundary is considered the positive boundary |
153 % boundary -- string | 150 % boundary -- string |
154 function s = getBoundarySign(obj, boundary) | 151 function s = getBoundarySign(obj, boundary) |
152 assertIsMember(boundary, {'l', 'r'}) | |
153 | |
155 switch boundary | 154 switch boundary |
156 case {'r'} | 155 case {'r'} |
157 s = 1; | 156 s = 1; |
158 case {'l'} | 157 case {'l'} |
159 s = -1; | 158 s = -1; |
160 otherwise | |
161 error('No such boundary: boundary = %s',boundary); | |
162 end | 159 end |
163 end | 160 end |
164 | 161 |
165 function N = size(obj) | 162 function N = size(obj) |
166 N = obj.grid.size(); | 163 N = obj.grid.size(); |