Mercurial > repos > public > sbplib
comparison +sbp/D1UpwindCompatible.m @ 1269:5fa2f62a58a1 feature/poroelastic
Add class for upwind D1 based on the standard norm matrices
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Sun, 31 May 2020 20:16:54 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1268:af9e52e97154 | 1269:5fa2f62a58a1 |
---|---|
1 classdef D1UpwindCompatible < sbp.OpSet | |
2 properties | |
3 Dp, Dm % SBP operator approximating first derivative | |
4 H % Norm matrix | |
5 HI % H^-1 | |
6 e_l % Left boundary operator | |
7 e_r % Right boundary operator | |
8 m % Number of grid points. | |
9 h % Step size | |
10 x % grid | |
11 borrowing % Struct with borrowing limits for different norm matrices | |
12 end | |
13 | |
14 methods | |
15 function obj = D1UpwindCompatible(m,lim,order) | |
16 | |
17 x_l = lim{1}; | |
18 x_r = lim{2}; | |
19 L = x_r-x_l; | |
20 obj.h = L/(m-1); | |
21 obj.x = linspace(x_l,x_r,m)'; | |
22 | |
23 ops = sbp.D2Standard(m, lim, order); | |
24 D1 = ops.D1; | |
25 H = ops.H; | |
26 | |
27 obj.H = H; | |
28 obj.HI = inv(H); | |
29 obj.e_l = ops.e_l; | |
30 obj.e_r = ops.e_r; | |
31 | |
32 switch order | |
33 case 2 | |
34 ops = sbp.D2Standard(m, lim, 2); | |
35 Dp = D1 + obj.h^1*1/2*(H\ops.M); | |
36 Dm = D1 - obj.h^1*1/2*(H\ops.M); | |
37 case 4 | |
38 ops = sbp.D4Variable(m, lim, 2); | |
39 Dp = D1 - obj.h^3*1/12*(H\ops.M4); | |
40 Dm = D1 + obj.h^3*1/12*(H\ops.M4); | |
41 otherwise | |
42 error('Invalid operator order %d.',order); | |
43 end | |
44 | |
45 obj.Dp = Dp; | |
46 obj.Dm = Dm; | |
47 | |
48 obj.m = m; | |
49 obj.borrowing = []; | |
50 | |
51 end | |
52 | |
53 function str = string(obj) | |
54 str = [class(obj) '_' num2str(obj.order)]; | |
55 end | |
56 end | |
57 | |
58 | |
59 end | |
60 | |
61 | |
62 | |
63 | |
64 |