diff +scheme/Burgers1d.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 f6c571d8f22f
children 68ee061639a1
line wrap: on
line diff
--- a/+scheme/Burgers1d.m	Wed Aug 07 13:28:21 2019 +0200
+++ b/+scheme/Burgers1d.m	Wed Aug 07 15:23:42 2019 +0200
@@ -68,7 +68,9 @@
         %       type                is a string specifying the type of boundary condition if there are several.
         function [closure, penalty] = boundary_condition(obj, boundary, type)
             default_arg('type','dirichlet');
-            [e, index, s] = obj.get_boundary_ops(boundary);
+            s = obj.getBoundarySign(boundary);
+            e = obj.getBoundaryOperator('e', boundary);
+            index = obj.getBoundaryIndex(boundary);
             switch type
                 % Stable dirchlet-like boundary conditions (u+-abs(u))*u/3
                 % with +- at left/right boundaries
@@ -77,8 +79,8 @@
                     % closure = @(v) obj.Hi*tau*(((v(index)-s*abs(v(index)))/3)*v(index));
                     % penalty = -obj.Hi*tau;
 
-                    magnitude = 2/3;
-                    tau = @(v) s*magnitude*obj.Hi*e*(v(index)-s*abs(v(index)))/2;
+                    penalty_parameter = 1/3;
+                    tau = @(v) s*penalty_parameter*obj.Hi*e*(v(index)-s*abs(v(index)))/2;
                     closure = @(v) tau(v)*v(index);
                     penalty = @(v) -tau(v);
                 otherwise
@@ -86,20 +88,49 @@
             end
         end
 
-        % Returns the boundary ops, boundary index and sign for the boundary specified by the string boundary.
-        % The right boundary is considered the positive boundary
-        function [e, index, s] = get_boundary_ops(obj,boundary)
+
+        % 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','L','left','Left'}
-                    e = obj.e_l;
+                case {'r'}
+                    s = 1;
+                case {'l'}
+                    s = -1;
+            end
+        end
+
+        % 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'})
+            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 index. The right boundary has the last index
+        % boundary -- string
+        function index = getBoundaryIndex(obj, boundary)
+            assertIsMember(boundary, {'l', 'r'})
+            switch boundary
+                case {'r'}
+                    index = length(obj.e_r);
+                case {'l'}
                     index = 1;
-                    s = -1;
-                case {'r','R','right','Right'}
-                    e = obj.e_r;
-                    index = length(e);
-                    s = 1;
-                otherwise
-                    error('No such boundary: boundary = %s',boundary);
             end
         end