diff +sbp/+implementations/d1_noneq_minimal_8.m @ 261:6009f2712d13 operator_remake

Moved and renamned all implementations.
author Martin Almquist <martin.almquist@it.uu.se>
date Thu, 08 Sep 2016 15:35:45 +0200
parents
children bfa130b7abf6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+sbp/+implementations/d1_noneq_minimal_8.m	Thu Sep 08 15:35:45 2016 +0200
@@ -0,0 +1,150 @@
+function [D1,H,x,h] = d1_noneq_minimal_8(N,L)
+
+% L: Domain length
+% N: Number of grid points
+if(nargin < 2)
+    L = 1;
+end
+
+% BP: Number of boundary points
+% m:  Number of nonequidistant spacings
+% order: Accuracy of interior stencil
+BP = 6;
+m = 2;
+order = 8;
+
+%%%% Non-equidistant grid points %%%%%
+x0 =  0.0000000000000e+00;
+x1 =  4.9439570885261e-01;
+x2 =  1.4051531374839e+00;
+x3 =  2.4051531374839e+00;
+x4 =  3.4051531374839e+00;
+x5 =  4.4051531374839e+00;
+x6 =  5.4051531374839e+00;
+
+xb = zeros(m+1,1);
+for i = 0:m
+    xb(i+1) = eval(['x' num2str(i)]);
+end
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%% Compute h %%%%%%%%%%
+h = L/(2*xb(end) + N-1-2*m);
+%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%% Define grid %%%%%%%%
+x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ];
+%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%% Norm matrix %%%%%%%%
+P = zeros(BP,1);
+%#ok<*NASGU>
+P0 =  1.4523997892351e-01;
+P1 =  7.6864793350174e-01;
+P2 =  9.9116487068535e-01;
+P3 =  9.9992473335107e-01;
+P4 =  1.0002097054636e+00;
+P5 =  9.9996591555866e-01;
+
+for i = 0:BP-1
+    P(i+1) = eval(['P' num2str(i)]);
+end
+
+H = ones(N,1);
+H(1:BP) = P;
+H(end-BP+1:end) = flip(P);
+H = spdiags(h*H,0,N,N);
+%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%% Q matrix %%%%%%%%%%%
+
+% interior stencil
+switch order
+    case 2
+        d = [-1/2,0,1/2];
+    case 4
+        d = [1/12,-2/3,0,2/3,-1/12];
+    case 6
+        d = [-1/60,3/20,-3/4,0,3/4,-3/20,1/60];
+    case 8
+        d = [1/280,-4/105,1/5,-4/5,0,4/5,-1/5,4/105,-1/280];
+    case 10
+        d = [-1/1260,5/504,-5/84,5/21,-5/6,0,5/6,-5/21,5/84,-5/504,1/1260];
+    case 12
+        d = [1/5544,-1/385,1/56,-5/63,15/56,-6/7,0,6/7,-15/56,5/63,-1/56,1/385,-1/5544];
+end
+d = repmat(d,N,1);
+Q = spdiags(d,-order/2:order/2,N,N);
+
+% Boundaries
+Q0_0 = -5.0000000000000e-01;
+Q0_1 =  6.6697342753834e-01;
+Q0_2 = -2.2919342278749e-01;
+Q0_3 =  7.4283116457276e-02;
+Q0_4 = -1.2020661178873e-02;
+Q0_5 = -4.2460029252999e-05;
+Q0_6 =  0.0000000000000e+00;
+Q0_7 =  0.0000000000000e+00;
+Q0_8 =  0.0000000000000e+00;
+Q0_9 =  0.0000000000000e+00;
+Q1_0 = -6.6697342753834e-01;
+Q1_1 =  0.0000000000000e+00;
+Q1_2 =  8.8241196934163e-01;
+Q1_3 = -2.6653314104602e-01;
+Q1_4 =  5.5302527504316e-02;
+Q1_5 = -4.2079282615860e-03;
+Q1_6 =  0.0000000000000e+00;
+Q1_7 =  0.0000000000000e+00;
+Q1_8 =  0.0000000000000e+00;
+Q1_9 =  0.0000000000000e+00;
+Q2_0 =  2.2919342278749e-01;
+Q2_1 = -8.8241196934163e-01;
+Q2_2 =  0.0000000000000e+00;
+Q2_3 =  8.2904844081126e-01;
+Q2_4 = -2.1156614214635e-01;
+Q2_5 =  3.9307676460659e-02;
+Q2_6 = -3.5714285714286e-03;
+Q2_7 =  0.0000000000000e+00;
+Q2_8 =  0.0000000000000e+00;
+Q2_9 =  0.0000000000000e+00;
+Q3_0 = -7.4283116457276e-02;
+Q3_1 =  2.6653314104602e-01;
+Q3_2 = -8.2904844081126e-01;
+Q3_3 =  0.0000000000000e+00;
+Q3_4 =  8.0305501223679e-01;
+Q3_5 = -2.0078040553808e-01;
+Q3_6 =  3.8095238095238e-02;
+Q3_7 = -3.5714285714286e-03;
+Q3_8 =  0.0000000000000e+00;
+Q3_9 =  0.0000000000000e+00;
+Q4_0 =  1.2020661178873e-02;
+Q4_1 = -5.5302527504316e-02;
+Q4_2 =  2.1156614214635e-01;
+Q4_3 = -8.0305501223679e-01;
+Q4_4 =  0.0000000000000e+00;
+Q4_5 =  8.0024692689207e-01;
+Q4_6 = -2.0000000000000e-01;
+Q4_7 =  3.8095238095238e-02;
+Q4_8 = -3.5714285714286e-03;
+Q4_9 =  0.0000000000000e+00;
+Q5_0 =  4.2460029252999e-05;
+Q5_1 =  4.2079282615860e-03;
+Q5_2 = -3.9307676460659e-02;
+Q5_3 =  2.0078040553808e-01;
+Q5_4 = -8.0024692689207e-01;
+Q5_5 =  0.0000000000000e+00;
+Q5_6 =  8.0000000000000e-01;
+Q5_7 = -2.0000000000000e-01;
+Q5_8 =  3.8095238095238e-02;
+Q5_9 = -3.5714285714286e-03;
+for i = 1:BP
+    for j = 1:BP
+        Q(i,j) = eval(['Q' num2str(i-1) '_' num2str(j-1)]);
+        Q(N+1-i,N+1-j) = -eval(['Q' num2str(i-1) '_' num2str(j-1)]);
+    end
+end
+%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%% Difference operator %%
+D1 = H\Q;
+%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ No newline at end of file