Mercurial > repos > public > sbplib
annotate +sbp/D2VariableCompatibleHollow.m @ 1303:49e3870335ef feature/poroelastic
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Sat, 11 Jul 2020 06:54:15 -0700 |
parents | |
children | b5907140c069 |
rev | line source |
---|---|
1303
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
1 classdef D2VariableCompatibleHollow < sbp.OpSet |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
2 properties |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
3 D1 % SBP operator approximating first derivative |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
4 H % Norm matrix |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
5 HI % H^-1 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
6 Q % Skew-symmetric matrix |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
7 e_l % Left boundary operator |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
8 e_r % Right boundary operator |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
9 D2 % SBP operator for second derivative |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
10 M % Norm matrix, second derivative |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
11 d1_l % Left boundary first derivative |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
12 d1_r % Right boundary first derivative |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
13 m % Number of grid points. |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
14 h % Step size |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
15 x % grid |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
16 borrowing % Struct with borrowing limits for different norm matrices |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
17 end |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
18 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
19 methods |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
20 function obj = D2VariableCompatibleHollow(m,lim,order) |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
21 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
22 x_l = lim{1}; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
23 x_r = lim{2}; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
24 L = x_r-x_l; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
25 obj.h = L/(m-1); |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
26 obj.x = linspace(x_l,x_r,m)'; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
27 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
28 switch order |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
29 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
30 case 6 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
31 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
32 [obj.H, obj.HI, obj.D1, D2, ... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
33 ~, obj.e_l, obj.e_r, ~, ~, ~, ~, ~,... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
34 d1_l, d1_r] = ... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
35 sbp.implementations.d4_variable_hollow_6(m, obj.h); |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 case 4 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 [obj.H, obj.HI, obj.D1, D2, obj.e_l,... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 obj.e_r, d1_l, d1_r] = ... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
40 sbp.implementations.d2_variable_hollow_4(m,obj.h); |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
41 case 2 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
42 [obj.H, obj.HI, obj.D1, D2, obj.e_l,... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 obj.e_r, d1_l, d1_r] = ... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
44 sbp.implementations.d2_variable_hollow_2(m,obj.h); |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
45 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
46 otherwise |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
47 error('Invalid operator order %d.',order); |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
48 end |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
49 obj.borrowing.H11 = obj.H(1,1)/obj.h; % First element in H/h, |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
50 obj.borrowing.M.d1 = obj.H(1,1)/obj.h; % First element in H/h is borrowing also for M |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
51 obj.borrowing.R.delta_D = inf; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
52 obj.m = m; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
53 obj.M = []; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
54 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
55 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
56 D1 = obj.D1; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
57 e_r = obj.e_r; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 e_l = obj.e_l; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
60 % D2 = Hinv * (-M + br*er*d1r^T - bl*el*d1l^T); |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
61 % Replace d1' by e'*D1 in D2. |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
62 D2_compatible = @(b) D2(b) - obj.HI*(b(m)*e_r*d1_r' - b(m)*e_r*e_r'*D1) ... |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
63 + obj.HI*(b(1)*e_l*d1_l' - b(1)*e_l*e_l'*D1); |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
64 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
65 obj.D2 = D2_compatible; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
66 obj.d1_l = (e_l'*D1)'; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
67 obj.d1_r = (e_r'*D1)'; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
68 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
69 end |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
70 function str = string(obj) |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
71 str = [class(obj) '_' num2str(obj.order)]; |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
72 end |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
73 end |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
74 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
75 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
76 end |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
77 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
78 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
79 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
80 |
49e3870335ef
Make the hollow scheme generation more efficient by introducing the D2VariableHollow opSet
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
81 |