Mercurial > repos > public > sbplib
comparison +sbp/D4Variable.m @ 886:8894e9c49e40 feature/timesteppers
Merge with default for latest changes
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 15 Nov 2018 16:36:21 -0800 |
parents | 42c89b5eedc0 |
children |
comparison
equal
deleted
inserted
replaced
816:b5e5b195da1e | 886:8894e9c49e40 |
---|---|
1 classdef D4Variable < sbp.OpSet | |
2 properties | |
3 m % Number of grid points. | |
4 h % Step size | |
5 x % grid | |
6 H % Norm matrix | |
7 HI % H^-1 | |
8 D1 % SBP operator approximating first derivative | |
9 D2 % SBP operator for second derivative | |
10 D4 % SBP operator for fourth derivative | |
11 Q % Skew-symmetric matrix | |
12 M % Norm matrix, second derivative | |
13 M4 % Norm matrix, fourth derivative | |
14 e_l, e_r % Left and right boundary operator | |
15 d1_l, d1_r % Left and right boundary first derivative | |
16 d2_l, d2_r % Left and right boundary second derivative | |
17 d3_l, d3_r % Left and right boundary third derivative | |
18 borrowing % Struct with borrowing limits for different norm matrices | |
19 order | |
20 end | |
21 | |
22 methods | |
23 function obj = D4Variable(m, lim, order) | |
24 x_l = lim{1}; | |
25 x_r = lim{2}; | |
26 L = x_r-x_l; | |
27 obj.h = L/(m-1); | |
28 obj.x = linspace(x_l, x_r,m)'; | |
29 | |
30 if order == 2 | |
31 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ... | |
32 sbp.implementations.d4_variable_2(m, obj.h); | |
33 obj.borrowing.M.d1 = 0.4000; | |
34 obj.borrowing.N.S2 = 1.2500; | |
35 obj.borrowing.N.S3 = 0.4000; | |
36 elseif order == 4 | |
37 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ... | |
38 sbp.implementations.d4_variable_4(m, obj.h); | |
39 obj.borrowing.M.d1 = 0.2508; | |
40 obj.borrowing.N.S2 = 0.5055; | |
41 obj.borrowing.N.S3 = 0.9290; | |
42 elseif order == 6 | |
43 [H, HI, D1, D2, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = ... | |
44 sbp.implementations.d4_variable_6(m, obj.h); | |
45 obj.borrowing.M.d1 = 0.1878; | |
46 obj.borrowing.N.S2 = 0.3259; | |
47 obj.borrowing.N.S3 = 0.1580; | |
48 else | |
49 error('Invalid operator order.'); | |
50 end | |
51 | |
52 obj.m = m; | |
53 obj.order = order; | |
54 | |
55 obj.H = H; | |
56 obj.HI = HI; | |
57 obj.D1 = D1; | |
58 obj.D2 = D2; | |
59 obj.D4 = D4; | |
60 obj.M4 = M4; | |
61 obj.e_l = e_l; | |
62 obj.e_r = e_r; | |
63 obj.d1_l = d1_l; | |
64 obj.d1_r = d1_r; | |
65 obj.d2_l = d2_l; | |
66 obj.d2_r = d2_r; | |
67 obj.d3_l = d3_l; | |
68 obj.d3_r = d3_r; | |
69 end | |
70 | |
71 function str = string(obj) | |
72 str = [class(obj) '_' num2str(obj.order)]; | |
73 end | |
74 end | |
75 end |