Mercurial > repos > public > sbplib
changeset 1066:d64062bed5fb feature/laplace_curvilinear_test
Clean up getBoundarOperator/Quadrature as was done on feature/getBoundaryOp. Temporarily re-add lambda so that old interface method works.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 22 Jan 2019 12:53:13 -0800 |
parents | c2bd7f15da48 |
children | 9a858436f8fa |
files | +scheme/LaplaceCurvilinearNewCorner.m |
diffstat | 1 files changed, 31 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
diff -r c2bd7f15da48 -r d64062bed5fb +scheme/LaplaceCurvilinearNewCorner.m --- a/+scheme/LaplaceCurvilinearNewCorner.m Thu Jan 17 18:57:54 2019 -0800 +++ b/+scheme/LaplaceCurvilinearNewCorner.m Tue Jan 22 12:53:13 2019 -0800 @@ -45,6 +45,10 @@ theta_R_u, theta_R_v theta_H_u, theta_H_v + % Temporary + lambda + gamm_u, gamm_v + end methods @@ -139,7 +143,7 @@ a11 = 1./J .* (x_v.^2 + y_v.^2); a12 = -1./J .* (x_u.*x_v + y_u.*y_v); a22 = 1./J .* (x_u.^2 + y_u.^2); - % lambda = 1/2 * (a11 + a22 - sqrt((a11-a22).^2 + 4*a12.^2)); + lambda = 1/2 * (a11 + a22 - sqrt((a11-a22).^2 + 4*a12.^2)); K = cell(dim, dim); K{1,1} = spdiag(y_v./J); @@ -234,7 +238,6 @@ obj.a11 = a11; obj.a12 = a12; obj.a22 = a22; - % obj.lambda = lambda; obj.s_w = spdiag(s_w); obj.s_e = spdiag(s_e); obj.s_s = spdiag(s_s); @@ -248,6 +251,11 @@ obj.theta_H_u = h_u*ops_u.borrowing.H11; obj.theta_H_v = h_v*ops_v.borrowing.H11; + + % Temporary + obj.lambda = lambda; + obj.gamm_u = h_u*ops_u.borrowing.M.d1; + obj.gamm_v = h_v*ops_v.borrowing.M.d1; end @@ -262,7 +270,8 @@ default_arg('type','neumann'); default_arg('parameter', []); - [e, d] = obj.getBoundaryOperator({'e', 'd'}, boundary); + e = obj.getBoundaryOperator('e', boundary); + d = obj.getBoundaryOperator('d', boundary); H_b = obj.getBoundaryQuadrature(boundary); s_b = obj.getBoundaryScaling(boundary); [th_H, th_M, th_R] = obj.getBoundaryBorrowing(boundary); @@ -322,7 +331,7 @@ % -- interpolation: type of interpolation, default 'none' function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary,type) - error('Not implemented') + % error('Not implemented') defaultType.tuning = 1.2; defaultType.interpolation = 'none'; @@ -343,12 +352,14 @@ % u denotes the solution in the own domain % v denotes the solution in the neighbour domain - [e_u, d_u] = obj.getBoundaryOperator({'e', 'd'}, boundary); + e_u = obj.getBoundaryOperator('e', boundary); + d_u = obj.getBoundaryOperator('d', boundary); H_b_u = obj.getBoundaryQuadrature(boundary); I_u = obj.getBoundaryIndices(boundary); gamm_u = obj.getBoundaryBorrowing(boundary); - [e_v, d_v] = neighbour_scheme.getBoundaryOperator({'e', 'd'}, neighbour_boundary); + e_v = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary); + d_v = neighbour_scheme.getBoundaryOperator('d', neighbour_boundary); H_b_v = neighbour_scheme.getBoundaryQuadrature(neighbour_boundary); I_v = neighbour_scheme.getBoundaryIndices(neighbour_boundary); gamm_v = neighbour_scheme.getBoundaryBorrowing(neighbour_boundary); @@ -388,12 +399,14 @@ % u denotes the solution in the own domain % v denotes the solution in the neighbour domain - [e_u, d_u] = obj.getBoundaryOperator({'e', 'd'}, boundary); + e_u = obj.getBoundaryOperator('e', boundary); + d_u = obj.getBoundaryOperator('d', boundary); H_b_u = obj.getBoundaryQuadrature(boundary); I_u = obj.getBoundaryIndices(boundary); gamm_u = obj.getBoundaryBorrowing(boundary); - [e_v, d_v] = neighbour_scheme.getBoundaryOperator({'e', 'd'}, neighbour_boundary); + e_v = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary); + d_v = neighbour_scheme.getBoundaryOperator('d', neighbour_boundary); H_b_v = neighbour_scheme.getBoundaryQuadrature(neighbour_boundary); I_v = neighbour_scheme.getBoundaryIndices(neighbour_boundary); gamm_v = neighbour_scheme.getBoundaryBorrowing(neighbour_boundary); @@ -439,47 +452,13 @@ end % Returns the boundary operator op for the boundary specified by the string boundary. - % op -- string or a cell array of strings + % op -- string % boundary -- string - function varargout = getBoundaryOperator(obj, op, boundary) - - if ~iscell(op) - op = {op}; - end + function o = getBoundaryOperator(obj, op, boundary) + assertIsMember(op, {'e', 'd'}) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) - for i = 1:numel(op) - switch op{i} - case 'e' - switch boundary - case 'w' - e = obj.e_w; - case 'e' - e = obj.e_e; - case 's' - e = obj.e_s; - case 'n' - e = obj.e_n; - otherwise - error('No such boundary: boundary = %s',boundary); - end - varargout{i} = e; - - case 'd' - switch boundary - case 'w' - d = obj.d_w; - case 'e' - d = obj.d_e; - case 's' - d = obj.d_s; - case 'n' - d = obj.d_n; - otherwise - error('No such boundary: boundary = %s',boundary); - end - varargout{i} = d; - end - end + o = obj.([op, '_', boundary]); end % Returns square boundary quadrature matrix, of dimension @@ -487,19 +466,9 @@ % % boundary -- string function H_b = getBoundaryQuadrature(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) - switch boundary - case 'w' - H_b = obj.H_w; - case 'e' - H_b = obj.H_e; - case 's' - H_b = obj.H_s; - case 'n' - H_b = obj.H_n; - otherwise - error('No such boundary: boundary = %s',boundary); - end + H_b = obj.(['H_', boundary]); end % Returns square boundary quadrature scaling matrix, of dimension @@ -507,33 +476,22 @@ % % boundary -- string function s_b = getBoundaryScaling(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) - switch boundary - case 'w' - s_b = obj.s_w; - case 'e' - s_b = obj.s_e; - case 's' - s_b = obj.s_s; - case 'n' - s_b = obj.s_n; - otherwise - error('No such boundary: boundary = %s',boundary); - end + s_b = obj.(['s_', boundary]); end % Returns the coordinate number corresponding to the boundary % % boundary -- string function m = getBoundaryNumber(obj, boundary) + assertIsMember(boundary, {'w', 'e', 's', 'n'}) switch boundary case {'w', 'e'} m = 1; case {'s', 'n'} m = 2; - otherwise - error('No such boundary: boundary = %s',boundary); end end