comparison +scheme/Beam.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
84 % neighbour_scheme is an instance of Scheme that should be interfaced to. 84 % neighbour_scheme is an instance of Scheme that should be interfaced to.
85 % neighbour_boundary is a string specifying which boundary to interface to. 85 % neighbour_boundary is a string specifying which boundary to interface to.
86 function [closure, penalty] = boundary_condition(obj,boundary,type) 86 function [closure, penalty] = boundary_condition(obj,boundary,type)
87 default_arg('type','dn'); 87 default_arg('type','dn');
88 88
89 [e, d1, d2, d3] = obj.getBoundaryOperator({'e', 'd1', 'd2', 'd3'}, boundary); 89 e = obj.getBoundaryOperator('e', boundary);
90 d1 = obj.getBoundaryOperator('d1', boundary);
91 d2 = obj.getBoundaryOperator('d2', boundary);
92 d3 = obj.getBoundaryOperator('d3', boundary);
90 s = obj.getBoundarySign(boundary); 93 s = obj.getBoundarySign(boundary);
91 gamm = obj.gamm; 94 gamm = obj.gamm;
92 delt = obj.delt; 95 delt = obj.delt;
93 96
94 97
172 end 175 end
173 176
174 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary, type) 177 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary, type)
175 % u denotes the solution in the own domain 178 % u denotes the solution in the own domain
176 % v denotes the solution in the neighbour domain 179 % v denotes the solution in the neighbour domain
177 [e_u, d1_u, d2_u, d3_u] = obj.getBoundaryOperator({'e', 'd1', 'd2', 'd3'}, boundary); 180 e_u = obj.getBoundaryOperator('e', boundary);
181 d1_u = obj.getBoundaryOperator('d1', boundary);
182 d2_u = obj.getBoundaryOperator('d2', boundary);
183 d3_u = obj.getBoundaryOperator('d3', boundary);
178 s_u = obj.getBoundarySign(boundary); 184 s_u = obj.getBoundarySign(boundary);
179 185
180 [e_v, d1_v, d2_v, d3_v] = neighbour_scheme.getBoundaryOperator({'e', 'd1', 'd2', 'd3'}, neighbour_boundary); 186 e_v = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary);
187 d1_v = neighbour_scheme.getBoundaryOperator('d1', neighbour_boundary);
188 d2_v = neighbour_scheme.getBoundaryOperator('d2', neighbour_boundary);
189 d3_v = neighbour_scheme.getBoundaryOperator('d3', neighbour_boundary);
181 s_v = neighbour_scheme.getBoundarySign(neighbour_boundary); 190 s_v = neighbour_scheme.getBoundarySign(neighbour_boundary);
182 191
183 alpha_u = obj.alpha; 192 alpha_u = obj.alpha;
184 alpha_v = neighbour_scheme.alpha; 193 alpha_v = neighbour_scheme.alpha;
185 194
235 closure = obj.Hi*(tau*e_u' + sig*d1_u' + phi*alpha_u*d2_u' + psi*alpha_u*d3_u'); 244 closure = obj.Hi*(tau*e_u' + sig*d1_u' + phi*alpha_u*d2_u' + psi*alpha_u*d3_u');
236 penalty = -obj.Hi*(tau*e_v' + sig*d1_v' + phi*alpha_v*d2_v' + psi*alpha_v*d3_v'); 245 penalty = -obj.Hi*(tau*e_v' + sig*d1_v' + phi*alpha_v*d2_v' + psi*alpha_v*d3_v');
237 end 246 end
238 247
239 % Returns the boundary operator op for the boundary specified by the string boundary. 248 % Returns the boundary operator op for the boundary specified by the string boundary.
240 % op -- string or a cell array of strings 249 % op -- string
241 % boundary -- string 250 % boundary -- string
242 function varargout = getBoundaryOperator(obj, op, boundary) 251 function o = getBoundaryOperator(obj, op, boundary)
243 assertIsMember(boundary, {'l', 'r'}) 252 assertIsMember(boundary, {'l', 'r'})
244 253
245 if ~iscell(op) 254 switch op
246 op = {op};
247 end
248
249 for i = 1:numel(op)
250 switch op{i}
251 case 'e' 255 case 'e'
252 switch boundary 256 switch boundary
253 case 'l' 257 case 'l'
254 e = obj.e_l; 258 e = obj.e_l;
255 case 'r' 259 case 'r'
256 e = obj.e_r; 260 e = obj.e_r;
257 end 261 end
258 varargout{i} = e; 262 o = e;
259 263
260 case 'd1' 264 case 'd1'
261 switch boundary 265 switch boundary
262 case 'l' 266 case 'l'
263 d1 = obj.d1_l; 267 d1 = obj.d1_l;
264 case 'r' 268 case 'r'
265 d1 = obj.d1_r; 269 d1 = obj.d1_r;
266 end 270 end
267 varargout{i} = d1; 271 o = d1;
268 end 272 end
269 273
270 case 'd2' 274 case 'd2'
271 switch boundary 275 switch boundary
272 case 'l' 276 case 'l'
273 d2 = obj.d2_l; 277 d2 = obj.d2_l;
274 case 'r' 278 case 'r'
275 d2 = obj.d2_r; 279 d2 = obj.d2_r;
276 end 280 end
277 varargout{i} = d2; 281 o = d2;
278 end 282 end
279 283
280 case 'd3' 284 case 'd3'
281 switch boundary 285 switch boundary
282 case 'l' 286 case 'l'
283 d3 = obj.d3_l; 287 d3 = obj.d3_l;
284 case 'r' 288 case 'r'
285 d3 = obj.d3_r; 289 d3 = obj.d3_r;
286 end 290 end
287 varargout{i} = d3; 291 o = d3;
288 end
289 end 292 end
290 end 293 end
291 294
292 % Returns the boundary sign. The right boundary is considered the positive boundary 295 % Returns the boundary sign. The right boundary is considered the positive boundary
293 % boundary -- string 296 % boundary -- string