comparison +scheme/Laplace1d.m @ 1045:dc1bcbef2a86 feature/getBoundaryOp

Remove ability to get several boundary ops at the same time from a few of the schemes While it can be handy the code for the getBoundaryOp methods get needlessly cluttered
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 22 Jan 2019 17:12:22 +0100
parents 5afc774fb7c4
children 19ed046aec52
comparison
equal deleted inserted replaced
1044:5afc774fb7c4 1045:dc1bcbef2a86
54 % neighbour_boundary is a string specifying which boundary to interface to. 54 % neighbour_boundary is a string specifying which boundary to interface to.
55 function [closure, penalty] = boundary_condition(obj,boundary,type,data) 55 function [closure, penalty] = boundary_condition(obj,boundary,type,data)
56 default_arg('type','neumann'); 56 default_arg('type','neumann');
57 default_arg('data',0); 57 default_arg('data',0);
58 58
59 [e, d] = obj.getBoundaryOperator({'e', 'd'}, boundary); 59 e = obj.getBoundaryOperator('e', boundary);
60 d = obj.getBoundaryOperator('d', boundary);
60 s = obj.getBoundarySign(boundary); 61 s = obj.getBoundarySign(boundary);
61 62
62 switch type 63 switch type
63 % Dirichlet boundary condition 64 % Dirichlet boundary condition
64 case {'D','dirichlet'} 65 case {'D','dirichlet'}
112 closure = obj.Hi*( tau*e_u' + sig*a_u*d_u'); 113 closure = obj.Hi*( tau*e_u' + sig*a_u*d_u');
113 penalty = obj.Hi*(-tau*e_v' + sig*a_v*d_v'); 114 penalty = obj.Hi*(-tau*e_v' + sig*a_v*d_v');
114 end 115 end
115 116
116 % Returns the boundary operator op for the boundary specified by the string boundary. 117 % Returns the boundary operator op for the boundary specified by the string boundary.
117 % op -- string or a cell array of strings 118 % op -- string
118 % boundary -- string 119 % boundary -- string
119 function varargout = getBoundaryOperator(obj, op, boundary) 120 function o = getBoundaryOperator(obj, op, boundary)
120 assertIsMember(boundary, {'l', 'r'}) 121 assertIsMember(boundary, {'l', 'r'})
121 122
122 if ~iscell(op) 123 switch op
123 op = {op};
124 end
125
126 for i = 1:numel(op)
127 switch op{i}
128 case 'e' 124 case 'e'
129 switch boundary 125 switch boundary
130 case 'l' 126 case 'l'
131 e = obj.e_l; 127 e = obj.e_l;
132 case 'r' 128 case 'r'
133 e = obj.e_r; 129 e = obj.e_r;
134 end 130 end
135 varargout{i} = e; 131 o = e;
136 132
137 case 'd' 133 case 'd'
138 switch boundary 134 switch boundary
139 case 'l' 135 case 'l'
140 d = obj.d_l; 136 d = obj.d_l;
141 case 'r' 137 case 'r'
142 d = obj.d_r; 138 d = obj.d_r;
143 end 139 end
144 varargout{i} = d; 140 o = d;
145 end
146 end 141 end
147 end 142 end
148 143
149 % Returns the boundary sign. The right boundary is considered the positive boundary 144 % Returns the boundary sign. The right boundary is considered the positive boundary
150 % boundary -- string 145 % boundary -- string