Mercurial > repos > public > sbplib
comparison +sbp/D1Staggered.m @ 636:476b7e411ce3 feature/d1_staggered
Add staggered operators
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 07 Nov 2017 20:44:13 -0800 |
parents | |
children | eead18a8964d |
comparison
equal
deleted
inserted
replaced
635:bb1180becc30 | 636:476b7e411ce3 |
---|---|
1 classdef D1Staggered < sbp.OpSet | |
2 properties | |
3 % xp: "plus" grid with m points | |
4 % xm: "minus" grid with m+1 points | |
5 | |
6 D1p % SBP operator approximating first derivative | |
7 D1m % SBP operator approximating first derivative | |
8 Hp % Norm matrix | |
9 Hm % Norm matrix | |
10 HpI % H^-1 | |
11 HmI % H^-1 | |
12 ep_l % Left boundary operator | |
13 em_l % Left boundary operator | |
14 ep_r % Right boundary operator | |
15 em_r % Right boundary operator | |
16 m % Number of grid points. | |
17 mp % Number of grid points. | |
18 mm % Number of grid points. | |
19 h % Step size | |
20 xp % grid | |
21 xm % grid | |
22 x | |
23 borrowing % Struct with borrowing limits for different norm matrices | |
24 end | |
25 | |
26 methods | |
27 function obj = D1Staggered(m,lim,order) | |
28 | |
29 x_l = lim{1}; | |
30 x_r = lim{2}; | |
31 L = x_r-x_l; | |
32 | |
33 mp = m; | |
34 mm = m+1; | |
35 | |
36 switch order | |
37 case 2 | |
38 [xp, xm, Pp, Pm, Qp, Qm] = sbp.implementations.d1_staggered_2(m, L); | |
39 case 4 | |
40 [xp, xm, Pp, Pm, Qp, Qm] = sbp.implementations.d1_staggered_4(m, L); | |
41 case 6 | |
42 [xp, xm, Pp, Pm, Qp, Qm] = sbp.implementations.d1_staggered_6(m, L); | |
43 otherwise | |
44 error('Invalid operator order %d.',order); | |
45 end | |
46 | |
47 obj.m = m; | |
48 obj.mp = mp; | |
49 obj.mm = mm; | |
50 obj.xp = x_l + xp'; | |
51 obj.xm = x_l + xm'; | |
52 | |
53 D1p = Pp\Qp; | |
54 D1m = Pm\Qm; | |
55 | |
56 obj.D1p = D1p; | |
57 obj.D1m = D1m; | |
58 pbj.Hp = Pp; | |
59 obj.Hm = Pm; | |
60 | |
61 obj.ep_l = sparse(mp,1); | |
62 obj.ep_r = sparse(mp,1); | |
63 obj.ep_l(1) = 1; | |
64 obj.ep_r(mp) = 1; | |
65 | |
66 obj.em_l = sparse(mm,1); | |
67 obj.em_r = sparse(mm,1); | |
68 obj.em_l(1) = 1; | |
69 obj.em_r(mm) = 1; | |
70 | |
71 obj.HpI = inv(obj.Hp); | |
72 obj.HmI = inv(obj.Hm); | |
73 | |
74 obj.borrowing = []; | |
75 obj.x = []; | |
76 | |
77 end | |
78 | |
79 function str = string(obj) | |
80 str = [class(obj) '_' num2str(obj.order)]; | |
81 end | |
82 end | |
83 end |