Mercurial > repos > public > sbplib
changeset 85:643bc513b8b8
Wave2DCurve: Fixed error in tau. Also made random guess at fixing theory from paper.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 30 Nov 2015 11:41:34 +0100 |
parents | 9d514669d372 |
children | 53fe4b64f65e |
files | +scheme/Wave2dCurve.m printSize.m |
diffstat | 2 files changed, 22 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/+scheme/Wave2dCurve.m Fri Nov 27 10:06:10 2015 +0100 +++ b/+scheme/Wave2dCurve.m Mon Nov 30 11:41:34 2015 +0100 @@ -244,8 +244,8 @@ % v denotes the solution in the neighbour domain tuning = 1.2; % tuning = 20.2; - [e_u, d_n_u, d_t_u, coeff_n_u, coeff_t_u, s_u, gamm_u, halfnorm_inv_u_n, halfnorm_inv_u_t, halfnorm_u_t] = obj.get_boundary_ops(boundary); - [e_v, d_n_v, d_t_v, coeff_n_v, coeff_t_v, s_v, gamm_v, halfnorm_inv_v_n, halfnorm_inv_v_t, halfnorm_v_t] = neighbour_scheme.get_boundary_ops(neighbour_boundary); + [e_u, d_n_u, d_t_u, coeff_n_u, coeff_t_u, s_u, gamm_u, halfnorm_inv_u_n, halfnorm_inv_u_t, halfnorm_u_t, I_u] = obj.get_boundary_ops(boundary); + [e_v, d_n_v, d_t_v, coeff_n_v, coeff_t_v, s_v, gamm_v, halfnorm_inv_v_n, halfnorm_inv_v_t, halfnorm_v_t, I_v] = neighbour_scheme.get_boundary_ops(neighbour_boundary); a_n_u = spdiag(coeff_n_u); a_t_u = spdiag(coeff_t_u); @@ -258,18 +258,18 @@ u = obj; v = neighbour_scheme; - b1_u = gamm_u*u.lambda./u.a11.^2; - b2_u = gamm_u*u.lambda./u.a22.^2; - b1_v = gamm_v*v.lambda./v.a11.^2; - b2_v = gamm_v*v.lambda./v.a22.^2; - + b1_u = gamm_u*u.lambda(I_u)./u.a11(I_u).^2; + b2_u = gamm_u*u.lambda(I_u)./u.a22(I_u).^2; + b1_v = gamm_v*v.lambda(I_v)./v.a11(I_v).^2; + b2_v = gamm_v*v.lambda(I_v)./v.a22(I_v).^2; tau = -1./(4*b1_u) -1./(4*b1_v) -1./(4*b2_u) -1./(4*b2_v); - tau = tuning * spdiag(tau(:)); + tau = tuning * spdiag(tau(:)); % Probably correct until here, see eq 27 sig1 = 1/2; sig2 = -1/2; - penalty_parameter_1 = halfnorm_inv_u_n*(tau + sig1*halfnorm_inv_u_t*F_u*e_u'*halfnorm_u_t)*e_u; + % penalty_parameter_1 = halfnorm_inv_u_n*(tau + sig1*halfnorm_inv_u_t*F_u*e_u'*halfnorm_u_t)*e_u; %% This is what is in the paper, but there is an error in dimensions. + penalty_parameter_1 = halfnorm_inv_u_n*(e_u*tau + sig1*halfnorm_inv_u_t*F_u*e_u'*halfnorm_u_t*e_u); %% Random guess at a fix, should check theory for this. penalty_parameter_2 = halfnorm_inv_u_n * sig2 * e_u; @@ -279,7 +279,13 @@ % Ruturns the boundary ops and sign for the boundary specified by the string boundary. % The right boundary is considered the positive boundary - function [e, d_n, d_t, coeff_n, coeff_t, s, gamm, halfnorm_inv_n, halfnorm_inv_t, halfnorm_t,a_n, a_t] = get_boundary_ops(obj,boundary) + % + % I -- the indecies of the boundary points in the grid matrix + function [e, d_n, d_t, coeff_n, coeff_t, s, gamm, halfnorm_inv_n, halfnorm_inv_t, halfnorm_t, I] = get_boundary_ops(obj,boundary) + + gridMatrix = zeros(obj.m(2),obj.m(1)); + gridMatrix(:) = 1:numel(gridMatrix); + switch boundary case 'w' e = obj.e_w; @@ -287,6 +293,7 @@ d_t = obj.dv_w; s = -1; + I = gridMatrix(:,1); coeff_n = obj.a11(:,1); coeff_t = obj.a12(:,1); case 'e' @@ -295,6 +302,7 @@ d_t = obj.dv_e; s = 1; + I = gridMatrix(:,end); coeff_n = obj.a11(:,end); coeff_t = obj.a12(:,end); case 's' @@ -303,6 +311,7 @@ d_t = obj.du_s; s = -1; + I = gridMatrix(1,:)'; coeff_n = obj.a22(1,:)'; coeff_t = obj.a12(1,:)'; case 'n' @@ -311,6 +320,7 @@ d_t = obj.du_n; s = 1; + I = gridMatrix(end,:)'; coeff_n = obj.a22(end,:)'; coeff_t = obj.a12(end,:)'; otherwise
--- a/printSize.m Fri Nov 27 10:06:10 2015 +0100 +++ b/printSize.m Mon Nov 30 11:41:34 2015 +0100 @@ -1,5 +1,4 @@ function printSize(A) - warning('Deprecated! Use printExpr() instead!'); - s = size(A); - fprintf('%8s has size: [%d, %d]\n',inputname(1),s(1),s(2)); + result = size(A); + fprintf('size(%s) => %s\n', inputname(1), toString(result)); end \ No newline at end of file