comparison +scheme/Hypsyst2d.m @ 1197:433c89bf19e0 feature/rv

Merge with default
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 07 Aug 2019 15:23:42 +0200
parents 8d73fcdb07a5
children
comparison
equal deleted inserted replaced
1196:f6c571d8f22f 1197:433c89bf19e0
184 % General boundary condition in the form Lu=g(x) 184 % General boundary condition in the form Lu=g(x)
185 function [closure,penalty] = boundary_condition_general(obj,boundary,L) 185 function [closure,penalty] = boundary_condition_general(obj,boundary,L)
186 params = obj.params; 186 params = obj.params;
187 x = obj.x; 187 x = obj.x;
188 y = obj.y; 188 y = obj.y;
189 e_ = obj.getBoundaryOperator('e', boundary);
189 190
190 switch boundary 191 switch boundary
191 case {'w','W','west'} 192 case {'w','W','west'}
192 e_ = obj.e_w;
193 mat = obj.A; 193 mat = obj.A;
194 boundPos = 'l'; 194 boundPos = 'l';
195 Hi = obj.Hxi; 195 Hi = obj.Hxi;
196 [V,Vi,D,signVec] = obj.matrixDiag(mat,x(1),y); 196 [V,Vi,D,signVec] = obj.matrixDiag(mat,x(1),y);
197 L = obj.evaluateCoefficientMatrix(L,x(1),y); 197 L = obj.evaluateCoefficientMatrix(L,x(1),y);
198 side = max(length(y)); 198 side = max(length(y));
199 case {'e','E','east'} 199 case {'e','E','east'}
200 e_ = obj.e_e;
201 mat = obj.A; 200 mat = obj.A;
202 boundPos = 'r'; 201 boundPos = 'r';
203 Hi = obj.Hxi; 202 Hi = obj.Hxi;
204 [V,Vi,D,signVec] = obj.matrixDiag(mat,x(end),y); 203 [V,Vi,D,signVec] = obj.matrixDiag(mat,x(end),y);
205 L = obj.evaluateCoefficientMatrix(L,x(end),y); 204 L = obj.evaluateCoefficientMatrix(L,x(end),y);
206 side = max(length(y)); 205 side = max(length(y));
207 case {'s','S','south'} 206 case {'s','S','south'}
208 e_ = obj.e_s;
209 mat = obj.B; 207 mat = obj.B;
210 boundPos = 'l'; 208 boundPos = 'l';
211 Hi = obj.Hyi; 209 Hi = obj.Hyi;
212 [V,Vi,D,signVec] = obj.matrixDiag(mat,x,y(1)); 210 [V,Vi,D,signVec] = obj.matrixDiag(mat,x,y(1));
213 L = obj.evaluateCoefficientMatrix(L,x,y(1)); 211 L = obj.evaluateCoefficientMatrix(L,x,y(1));
214 side = max(length(x)); 212 side = max(length(x));
215 case {'n','N','north'} 213 case {'n','N','north'}
216 e_ = obj.e_n;
217 mat = obj.B; 214 mat = obj.B;
218 boundPos = 'r'; 215 boundPos = 'r';
219 Hi = obj.Hyi; 216 Hi = obj.Hyi;
220 [V,Vi,D,signVec] = obj.matrixDiag(mat,x,y(end)); 217 [V,Vi,D,signVec] = obj.matrixDiag(mat,x,y(end));
221 L = obj.evaluateCoefficientMatrix(L,x,y(end)); 218 L = obj.evaluateCoefficientMatrix(L,x,y(end));
295 V = [V(:,poseig) V(:,zeroeig) V(:,negeig)]; 292 V = [V(:,poseig) V(:,zeroeig) V(:,negeig)];
296 Vi = [Vi(poseig,:); Vi(zeroeig,:); Vi(negeig,:)]; 293 Vi = [Vi(poseig,:); Vi(zeroeig,:); Vi(negeig,:)];
297 signVec = [sum(poseig),sum(zeroeig),sum(negeig)]; 294 signVec = [sum(poseig),sum(zeroeig),sum(negeig)];
298 end 295 end
299 296
297 % Returns the boundary operator op for the boundary specified by the string boundary.
298 % op -- string or a cell array of strings
299 % boundary -- string
300 function varargout = getBoundaryOperator(obj, op, boundary)
301 assertIsMember(boundary, {'w', 'e', 's', 'n'})
302
303 if ~iscell(op)
304 op = {op};
305 end
306
307 for i = 1:numel(op)
308 switch op{i}
309 case 'e'
310 switch boundary
311 case 'w'
312 e = obj.e_w;
313 case 'e'
314 e = obj.e_e;
315 case 's'
316 e = obj.e_s;
317 case 'n'
318 e = obj.e_n;
319 end
320 varargout{i} = e;
321 end
322 end
323 end
324
325 % Returns square boundary quadrature matrix, of dimension
326 % corresponding to the number of boundary points
327 %
328 % boundary -- string
329 function H_b = getBoundaryQuadrature(obj, boundary)
330 assertIsMember(boundary, {'w', 'e', 's', 'n'})
331
332 e = obj.getBoundaryOperator('e', boundary);
333
334 switch boundary
335 case 'w'
336 H_b = inv(e'*obj.Hyi*e);
337 case 'e'
338 H_b = inv(e'*obj.Hyi*e);
339 case 's'
340 H_b = inv(e'*obj.Hxi*e);
341 case 'n'
342 H_b = inv(e'*obj.Hxi*e);
343 end
344 end
345
300 end 346 end
301 end 347 end