comparison +sbp/+implementations/d1_noneq_minimal_6.m @ 1300:196123459178

Merge in feature/boundary_optimized_grids
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 08 Jul 2020 18:22:54 +0200
parents 4cb627c7fb90
children
comparison
equal deleted inserted replaced
1250:8ec777fb473e 1300:196123459178
1 function [D1,H,x,h] = d1_noneq_minimal_6(N,L) 1 function [D1,H] = d1_noneq_minimal_6(N,h)
2 2
3 % L: Domain length
4 % N: Number of grid points 3 % N: Number of grid points
5 if(nargin < 2)
6 L = 1;
7 end
8
9 if(N<10) 4 if(N<10)
10 error('Operator requires at least 10 grid points'); 5 error('Operator requires at least 10 grid points');
11 end 6 end
12 7
13 % BP: Number of boundary points 8 % BP: Number of boundary points
14 % m: Number of nonequidistant spacings
15 % order: Accuracy of interior stencil
16 BP = 5; 9 BP = 5;
17 m = 2;
18 order = 6;
19
20 %%%% Non-equidistant grid points %%%%%
21 x0 = 0.0000000000000e+00;
22 x1 = 4.0842950991998e-01;
23 x2 = 1.1968523189207e+00;
24 x3 = 2.1968523189207e+00;
25 x4 = 3.1968523189207e+00;
26 x5 = 4.1968523189207e+00;
27
28 xb = sparse(m+1,1);
29 for i = 0:m
30 xb(i+1) = eval(['x' num2str(i)]);
31 end
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33
34 %%%% Compute h %%%%%%%%%%
35 h = L/(2*xb(end) + N-1-2*m);
36 %%%%%%%%%%%%%%%%%%%%%%%%%
37
38 %%%% Define grid %%%%%%%%
39 x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ];
40 %%%%%%%%%%%%%%%%%%%%%%%%%
41 10
42 %%%% Norm matrix %%%%%%%% 11 %%%% Norm matrix %%%%%%%%
43 P = sparse(BP,1); 12 P = sparse(BP,1);
44 %#ok<*NASGU> 13 %#ok<*NASGU>
45 P0 = 1.2740260779883e-01; 14 P0 = 1.2740260779883e-01;
57 H(end-BP+1:end) = flip(P); 26 H(end-BP+1:end) = flip(P);
58 H = spdiags(h*H,0,N,N); 27 H = spdiags(h*H,0,N,N);
59 %%%%%%%%%%%%%%%%%%%%%%%%% 28 %%%%%%%%%%%%%%%%%%%%%%%%%
60 29
61 %%%% Q matrix %%%%%%%%%%% 30 %%%% Q matrix %%%%%%%%%%%
62
63 % interior stencil 31 % interior stencil
64 switch order 32 order = 6;
65 case 2 33 d = [-1/60,3/20,-3/4,0,3/4,-3/20,1/60];
66 d = [-1/2,0,1/2];
67 case 4
68 d = [1/12,-2/3,0,2/3,-1/12];
69 case 6
70 d = [-1/60,3/20,-3/4,0,3/4,-3/20,1/60];
71 case 8
72 d = [1/280,-4/105,1/5,-4/5,0,4/5,-1/5,4/105,-1/280];
73 case 10
74 d = [-1/1260,5/504,-5/84,5/21,-5/6,0,5/6,-5/21,5/84,-5/504,1/1260];
75 case 12
76 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];
77 end
78 d = repmat(d,N,1); 34 d = repmat(d,N,1);
79 Q = spdiags(d,-order/2:order/2,N,N); 35 Q = spdiags(d,-order/2:order/2,N,N);
80 36
81 % Boundaries 37 % Boundaries
82 Q0_0 = -5.0000000000000e-01; 38 Q0_0 = -5.0000000000000e-01;