comparison +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
comparison
equal deleted inserted replaced
1007:9c8ed00732fd 1042:8d73fcdb07a5
198 198
199 % Returns the boundary operator op for the boundary specified by the string boundary. 199 % Returns the boundary operator op for the boundary specified by the string boundary.
200 % op -- string or a cell array of strings 200 % op -- string or a cell array of strings
201 % boundary -- string 201 % boundary -- string
202 function varargout = getBoundaryOperator(obj, op, boundary) 202 function varargout = getBoundaryOperator(obj, op, boundary)
203 assertIsMember(boundary, {'w', 'e', 's', 'n'})
203 204
204 if ~iscell(op) 205 if ~iscell(op)
205 op = {op}; 206 op = {op};
206 end 207 end
207 208
215 e = obj.e_e; 216 e = obj.e_e;
216 case 's' 217 case 's'
217 e = obj.e_s; 218 e = obj.e_s;
218 case 'n' 219 case 'n'
219 e = obj.e_n; 220 e = obj.e_n;
220 otherwise
221 error('No such boundary: boundary = %s',boundary);
222 end 221 end
223 varargout{i} = e; 222 varargout{i} = e;
224 223
225 case 'd' 224 case 'd'
226 switch boundary 225 switch boundary
230 d = obj.d1_e; 229 d = obj.d1_e;
231 case 's' 230 case 's'
232 d = obj.d1_s; 231 d = obj.d1_s;
233 case 'n' 232 case 'n'
234 d = obj.d1_n; 233 d = obj.d1_n;
235 otherwise
236 error('No such boundary: boundary = %s',boundary);
237 end 234 end
238 varargout{i} = d; 235 varargout{i} = d;
239 end 236 end
240 end 237 end
241 238
244 % Returns square boundary quadrature matrix, of dimension 241 % Returns square boundary quadrature matrix, of dimension
245 % corresponding to the number of boundary points 242 % corresponding to the number of boundary points
246 % 243 %
247 % boundary -- string 244 % boundary -- string
248 function H_b = getBoundaryQuadrature(obj, boundary) 245 function H_b = getBoundaryQuadrature(obj, boundary)
246 assertIsMember(boundary, {'w', 'e', 's', 'n'})
249 247
250 switch boundary 248 switch boundary
251 case 'w' 249 case 'w'
252 H_b = obj.H_y; 250 H_b = obj.H_y;
253 case 'e' 251 case 'e'
254 H_b = obj.H_y; 252 H_b = obj.H_y;
255 case 's' 253 case 's'
256 H_b = obj.H_x; 254 H_b = obj.H_x;
257 case 'n' 255 case 'n'
258 H_b = obj.H_x; 256 H_b = obj.H_x;
259 otherwise
260 error('No such boundary: boundary = %s',boundary);
261 end 257 end
262 end 258 end
263 259
264 % Returns borrowing constant gamma 260 % Returns borrowing constant gamma
265 % boundary -- string 261 % boundary -- string
266 function gamm = getBoundaryBorrowing(obj, boundary) 262 function gamm = getBoundaryBorrowing(obj, boundary)
263 assertIsMember(boundary, {'w', 'e', 's', 'n'})
264
267 switch boundary 265 switch boundary
268 case {'w','e'} 266 case {'w','e'}
269 gamm = obj.gamm_x; 267 gamm = obj.gamm_x;
270 case {'s','n'} 268 case {'s','n'}
271 gamm = obj.gamm_y; 269 gamm = obj.gamm_y;
272 otherwise
273 error('No such boundary: boundary = %s',boundary);
274 end 270 end
275 end 271 end
276 272
277 % Returns the boundary sign. The right boundary is considered the positive boundary 273 % Returns the boundary sign. The right boundary is considered the positive boundary
278 % boundary -- string 274 % boundary -- string
279 function s = getBoundarySign(obj, boundary) 275 function s = getBoundarySign(obj, boundary)
276 assertIsMember(boundary, {'w', 'e', 's', 'n'})
277
280 switch boundary 278 switch boundary
281 case {'e','n'} 279 case {'e','n'}
282 s = 1; 280 s = 1;
283 case {'w','s'} 281 case {'w','s'}
284 s = -1; 282 s = -1;
285 otherwise
286 error('No such boundary: boundary = %s',boundary);
287 end 283 end
288 end 284 end
289 285
290 % Returns the halfnorm_inv used in SATs. TODO: better notation 286 % Returns the halfnorm_inv used in SATs. TODO: better notation
291 function Hinv = getHalfnormInv(obj, boundary) 287 function Hinv = getHalfnormInv(obj, boundary)
288 assertIsMember(boundary, {'w', 'e', 's', 'n'})
289
292 switch boundary 290 switch boundary
293 case 'w' 291 case 'w'
294 Hinv = obj.Hix; 292 Hinv = obj.Hix;
295 case 'e' 293 case 'e'
296 Hinv = obj.Hix; 294 Hinv = obj.Hix;
297 case 's' 295 case 's'
298 Hinv = obj.Hiy; 296 Hinv = obj.Hiy;
299 case 'n' 297 case 'n'
300 Hinv = obj.Hiy; 298 Hinv = obj.Hiy;
301 otherwise
302 error('No such boundary: boundary = %s',boundary);
303 end 299 end
304 end 300 end
305 301
306 function N = size(obj) 302 function N = size(obj)
307 N = prod(obj.m); 303 N = prod(obj.m);