Mercurial > repos > public > sbplib
view +sbp/+implementations/d1_noneq_4.m @ 1301:8978521b0f06 default
Fix incorrect package name.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 08 Jul 2020 19:11:04 +0200 |
parents | 4cb627c7fb90 |
children |
line wrap: on
line source
function [D1,H] = d1_noneq_4(N,h) % N: Number of grid points if(N<8) error('Operator requires at least 8 grid points'); end % BP: Number of boundary points BP = 4; %%%% Norm matrix %%%%%%%% P = sparse(BP,1); %#ok<*NASGU> P0 = 2.1259737557798e-01; P1 = 1.0260290400758e+00; P2 = 1.0775123588954e+00; P3 = 9.8607273802835e-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 order = 4; d = [1/12,-2/3,0,2/3,-1/12]; d = repmat(d,N,1); Q = spdiags(d,-order/2:order/2,N,N); % Boundaries Q0_0 = -5.0000000000000e-01; Q0_1 = 6.5605279837843e-01; Q0_2 = -1.9875859409017e-01; Q0_3 = 4.2705795711740e-02; Q0_4 = 0.0000000000000e+00; Q0_5 = 0.0000000000000e+00; Q1_0 = -6.5605279837843e-01; Q1_1 = 0.0000000000000e+00; Q1_2 = 8.1236966439895e-01; Q1_3 = -1.5631686602052e-01; Q1_4 = 0.0000000000000e+00; Q1_5 = 0.0000000000000e+00; Q2_0 = 1.9875859409017e-01; Q2_1 = -8.1236966439895e-01; Q2_2 = 0.0000000000000e+00; Q2_3 = 6.9694440364211e-01; Q2_4 = -8.3333333333333e-02; Q2_5 = 0.0000000000000e+00; Q3_0 = -4.2705795711740e-02; Q3_1 = 1.5631686602052e-01; Q3_2 = -6.9694440364211e-01; Q3_3 = 0.0000000000000e+00; Q3_4 = 6.6666666666667e-01; Q3_5 = -8.3333333333333e-02; 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; %%%%%%%%%%%%%%%%%%%%%%%%%%%