comparison +scheme/Heat2dCurvilinear.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
comparison
equal deleted inserted replaced
1007:9c8ed00732fd 1042:8d73fcdb07a5
319 319
320 % Returns the boundary operator op for the boundary specified by the string boundary. 320 % Returns the boundary operator op for the boundary specified by the string boundary.
321 % op -- string or a cell array of strings 321 % op -- string or a cell array of strings
322 % boundary -- string 322 % boundary -- string
323 function varargout = getBoundaryOperator(obj, op, boundary) 323 function varargout = getBoundaryOperator(obj, op, boundary)
324 assertIsMember(boundary, {'w', 'e', 's', 'n'})
324 325
325 if ~iscell(op) 326 if ~iscell(op)
326 op = {op}; 327 op = {op};
327 end 328 end
328 329
336 e = obj.e_r{1}; 337 e = obj.e_r{1};
337 case 's' 338 case 's'
338 e = obj.e_l{2}; 339 e = obj.e_l{2};
339 case 'n' 340 case 'n'
340 e = obj.e_r{2}; 341 e = obj.e_r{2};
341 otherwise
342 error('No such boundary: boundary = %s',boundary);
343 end 342 end
344 varargout{i} = e; 343 varargout{i} = e;
345 344
346 case 'd' 345 case 'd'
347 switch boundary 346 switch boundary
351 d = obj.d1_r{1}; 350 d = obj.d1_r{1};
352 case 's' 351 case 's'
353 d = obj.d1_l{2}; 352 d = obj.d1_l{2};
354 case 'n' 353 case 'n'
355 d = obj.d1_r{2}; 354 d = obj.d1_r{2};
356 otherwise
357 error('No such boundary: boundary = %s',boundary);
358 end 355 end
359 varargout{i} = d; 356 varargout{i} = d;
360 357
361 case 'flux' 358 case 'flux'
362 switch boundary 359 switch boundary
366 flux = obj.flux_r{1}; 363 flux = obj.flux_r{1};
367 case 's' 364 case 's'
368 flux = obj.flux_l{2}; 365 flux = obj.flux_l{2};
369 case 'n' 366 case 'n'
370 flux = obj.flux_r{2}; 367 flux = obj.flux_r{2};
371 otherwise
372 error('No such boundary: boundary = %s',boundary);
373 end 368 end
374 varargout{i} = flux; 369 varargout{i} = flux;
375 end 370 end
376 end 371 end
377 end 372 end
379 % Returns square boundary quadrature matrix, of dimension 374 % Returns square boundary quadrature matrix, of dimension
380 % corresponding to the number of boundary points 375 % corresponding to the number of boundary points
381 % 376 %
382 % boundary -- string 377 % boundary -- string
383 function H_b = getBoundaryQuadrature(obj, boundary) 378 function H_b = getBoundaryQuadrature(obj, boundary)
379 assertIsMember(boundary, {'w', 'e', 's', 'n'})
384 380
385 switch boundary 381 switch boundary
386 case 'w' 382 case 'w'
387 H_b = obj.H_boundary_l{1}; 383 H_b = obj.H_boundary_l{1};
388 case 'e' 384 case 'e'
389 H_b = obj.H_boundary_r{1}; 385 H_b = obj.H_boundary_r{1};
390 case 's' 386 case 's'
391 H_b = obj.H_boundary_l{2}; 387 H_b = obj.H_boundary_l{2};
392 case 'n' 388 case 'n'
393 H_b = obj.H_boundary_r{2}; 389 H_b = obj.H_boundary_r{2};
394 otherwise
395 error('No such boundary: boundary = %s',boundary);
396 end 390 end
397 end 391 end
398 392
399 % Returns the boundary sign. The right boundary is considered the positive boundary 393 % Returns the boundary sign. The right boundary is considered the positive boundary
400 % boundary -- string 394 % boundary -- string
401 function s = getBoundarySign(obj, boundary) 395 function s = getBoundarySign(obj, boundary)
396 assertIsMember(boundary, {'w', 'e', 's', 'n'})
397
402 switch boundary 398 switch boundary
403 case {'e','n'} 399 case {'e','n'}
404 s = 1; 400 s = 1;
405 case {'w','s'} 401 case {'w','s'}
406 s = -1; 402 s = -1;
407 otherwise
408 error('No such boundary: boundary = %s',boundary);
409 end 403 end
410 end 404 end
411 405
412 % Returns borrowing constant gamma*h 406 % Returns borrowing constant gamma*h
413 % boundary -- string 407 % boundary -- string
414 function gamm = getBoundaryBorrowing(obj, boundary) 408 function gamm = getBoundaryBorrowing(obj, boundary)
409 assertIsMember(boundary, {'w', 'e', 's', 'n'})
410
415 switch boundary 411 switch boundary
416 case {'w','e'} 412 case {'w','e'}
417 gamm = obj.h(1)*obj.alpha(1); 413 gamm = obj.h(1)*obj.alpha(1);
418 case {'s','n'} 414 case {'s','n'}
419 gamm = obj.h(2)*obj.alpha(2); 415 gamm = obj.h(2)*obj.alpha(2);
420 otherwise
421 error('No such boundary: boundary = %s',boundary);
422 end 416 end
423 end 417 end
424 418
425 function N = size(obj) 419 function N = size(obj)
426 N = prod(obj.m); 420 N = prod(obj.m);