comparison +scheme/Elastic2dVariable.m @ 1056:b4fa176b4287 feature/poroelastic

Elastic2dVariable: boundary condition type can now be a string, normal or tangential, as well as component number.
author Martin Almquist <malmquist@stanford.edu>
date Fri, 25 Jan 2019 15:15:44 -0800
parents 1c334842bf23
children ff274c7404cc
comparison
equal deleted inserted replaced
1055:b828e589d540 1056:b4fa176b4287
342 342
343 % Closure functions return the operators applied to the own domain to close the boundary 343 % Closure functions return the operators applied to the own domain to close the boundary
344 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other doamin. 344 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other doamin.
345 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. 345 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
346 % bc is a cell array of component and bc type, e.g. {1, 'd'} for Dirichlet condition 346 % bc is a cell array of component and bc type, e.g. {1, 'd'} for Dirichlet condition
347 % on the first component. 347 % on the first component. Can also be e.g.
348 % {'normal', 'd'} or {'tangential', 't'} for conditions on
349 % tangential/normal component.
348 % data is a function returning the data that should be applied at the boundary. 350 % data is a function returning the data that should be applied at the boundary.
349 % neighbour_scheme is an instance of Scheme that should be interfaced to. 351 % neighbour_scheme is an instance of Scheme that should be interfaced to.
350 % neighbour_boundary is a string specifying which boundary to interface to. 352 % neighbour_boundary is a string specifying which boundary to interface to.
351 function [closure, penalty] = boundary_condition(obj, boundary, bc, tuning) 353 function [closure, penalty] = boundary_condition(obj, boundary, bc, tuning)
352 default_arg('tuning', 1.2); 354 default_arg('tuning', 1.2);
353 355
354 assert( iscell(bc), 'The BC type must be a 2x1 cell array' ); 356 assert( iscell(bc), 'The BC type must be a 2x1 cell array' );
355 comp = bc{1}; 357 comp = bc{1};
356 type = bc{2}; 358 type = bc{2};
359 if ischar(comp)
360 comp = obj.getComponent(comp, boundary);
361 end
357 362
358 % j is the coordinate direction of the boundary 363 % j is the coordinate direction of the boundary
359 j = obj.get_boundary_number(boundary); 364 j = obj.get_boundary_number(boundary);
360 [e, T, tau, H_gamma] = obj.getBoundaryOperator({'e','T','tau','H'}, boundary); 365 [e, T, tau, H_gamma] = obj.getBoundaryOperator({'e','T','tau','H'}, boundary);
361
362 366
363 E = obj.E; 367 E = obj.E;
364 Hi = obj.Hi; 368 Hi = obj.Hi;
365 LAMBDA = obj.LAMBDA; 369 LAMBDA = obj.LAMBDA;
366 MU = obj.MU; 370 MU = obj.MU;
471 switch boundary 475 switch boundary
472 case {'w','W','west','West','s','S','south','South'} 476 case {'w','W','west','West','s','S','south','South'}
473 nj = -1; 477 nj = -1;
474 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'} 478 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'}
475 nj = 1; 479 nj = 1;
480 end
481 end
482
483 % Returns the component number that is the tangential/normal component
484 % at the specified boundary
485 function comp = getComponent(obj, comp_str, boundary)
486 assertIsMember(comp_str, {'normal', 'tangential'});
487 assertIsMember(boundary, {'w', 'e', 's', 'n'});
488
489 switch boundary
490 case {'w', 'e'}
491 switch comp_str
492 case 'normal'
493 comp = 1;
494 case 'tangential'
495 comp = 2;
496 end
497 case {'s', 'n'}
498 switch comp_str
499 case 'normal'
500 comp = 2;
501 case 'tangential'
502 comp = 1;
503 end
476 end 504 end
477 end 505 end
478 506
479 % Returns the boundary operator op for the boundary specified by the string boundary. 507 % Returns the boundary operator op for the boundary specified by the string boundary.
480 % op: may be a cell array of strings 508 % op: may be a cell array of strings