Mercurial > repos > public > sbplib
annotate +sbp/+implementations/d4_lonely_4_min_boundary_points.m @ 1337:bf2554f1825d feature/D2_boundary_opt
Add periodic D1 and D2 operators for orders 8,10,12
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 13 May 2022 13:28:10 +0200 |
parents | b19e142fcae1 |
children |
rev | line source |
---|---|
324
c0cbffcf6513
Created new operator class for lonely D4 operators. Removed some output parameters of implementations.
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
1 function [H, HI, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = d4_variable_4_min_boundary_points(m,h) |
312 | 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 %%% 4:de ordn. SBP Finita differens %%% | |
4 %%% operatorer framtagna av Mark Carpenter %%% | |
5 %%% %%% | |
6 %%% H (Normen) %%% | |
7 %%% D1=H^(-1)Q (approx f?rsta derivatan) %%% | |
8 %%% D2 (approx andra derivatan) %%% | |
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
10 %H?r med endast 4 randpunkter | |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
11 |
249
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
12 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
13 BP = 4; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
14 if(m<2*BP) |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
15 error(['Operator requires at least ' num2str(2*BP) ' grid points']); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
16 end |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
17 |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
18 |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
19 % Norm |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
20 Hv = ones(m,1); |
312 | 21 Hv(1:4) = [17/48 59/48 43/48 49/48]; |
22 Hv(m-3:m) = rot90(Hv(1:4),2); | |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
23 Hv = h*Hv; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
24 H = spdiag(Hv, 0); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
25 HI = spdiag(1./Hv, 0); |
249
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
26 |
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
27 |
312 | 28 % Boundary operators |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
29 e_l = sparse(m,1); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
30 e_l(1) = 1; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
31 e_r = rot90(e_l, 2); |
249
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
32 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
33 d1_l = sparse(m,1); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
34 d1_l(1:4) = 1/h*[-11/6 3 -3/2 1/3]; |
326
b19e142fcae1
Fixed bug in setting of boundary derivative.
Jonatan Werpers <jonatan@werpers.com>
parents:
325
diff
changeset
|
35 d1_r = -rot90(d1_l, 2); |
249
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
36 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
37 d2_l = sparse(m,1); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
38 d2_l(1:4) = 1/h^2*[2 -5 4 -1]; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
39 d2_r = rot90(d2_l, 2); |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
40 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
41 d3_l = sparse(m,1); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
42 d3_l(1:4) = 1/h^3*[-1 3 -3 1]; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
43 d3_r = -rot90(d3_l, 2); |
249
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
44 |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
45 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
46 % First derivative |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
47 stencil = [1/12 -2/3 0 2/3 -1/12]; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
48 diags = [-1 0 1]; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
49 |
312 | 50 Q_U = [ |
51 0 0.59e2/0.96e2 -0.1e1/0.12e2 -0.1e1/0.32e2; | |
52 -0.59e2/0.96e2 0 0.59e2/0.96e2 0; | |
53 0.1e1/0.12e2 -0.59e2/0.96e2 0 0.59e2/0.96e2; | |
54 0.1e1/0.32e2 0 -0.59e2/0.96e2 0; | |
249
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
55 ]; |
02423f9323c6
Started modifying operator files.
Jonatan Werpers <jonatan@werpers.com>
parents:
246
diff
changeset
|
56 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
57 Q = stripeMatrix(stencil, diags, m); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
58 Q(1:4,1:4)=Q_U; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
59 Q(m-3:m,m-3:m) = -rot90(Q_U, 2); |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
60 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
61 D1 = HI*(Q - 1/2*e_l*e_l' + 1/2*e_r*e_r'); |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
62 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
63 % Fourth derivative |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
64 stencil = [-1/6, 2, -13/2, 28/3, -13/2, 2, -1/6]; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
65 diags = -3:3; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
66 M4 = stripeMatrix(stencil, diags, m); |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
67 |
312 | 68 M4_U=[ |
69 0.8e1/0.3e1 -0.37e2/0.6e1 0.13e2/0.3e1 -0.5e1/0.6e1; | |
70 -0.37e2/0.6e1 0.47e2/0.3e1 -13 0.11e2/0.3e1; | |
71 0.13e2/0.3e1 -13 0.44e2/0.3e1 -0.47e2/0.6e1; | |
72 -0.5e1/0.6e1 0.11e2/0.3e1 -0.47e2/0.6e1 0.29e2/0.3e1; | |
73 ]; | |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
74 |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
75 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
76 M4(1:4,1:4) = M4_U; |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
77 M4(m-3:m,m-3:m) = rot90(M4_U, 2); |
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
78 M4 = 1/h^3*M4; |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
79 |
318
99005a80b4c2
Cleaned up d4_variable_4_min_boundary. Removed incorrect D2s from a bunch of files.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
80 D4=HI*(M4 - e_l*d3_l'+e_r*d3_r' + d1_l*d2_l'-d1_r*d2_r'); |
312 | 81 end |