comparison +sbp/D4Variable.m @ 324:c0cbffcf6513 feature/beams

Created new operator class for lonely D4 operators. Removed some output parameters of implementations.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 26 Sep 2016 09:51:45 +0200
parents 9230c056a574
children 31d6698c1edf
comparison
equal deleted inserted replaced
323:7579c2abbf9f 324:c0cbffcf6513
1 classdef D4CompatibleVariable < sbp.OpSet 1 classdef D4Variable < sbp.OpSet
2 properties 2 properties
3 D1 % SBP operator approximating first derivative 3 D1 % SBP operator approximating first derivative
4 H % Norm matrix 4 H % Norm matrix
5 HI % H^-1 5 HI % H^-1
6 Q % Skew-symmetric matrix 6 Q % Skew-symmetric matrix
7 e_l % Left boundary operator 7 e_l % Left boundary operator
8 e_r % Right boundary operator 8 e_r % Right boundary operator
9 d1_l % Left boundary first derivative
10 d1_r % Right boundary first derivative
11 d2_l % Left boundary second derivative
12 d2_r % Right boundary second derivative
13 d3_l % Left boundary third derivative
14 d3_r % Right boundary third derivative
9 D2 % SBP operator for second derivative 15 D2 % SBP operator for second derivative
10 M % Norm matrix, second derivative 16 M % Norm matrix, second derivative
11 d1_l % Left boundary first derivative
12 d1_r % Right boundary first derivative
13 D3 % SBP operator for third derivative
14 Q3 % Skew-symmetric matrix in third derivative
15 d2_l % Left boundary second derivative
16 d2_r % Right boundary second derivative
17 D4 % SBP operator for fourth derivative 17 D4 % SBP operator for fourth derivative
18 M4 % Norm matrix, fourth derivative 18 M4 % Norm matrix, fourth derivative
19 d3_l % Left boundary third derivative
20 d3_r % Right boundary third derivative
21 m % Number of grid points. 19 m % Number of grid points.
22 h % Step size 20 h % Step size
23 x % grid 21 x % grid
24 borrowing % Struct with borrowing limits for different norm matrices 22 borrowing % Struct with borrowing limits for different norm matrices
25 end 23 end
26 24
27 methods 25 methods
28 function obj = D4CompatibleVariable(m, lim, order, opt) 26 function obj = D4Variable(m, lim, order)
29 default_arg('opt', '')
30
31 x_l = lim{1}; 27 x_l = lim{1};
32 x_r = lim{2}; 28 x_r = lim{2};
33 L = x_r-x_l; 29 L = x_r-x_l;
34 obj.h = L/(m-1); 30 obj.h = L/(m-1);
35 obj.x = linspace(x_l, x_r,m)'; 31 obj.x = linspace(x_l, x_r,m)';
37 if order == 2 33 if order == 2
38 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ... 34 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
39 sbp.implementations.d4_variable_2(m, obj.h); 35 sbp.implementations.d4_variable_2(m, obj.h);
40 obj.borrowing.N.S2 = 1.2500; 36 obj.borrowing.N.S2 = 1.2500;
41 obj.borrowing.N.S3 = 0.4000; 37 obj.borrowing.N.S3 = 0.4000;
42
43 elseif order == 4 38 elseif order == 4
44 switch opt 39 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
45 case 'min_boundary_points' 40 sbp.implementations.d4_variable_4(m, obj.h);
46 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ... 41 obj.borrowing.N.S2 = 0.5055;
47 sbp.implementations.d4_variable_4_min_boundary_points(m, obj.h); 42 obj.borrowing.N.S3 = 0.9290;
48 % obj.borrowing.N.S2 = 0.5055;
49 % obj.borrowing.N.S3 = 0.9290;
50 otherwise
51 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
52 sbp.implementations.d4_variable_4(m, obj.h);
53 obj.borrowing.N.S2 = 0.5055;
54 obj.borrowing.N.S3 = 0.9290;
55 end
56
57 elseif order == 6 43 elseif order == 6
58 switch opt 44 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
59 case '2' 45 sbp.implementations.d4_variable_6(m, obj.h);
60 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ... 46 obj.borrowing.N.S2 = 0.3259;
61 sbp.implementations.d4_variable_6_2(m, obj.h); 47 obj.borrowing.N.S3 = 0.1580;
62 % obj.borrowing.N.S2 = 0.3259;
63 % obj.borrowing.N.S3 = 0.1580;
64 case '3'
65 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
66 sbp.implementations.d4_variable_6_3(m, obj.h);
67 % obj.borrowing.N.S2 = 0.3259;
68 % obj.borrowing.N.S3 = 0.1580;
69 case 'min_boundary_points'
70 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
71 sbp.implementations.d4_variable_6_min_boundary_points(m, obj.h);
72 % obj.borrowing.N.S2 = 0.3259;
73 % obj.borrowing.N.S3 = 0.1580;
74 otherwise
75 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
76 sbp.implementations.d4_variable_6(m, obj.h);
77 obj.borrowing.N.S2 = 0.3259;
78 obj.borrowing.N.S3 = 0.1580;
79 end
80
81 elseif order == 8
82 switch opt
83 case 'min_boundary_points'
84 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
85 sbp.implementations.d4_variable_8_min_boundary_points(m, obj.h);
86 % obj.borrowing.N.S2 = 0.3259;
87 % obj.borrowing.N.S3 = 0.1580;
88 otherwise
89 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ...
90 sbp.implementations.d4_variable_8_higher_boundary_order(m, obj.h);
91 % obj.borrowing.N.S2 = 0.3259;
92 % obj.borrowing.N.S3 = 0.1580;
93 end
94 else 48 else
95 error('Invalid operator order.'); 49 error('Invalid operator order.');
96 end 50 end
97 51
98 obj.m = m; 52 obj.m = m;
99 53
100 obj.H = H; 54 obj.H = H;
101 obj.HI = HI; 55 obj.HI = HI;
56 obj.D1 = D1;
102 obj.D2 = D2; 57 obj.D2 = D2;
103 obj.D4 = D4; 58 obj.D4 = D4;
104 obj.M4 = M4; 59 obj.M4 = M4;
105 obj.e_l = e_l; 60 obj.e_l = e_l;
106 obj.e_r = e_r; 61 obj.e_r = e_r;
108 obj.d1_r = d1_r; 63 obj.d1_r = d1_r;
109 obj.d2_l = d2_l; 64 obj.d2_l = d2_l;
110 obj.d2_r = d2_r; 65 obj.d2_r = d2_r;
111 obj.d3_l = d3_l; 66 obj.d3_l = d3_l;
112 obj.d3_r = d3_r; 67 obj.d3_r = d3_r;
113
114 obj.D1 = [];
115 obj.D3 = [];
116 end 68 end
117 end 69 end
118 end 70 end