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