Mercurial > repos > public > sbplib
diff +scheme/Laplace1d.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 | 33c378e508d2 |
children |
line wrap: on
line diff
--- a/+scheme/Laplace1d.m Wed Aug 07 13:28:21 2019 +0200 +++ b/+scheme/Laplace1d.m Wed Aug 07 15:23:42 2019 +0200 @@ -56,11 +56,13 @@ default_arg('type','neumann'); default_arg('data',0); - [e,d,s] = obj.get_boundary_ops(boundary); + e = obj.getBoundaryOperator('e', boundary); + d = obj.getBoundaryOperator('d', boundary); + s = obj.getBoundarySign(boundary); switch type % Dirichlet boundary condition - case {'D','dirichlet'} + case {'D','d','dirichlet'} tuning = 1.1; tau1 = -tuning/obj.gamm; tau2 = 1; @@ -68,10 +70,10 @@ tau = tau1*e + tau2*d; closure = obj.a*obj.Hi*tau*e'; - penalty = obj.a*obj.Hi*tau; + penalty = -obj.a*obj.Hi*tau; % Neumann boundary condition - case {'N','neumann'} + case {'N','n','neumann'} tau = -e; closure = obj.a*obj.Hi*tau*d'; @@ -86,10 +88,13 @@ function [closure, penalty] = interface(obj, boundary, neighbour_scheme, neighbour_boundary, type) % u denotes the solution in the own domain % v denotes the solution in the neighbour domain + e_u = obj.getBoundaryOperator('e', boundary); + d_u = obj.getBoundaryOperator('d', boundary); + s_u = obj.getBoundarySign(boundary); - [e_u,d_u,s_u] = obj.get_boundary_ops(boundary); - [e_v,d_v,s_v] = neighbour_scheme.get_boundary_ops(neighbour_boundary); - + e_v = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary); + d_v = neighbour_scheme.getBoundaryOperator('d', neighbour_boundary); + s_v = neighbour_scheme.getBoundarySign(neighbour_boundary); a_u = obj.a; a_v = neighbour_scheme.a; @@ -99,7 +104,7 @@ tuning = 1.1; - tau1 = -(a_u/gamm_u + a_v/gamm_v) * tuning; + tau1 = -1/4*(a_u/gamm_u + a_v/gamm_v) * tuning; tau2 = 1/2*a_u; sig1 = -1/2; sig2 = 0; @@ -111,20 +116,37 @@ penalty = obj.Hi*(-tau*e_v' + sig*a_v*d_v'); end - % 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,s] = get_boundary_ops(obj,boundary) + % Returns the boundary operator op for the boundary specified by the string boundary. + % op -- string + % boundary -- string + function o = getBoundaryOperator(obj, op, boundary) + assertIsMember(op, {'e', 'd'}) + assertIsMember(boundary, {'l', 'r'}) + + o = obj.([op, '_', boundary]); + end + + % Returns square boundary quadrature matrix, of dimension + % corresponding to the number of boundary points + % + % boundary -- string + % Note: for 1d diffOps, the boundary quadrature is the scalar 1. + function H_b = getBoundaryQuadrature(obj, boundary) + assertIsMember(boundary, {'l', 'r'}) + + H_b = 1; + end + + % Returns the boundary sign. The right boundary is considered the positive boundary + % boundary -- string + function s = getBoundarySign(obj, boundary) + assertIsMember(boundary, {'l', 'r'}) + switch boundary - case 'l' - e = obj.e_l; - d = obj.d_l; + case {'r'} + s = 1; + case {'l'} s = -1; - case 'r' - e = obj.e_r; - d = obj.d_r; - s = 1; - otherwise - error('No such boundary: boundary = %s',boundary); end end @@ -133,14 +155,4 @@ end end - - methods(Static) - % Calculates the matrcis need for the inteface coupling between boundary bound_u of scheme schm_u - % and bound_v of scheme schm_v. - % [uu, uv, vv, vu] = inteface_couplong(A,'r',B,'l') - function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v) - [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v); - [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u); - end - end -end \ No newline at end of file +end