changeset 400:14f2be4fe9c1 feature/beams

Add function to center colorlimits.
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 31 Jan 2017 13:23:52 +0100
parents 359861563866
children 9ff24a14f9ef
files +time/SBPInTime.m centerColorbar.m
diffstat 2 files changed, 43 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/+time/SBPInTime.m	Thu Jan 26 15:17:38 2017 +0100
+++ b/+time/SBPInTime.m	Tue Jan 31 13:23:52 2017 +0100
@@ -4,15 +4,13 @@
     % k_local -- time-step
     % Nblock -- number of points in each block
     % nodes -- points such that t_n + nodes are the points in block n.
-    % Each "step" takes one block step and thus advances 
+    % Each "step" takes one block step and thus advances
     % k = k_local*(Nblock-1) in time.
     % M -- matrix used in every solve.
     % [L,U,P,Q] = lu(M);
     properties
-        M
-        L
-        U
-        P
+        M     % System matrix
+        L,U,P % LU factorization of M
         Q
         A
         Et_r
@@ -33,7 +31,7 @@
         function obj = SBPInTime(A, f, k, order, Nblock, t0, v0, TYPE)
             default_arg('TYPE','equidistant');
             default_arg('Nblock',time.SBPInTime.smallestBlockSize(order,TYPE));
-            
+
             obj.A = A;
             obj.f = f;
             obj.k_local = k;
@@ -42,7 +40,7 @@
             obj.t = t0;
             obj.m = length(v0);
             obj.n = 0;
-            
+
             %==== Build the time discretization matrix =====%
             switch TYPE
                 case 'equidistant'
@@ -52,38 +50,38 @@
                 case 'minimal'
                     ops = sbp.D1Nonequidistant(Nblock,{0,obj.k},order,'minimal');
             end
-            
+
             D1 = ops.D1;
             HI = ops.HI;
             e_l = ops.e_l;
             e_r = ops.e_r;
             obj.nodes = ops.x;
-            
+
             Ix = speye(size(A));
             It = speye(Nblock,Nblock);
-            
-            obj.Et_r = kron(e_r,Ix);            
-            
+
+            obj.Et_r = kron(e_r,Ix);
+
             % Time derivative + penalty
             tau = 1;
-            Mt = D1 + tau*HI*(e_l*e_l'); 
-            
+            Mt = D1 + tau*HI*(e_l*e_l');
+
             % penalty to impose "data"
             penalty = tau*HI*e_l;
             obj.penalty = kron(penalty,Ix);
-            
+
             Mx = kron(It,A);
-            Mt = kron(Mt,Ix); 
+            Mt = kron(Mt,Ix);
             obj.M = Mt - Mx;
             %==============================================%
-            
+
             % LU factorization
             [obj.L,obj.U,obj.P,obj.Q] = lu(obj.M);
-            
+
             % Pretend that the initial condition is the last level
             % of a previous step.
             obj.v = obj.Et_r * v0;
-                
+
         end
 
         function [v,t] = getV(obj)
@@ -100,17 +98,17 @@
             obj.n = obj.n + obj.Nblock-1;
         end
     end
-    
-    
+
+
     methods(Static)
-        
-        % 
+
+        %
         function [k,numberOfBlocks] = alignedTimeStep(k,Tend,Nblock)
-            
+
             % input k is the desired time-step
             % Nblock is the number of points per block.
-            
-            % Make sure that we reach the final time by advancing 
+
+            % Make sure that we reach the final time by advancing
             % an integer number of blocks
             kblock = (Nblock-1)*k;
             numberOfBlocks = ceil(Tend/kblock);
@@ -118,14 +116,14 @@
 
             % Corrected time step
             k = kblock/(Nblock-1);
-            
+
         end
-        
+
         function N = smallestBlockSize(order,TYPE)
             default_arg('TYPE','equidistant')
-            
+
             switch TYPE
-                
+
                 case 'equidistant'
                     switch order
                         case 2
@@ -143,9 +141,9 @@
                         otherwise
                             error('Operator does not exist');
                     end
-                    
+
                 case 'optimal'
-                    
+
                     switch order
                         case 4
                             N = 8;
@@ -160,9 +158,9 @@
                         otherwise
                             error('Operator does not exist');
                     end
-                    
+
                 case 'minimal'
-                    
+
                     switch order
                         case 4
                             N = 6;
@@ -177,13 +175,13 @@
                         otherwise
                             error('Operator does not exist');
                     end
-                    
+
             end
-            
+
         end
-        
+
     end
-    
-    
+
+
 
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/centerColorbar.m	Tue Jan 31 13:23:52 2017 +0100
@@ -0,0 +1,6 @@
+function centerColorbar(ah)
+    old = ah.CLim;
+
+    l = max(abs(old));
+    ah.CLim = [-l l];
+end
\ No newline at end of file