Mercurial > repos > public > sbplib
view +sbp/+implementations/d1_noneq_minimal_6.m @ 1347:ac54767ae1fb feature/poroelastic tip
Add interface, not fully compatible.
author | Martin Almquist <martin.almquist@it.uu.se> |
---|---|
date | Tue, 30 Apr 2024 14:58:35 +0200 |
parents | f7ac3cd6eeaa |
children | 4cb627c7fb90 |
line wrap: on
line source
function [D1,H,x,h] = d1_noneq_minimal_6(N,L) % L: Domain length % N: Number of grid points if(nargin < 2) L = 1; end if(N<10) error('Operator requires at least 10 grid points'); end % BP: Number of boundary points % m: Number of nonequidistant spacings % order: Accuracy of interior stencil BP = 5; m = 2; order = 6; %%%% Non-equidistant grid points %%%%% x0 = 0.0000000000000e+00; x1 = 4.0842950991998e-01; x2 = 1.1968523189207e+00; x3 = 2.1968523189207e+00; x4 = 3.1968523189207e+00; x5 = 4.1968523189207e+00; xb = sparse(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 = sparse(BP,1); %#ok<*NASGU> P0 = 1.2740260779883e-01; P1 = 6.1820981002054e-01; P2 = 9.4308973897679e-01; P3 = 1.0093019060199e+00; P4 = 9.9884825610465e-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.3217364546846e-01; Q0_2 = -1.6411963429825e-01; Q0_3 = 3.6495407984639e-02; Q0_4 = -4.5494191548490e-03; Q0_5 = 0.0000000000000e+00; Q0_6 = 0.0000000000000e+00; Q0_7 = 0.0000000000000e+00; Q1_0 = -6.3217364546846e-01; Q1_1 = 0.0000000000000e+00; Q1_2 = 8.0515625504417e-01; Q1_3 = -2.0755653563249e-01; Q1_4 = 3.4573926056780e-02; Q1_5 = 0.0000000000000e+00; Q1_6 = 0.0000000000000e+00; Q1_7 = 0.0000000000000e+00; Q2_0 = 1.6411963429825e-01; Q2_1 = -8.0515625504417e-01; Q2_2 = 0.0000000000000e+00; Q2_3 = 7.9402676057785e-01; Q2_4 = -1.6965680649860e-01; Q2_5 = 1.6666666666667e-02; Q2_6 = 0.0000000000000e+00; Q2_7 = 0.0000000000000e+00; Q3_0 = -3.6495407984639e-02; Q3_1 = 2.0755653563249e-01; Q3_2 = -7.9402676057785e-01; Q3_3 = 0.0000000000000e+00; Q3_4 = 7.5629896626333e-01; Q3_5 = -1.5000000000000e-01; Q3_6 = 1.6666666666667e-02; Q3_7 = 0.0000000000000e+00; Q4_0 = 4.5494191548490e-03; Q4_1 = -3.4573926056780e-02; Q4_2 = 1.6965680649860e-01; Q4_3 = -7.5629896626333e-01; Q4_4 = 0.0000000000000e+00; Q4_5 = 7.5000000000000e-01; Q4_6 = -1.5000000000000e-01; Q4_7 = 1.6666666666667e-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; %%%%%%%%%%%%%%%%%%%%%%%%%%%