Mercurial > repos > public > sbplib
annotate +scheme/LaplaceCurvilinearNew.m @ 1302:a0d615bde7f8 feature/poroelastic
Add the hollow option to the anisotropic diffops
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Fri, 10 Jul 2020 20:24:23 -0700 |
parents | 5c5815af4b7a |
children |
rev | line source |
---|---|
1212
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
1 classdef LaplaceCurvilinearNew < scheme.Scheme |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
2 properties |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
3 m % Number of points in each direction, possibly a vector |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
4 h % Grid spacing |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
5 dim % Number of spatial dimensions |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
6 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
7 grid |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
8 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
9 order % Order of accuracy for the approximation |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
10 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
11 a,b % Parameters of the operator |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
12 weight % Parameter in front of time derivative (e.g. u_tt in wave equation) here: 1/a. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
13 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
14 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
15 % Inner products and operators for physical coordinates |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
16 D % Laplace operator |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
17 H, Hi % Inner product |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
18 e_w, e_e, e_s, e_n |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
19 d_w, d_e, d_s, d_n % Normal derivatives at the boundary |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
20 H_w, H_e, H_s, H_n % Boundary inner products |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
21 Dx, Dy % Physical derivatives |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
22 M % Gradient inner product |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
23 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
24 % Metric coefficients |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
25 J, Ji |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
26 a11, a12, a22 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
27 K |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
28 x_u |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
29 x_v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
30 y_u |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
31 y_v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
32 s_w, s_e, s_s, s_n % Boundary integral scale factors |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
33 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
34 % Inner product and operators for logical coordinates |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
35 H_u, H_v % Norms in the x and y directions |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 Hi_u, Hi_v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 Hu,Hv % Kroneckerd norms. 1'*Hx*v corresponds to integration in the x dir. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 Hiu, Hiv |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 du_w, dv_w |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
40 du_e, dv_e |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
41 du_s, dv_s |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
42 du_n, dv_n |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
44 % Borrowing constants |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
45 theta_M_u, theta_M_v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
46 theta_R_u, theta_R_v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
47 theta_H_u, theta_H_v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
48 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
49 % Temporary, only used for nonconforming interfaces but should be removed. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
50 lambda |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
51 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
52 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
53 methods |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
54 % Implements a*div(b*grad(u)) as a SBP scheme |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
55 % TODO: Implement proper H, it should be the real physical quadrature, the logic quadrature may be but in a separate variable (H_logic?) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
56 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
57 function obj = LaplaceCurvilinearNew(g, order, a, b, opSet) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 default_arg('opSet',@sbp.D2Variable); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 default_arg('a', 1); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
60 default_arg('b', @(x,y) 0*x + 1); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
61 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
62 % assert(isa(g, 'grid.Curvilinear')) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
63 if isa(a, 'function_handle') |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
64 a = grid.evalOn(g, a); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
65 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
66 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
67 % If a is scalar |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
68 if length(a) == 1 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
69 a = a*ones(g.N(), 1); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
70 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
71 a = spdiag(a); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
72 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
73 if isa(b, 'function_handle') |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
74 b = grid.evalOn(g, b); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
75 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
76 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
77 % If b is scalar |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
78 if length(b) == 1 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
79 % b = b*speye(g.N(), g.N()); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
80 b = b*ones(g.N(), 1); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
81 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
82 b = spdiag(b); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
83 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
84 dim = 2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
85 m = g.size(); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
86 m_u = m(1); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
87 m_v = m(2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
88 m_tot = g.N(); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
89 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
90 % 1D operators |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
91 ops_u = opSet(m_u, {0, 1}, order); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
92 ops_v = opSet(m_v, {0, 1}, order); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
93 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
94 h_u = ops_u.h; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
95 h_v = ops_v.h; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
96 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
97 I_u = speye(m_u); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
98 I_v = speye(m_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
99 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
100 D1_u = ops_u.D1; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
101 D2_u = ops_u.D2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
102 H_u = ops_u.H; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
103 Hi_u = ops_u.HI; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
104 e_l_u = ops_u.e_l; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
105 e_r_u = ops_u.e_r; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
106 d1_l_u = ops_u.d1_l; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
107 d1_r_u = ops_u.d1_r; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
108 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
109 D1_v = ops_v.D1; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
110 D2_v = ops_v.D2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
111 H_v = ops_v.H; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
112 Hi_v = ops_v.HI; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
113 e_l_v = ops_v.e_l; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
114 e_r_v = ops_v.e_r; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
115 d1_l_v = ops_v.d1_l; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
116 d1_r_v = ops_v.d1_r; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
117 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
118 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
119 % Logical operators |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
120 Du = kr(D1_u,I_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
121 Dv = kr(I_u,D1_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
122 obj.Hu = kr(H_u,I_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
123 obj.Hv = kr(I_u,H_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
124 obj.Hiu = kr(Hi_u,I_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
125 obj.Hiv = kr(I_u,Hi_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
126 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
127 e_w = kr(e_l_u,I_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
128 e_e = kr(e_r_u,I_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
129 e_s = kr(I_u,e_l_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
130 e_n = kr(I_u,e_r_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
131 obj.du_w = kr(d1_l_u,I_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
132 obj.dv_w = (e_w'*Dv)'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
133 obj.du_e = kr(d1_r_u,I_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
134 obj.dv_e = (e_e'*Dv)'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
135 obj.du_s = (e_s'*Du)'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
136 obj.dv_s = kr(I_u,d1_l_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
137 obj.du_n = (e_n'*Du)'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
138 obj.dv_n = kr(I_u,d1_r_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
139 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
140 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
141 % Metric coefficients |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
142 coords = g.points(); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
143 x = coords(:,1); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
144 y = coords(:,2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
145 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
146 x_u = Du*x; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
147 x_v = Dv*x; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
148 y_u = Du*y; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
149 y_v = Dv*y; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
150 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
151 J = x_u.*y_v - x_v.*y_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
152 a11 = 1./J .* (x_v.^2 + y_v.^2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
153 a12 = -1./J .* (x_u.*x_v + y_u.*y_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
154 a22 = 1./J .* (x_u.^2 + y_u.^2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
155 lambda = 1/2 * (a11 + a22 - sqrt((a11-a22).^2 + 4*a12.^2)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
156 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
157 K = cell(dim, dim); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
158 K{1,1} = spdiag(y_v./J); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
159 K{1,2} = spdiag(-y_u./J); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
160 K{2,1} = spdiag(-x_v./J); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
161 K{2,2} = spdiag(x_u./J); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
162 obj.K = K; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
163 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
164 obj.x_u = x_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
165 obj.x_v = x_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
166 obj.y_u = y_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
167 obj.y_v = y_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
168 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
169 % Assemble full operators |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
170 L_12 = spdiag(a12); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
171 Duv = Du*b*L_12*Dv; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
172 Dvu = Dv*b*L_12*Du; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
173 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
174 Duu = sparse(m_tot); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
175 Dvv = sparse(m_tot); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
176 ind = grid.funcToMatrix(g, 1:m_tot); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
177 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
178 for i = 1:m_v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
179 b_a11 = b*a11; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
180 D = D2_u(b_a11(ind(:,i))); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
181 p = ind(:,i); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
182 Duu(p,p) = D; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
183 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
184 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
185 for i = 1:m_u |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
186 b_a22 = b*a22; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
187 D = D2_v(b_a22(ind(i,:))); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
188 p = ind(i,:); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
189 Dvv(p,p) = D; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
190 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
191 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
192 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
193 % Physical operators |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
194 obj.J = spdiag(J); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
195 obj.Ji = spdiag(1./J); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
196 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
197 obj.D = obj.Ji*a*(Duu + Duv + Dvu + Dvv); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
198 obj.H = obj.J*kr(H_u,H_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
199 obj.Hi = obj.Ji*kr(Hi_u,Hi_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
200 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
201 obj.e_w = e_w; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
202 obj.e_e = e_e; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
203 obj.e_s = e_s; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
204 obj.e_n = e_n; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
205 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
206 %% normal derivatives |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
207 I_w = ind(1,:); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
208 I_e = ind(end,:); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
209 I_s = ind(:,1); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
210 I_n = ind(:,end); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
211 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
212 a11_w = spdiag(a11(I_w)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
213 a12_w = spdiag(a12(I_w)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
214 a11_e = spdiag(a11(I_e)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
215 a12_e = spdiag(a12(I_e)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
216 a22_s = spdiag(a22(I_s)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
217 a12_s = spdiag(a12(I_s)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
218 a22_n = spdiag(a22(I_n)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
219 a12_n = spdiag(a12(I_n)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
220 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
221 s_w = sqrt((e_w'*x_v).^2 + (e_w'*y_v).^2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
222 s_e = sqrt((e_e'*x_v).^2 + (e_e'*y_v).^2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
223 s_s = sqrt((e_s'*x_u).^2 + (e_s'*y_u).^2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
224 s_n = sqrt((e_n'*x_u).^2 + (e_n'*y_u).^2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
225 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
226 obj.d_w = -1*(spdiag(1./s_w)*(a11_w*obj.du_w' + a12_w*obj.dv_w'))'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
227 obj.d_e = (spdiag(1./s_e)*(a11_e*obj.du_e' + a12_e*obj.dv_e'))'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
228 obj.d_s = -1*(spdiag(1./s_s)*(a22_s*obj.dv_s' + a12_s*obj.du_s'))'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
229 obj.d_n = (spdiag(1./s_n)*(a22_n*obj.dv_n' + a12_n*obj.du_n'))'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
230 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
231 obj.Dx = spdiag( y_v./J)*Du + spdiag(-y_u./J)*Dv; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
232 obj.Dy = spdiag(-x_v./J)*Du + spdiag( x_u./J)*Dv; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
233 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
234 %% Boundary inner products |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
235 obj.H_w = H_v*spdiag(s_w); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
236 obj.H_e = H_v*spdiag(s_e); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
237 obj.H_s = H_u*spdiag(s_s); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
238 obj.H_n = H_u*spdiag(s_n); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
239 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
240 % Misc. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
241 obj.m = m; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
242 obj.h = [h_u h_v]; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
243 obj.order = order; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
244 obj.grid = g; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
245 obj.dim = dim; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
246 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
247 obj.a = a; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
248 obj.weight = inv(a); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
249 obj.b = b; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
250 obj.a11 = a11; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
251 obj.a12 = a12; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
252 obj.a22 = a22; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
253 obj.s_w = spdiag(s_w); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
254 obj.s_e = spdiag(s_e); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
255 obj.s_s = spdiag(s_s); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
256 obj.s_n = spdiag(s_n); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
257 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
258 obj.theta_M_u = h_u*ops_u.borrowing.M.d1; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
259 obj.theta_M_v = h_v*ops_v.borrowing.M.d1; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
260 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
261 obj.theta_R_u = h_u*ops_u.borrowing.R.delta_D; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
262 obj.theta_R_v = h_v*ops_v.borrowing.R.delta_D; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
263 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
264 obj.theta_H_u = h_u*ops_u.borrowing.H11; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
265 obj.theta_H_v = h_v*ops_v.borrowing.H11; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
266 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
267 % Temporary |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
268 obj.lambda = lambda; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
269 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
270 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
271 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
272 % Closure functions return the opertors applied to the own doamin to close the boundary |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
273 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
274 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
275 % type is a string specifying the type of boundary condition if there are several. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
276 % data is a function returning the data that should be applied at the boundary. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
277 % neighbour_scheme is an instance of Scheme that should be interfaced to. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
278 % neighbour_boundary is a string specifying which boundary to interface to. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
279 function [closure, penalty] = boundary_condition(obj, boundary, type, parameter) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
280 default_arg('type','neumann'); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
281 default_arg('parameter', []); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
282 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
283 e = obj.getBoundaryOperator('e', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
284 d = obj.getBoundaryOperator('d', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
285 H_b = obj.getBoundaryQuadrature(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
286 s_b = obj.getBoundaryScaling(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
287 [th_H, ~, th_R] = obj.getBoundaryBorrowing(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
288 m = obj.getBoundaryNumber(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
289 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
290 K = obj.K; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
291 J = obj.J; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
292 Hi = obj.Hi; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
293 a = obj.a; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
294 b_b = e'*obj.b*e; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
295 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
296 switch type |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
297 % Dirichlet boundary condition |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
298 case {'D','d','dirichlet'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
299 tuning = 1.0; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
300 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
301 sigma = 0*b_b; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
302 for i = 1:obj.dim |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
303 sigma = sigma + e'*J*K{i,m}*K{i,m}*e; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
304 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
305 sigma = sigma/s_b; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
306 tau = tuning*(1/th_R + obj.dim/th_H)*sigma; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
307 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
308 closure = a*Hi*d*b_b*H_b*e' ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
309 -a*Hi*e*tau*b_b*H_b*e'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
310 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
311 penalty = -a*Hi*d*b_b*H_b ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
312 +a*Hi*e*tau*b_b*H_b; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
313 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
314 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
315 % Neumann boundary condition. Note that the penalty is for du/dn and not b*du/dn. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
316 case {'N','n','neumann'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
317 tau1 = -1; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
318 tau2 = 0; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
319 tau = (tau1*e + tau2*d)*H_b; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
320 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
321 closure = a*Hi*tau*b_b*d'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
322 penalty = -a*Hi*tau*b_b; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
323 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
324 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
325 % Unknown, boundary condition |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
326 otherwise |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
327 error('No such boundary condition: type = %s',type); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
328 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
329 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
330 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
331 % type Struct that specifies the interface coupling. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
332 % Fields: |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
333 % -- tuning: penalty strength, defaults to 1.2 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
334 % -- interpolation: type of interpolation, default 'none' |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
335 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
336 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
337 defaultType.coupling = 'sat'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
338 defaultType.tuning = 1.0; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
339 defaultType.interpolation = 'none'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
340 default_struct('type', defaultType); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
341 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
342 switch type.coupling |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
343 case {'cg', 'CG'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
344 [closure, penalty] = interfaceCG(obj,boundary,neighbour_scheme,neighbour_boundary,type); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
345 case {'sat', 'SAT'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
346 switch type.interpolation |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
347 case {'none', ''} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
348 [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
349 case {'op','OP'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
350 [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
351 otherwise |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
352 error('Unknown type of interpolation: %s ', type.interpolation); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
353 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
354 otherwise |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
355 error('Unknown type of coupling: %s ', type.coupling); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
356 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
357 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
358 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
359 function [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
360 tuning = type.tuning; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
361 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
362 dim = obj.dim; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
363 % u denotes the solution in the own domain |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
364 % v denotes the solution in the neighbour domain |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
365 u = obj; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
366 v = neighbour_scheme; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
367 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
368 % Boundary operators, u |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
369 e_u = u.getBoundaryOperator('e', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
370 d_u = u.getBoundaryOperator('d', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
371 s_b_u = u.getBoundaryScaling(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
372 [th_H_u, ~, th_R_u] = u.getBoundaryBorrowing(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
373 m_u = u.getBoundaryNumber(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
374 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
375 % Coefficients, u |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
376 K_u = u.K; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
377 J_u = u.J; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
378 b_b_u = e_u'*u.b*e_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
379 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
380 % Boundary operators, v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
381 e_v = v.getBoundaryOperator('e', neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
382 d_v = v.getBoundaryOperator('d', neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
383 s_b_v = v.getBoundaryScaling(neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
384 [th_H_v, ~, th_R_v] = v.getBoundaryBorrowing(neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
385 m_v = v.getBoundaryNumber(neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
386 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
387 % BUGFIX?!?!? |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
388 if (strcmp(boundary,'s') && strcmp(neighbour_boundary,'e')) || (strcmp(boundary,'e') && strcmp(neighbour_boundary,'s')) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
389 e_v = fliplr(e_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
390 d_v = fliplr(d_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
391 s_b_v = rot90(s_b_v,2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
392 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
393 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
394 % Coefficients, v |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
395 K_v = v.K; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
396 J_v = v.J; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
397 b_b_v = e_v'*v.b*e_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
398 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
399 %--- Penalty strength tau ------------- |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
400 sigma_u = 0*b_b_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
401 sigma_v = 0*b_b_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
402 for i = 1:obj.dim |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
403 sigma_u = sigma_u + e_u'*J_u*K_u{i,m_u}*K_u{i,m_u}*e_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
404 sigma_v = sigma_v + e_v'*J_v*K_v{i,m_v}*K_v{i,m_v}*e_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
405 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
406 sigma_u = sigma_u/s_b_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
407 sigma_v = sigma_v/s_b_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
408 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
409 tau_R_u = 1/th_R_u*sigma_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
410 tau_R_v = 1/th_R_v*sigma_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
411 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
412 tau_H_u = dim*1/th_H_u*sigma_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
413 tau_H_v = dim*1/th_H_v*sigma_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
414 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
415 tau = 1/4*tuning*(b_b_u*(tau_R_u + tau_H_u) + b_b_v*(tau_R_v + tau_H_v)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
416 %-------------------------------------- |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
417 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
418 % Operators/coefficients that are only required from this side |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
419 Hi = u.Hi; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
420 H_b = u.getBoundaryQuadrature(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
421 a = u.a; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
422 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
423 closure = 1/2*a*Hi*d_u*b_b_u*H_b*e_u' ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
424 -1/2*a*Hi*e_u*H_b*b_b_u*d_u' ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
425 -a*Hi*e_u*tau*H_b*e_u'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
426 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
427 penalty = -1/2*a*Hi*d_u*b_b_u*H_b*e_v' ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
428 -1/2*a*Hi*e_u*H_b*b_b_v*d_v' ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
429 +a*Hi*e_u*tau*H_b*e_v'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
430 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
431 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
432 function [closure, penalty] = interfaceCG(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
433 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
434 % There is no penalty, only a closure. And the closure is the same as for Neumann BC |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
435 e = obj.getBoundaryOperator('e', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
436 d = obj.getBoundaryOperator('d', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
437 H_b = obj.getBoundaryQuadrature(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
438 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
439 e_v = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
440 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
441 Hi = obj.Hi; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
442 a = obj.a; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
443 b_b = e'*obj.b*e; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
444 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
445 tau1 = -1; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
446 tau2 = 0; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
447 tau = (tau1*e + tau2*d)*H_b; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
448 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
449 closure = a*Hi*tau*b_b*d'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
450 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
451 % Zero penalty of correct dimensions |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
452 penalty = 0*e*e_v'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
453 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
454 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
455 function [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
456 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
457 % TODO: Make this work for curvilinear grids |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
458 warning('LaplaceCurvilinear: Non-conforming grid interpolation only works for Cartesian grids.'); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
459 warning('LaplaceCurvilinear: Non-conforming interface uses Virtas penalty strength'); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
460 warning('LaplaceCurvilinear: Non-conforming interface assumes that b is constant'); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
461 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
462 % User can request special interpolation operators by specifying type.interpOpSet |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
463 default_field(type, 'interpOpSet', @sbp.InterpOpsOP); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
464 interpOpSet = type.interpOpSet; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
465 tuning = type.tuning; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
466 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
467 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
468 % u denotes the solution in the own domain |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
469 % v denotes the solution in the neighbour domain |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
470 e_u = obj.getBoundaryOperator('e', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
471 d_u = obj.getBoundaryOperator('d', boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
472 H_b_u = obj.getBoundaryQuadrature(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
473 I_u = obj.getBoundaryIndices(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
474 [~, gamm_u] = obj.getBoundaryBorrowing(boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
475 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
476 e_v = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
477 d_v = neighbour_scheme.getBoundaryOperator('d', neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
478 H_b_v = neighbour_scheme.getBoundaryQuadrature(neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
479 I_v = neighbour_scheme.getBoundaryIndices(neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
480 [~, gamm_v] = neighbour_scheme.getBoundaryBorrowing(neighbour_boundary); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
481 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
482 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
483 % Find the number of grid points along the interface |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
484 m_u = size(e_u, 2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
485 m_v = size(e_v, 2); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
486 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
487 Hi = obj.Hi; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
488 a = obj.a; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
489 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
490 u = obj; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
491 v = neighbour_scheme; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
492 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
493 b1_u = gamm_u*u.lambda(I_u)./u.a11(I_u).^2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
494 b2_u = gamm_u*u.lambda(I_u)./u.a22(I_u).^2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
495 b1_v = gamm_v*v.lambda(I_v)./v.a11(I_v).^2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
496 b2_v = gamm_v*v.lambda(I_v)./v.a22(I_v).^2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
497 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
498 tau_u = -1./(4*b1_u) -1./(4*b2_u); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
499 tau_v = -1./(4*b1_v) -1./(4*b2_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
500 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
501 tau_u = tuning * spdiag(tau_u); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
502 tau_v = tuning * spdiag(tau_v); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
503 beta_u = tau_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
504 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
505 % Build interpolation operators |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
506 intOps = interpOpSet(m_u, m_v, obj.order, neighbour_scheme.order); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
507 Iu2v = intOps.Iu2v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
508 Iv2u = intOps.Iv2u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
509 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
510 closure = a*Hi*e_u*tau_u*H_b_u*e_u' + ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
511 a*Hi*e_u*H_b_u*Iv2u.bad*beta_u*Iu2v.good*e_u' + ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
512 a*1/2*Hi*d_u*H_b_u*e_u' + ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
513 -a*1/2*Hi*e_u*H_b_u*d_u'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
514 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
515 penalty = -a*Hi*e_u*tau_u*H_b_u*Iv2u.good*e_v' + ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
516 -a*Hi*e_u*H_b_u*Iv2u.bad*beta_u*e_v' + ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
517 -a*1/2*Hi*d_u*H_b_u*Iv2u.good*e_v' + ... |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
518 -a*1/2*Hi*e_u*H_b_u*Iv2u.bad*d_v'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
519 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
520 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
521 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
522 % Returns the boundary operator op for the boundary specified by the string boundary. |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
523 % op -- string |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
524 % boundary -- string |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
525 function o = getBoundaryOperator(obj, op, boundary) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
526 assertIsMember(op, {'e', 'd'}) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
527 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
528 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
529 o = obj.([op, '_', boundary]); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
530 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
531 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
532 % Returns square boundary quadrature matrix, of dimension |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
533 % corresponding to the number of boundary points |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
534 % |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
535 % boundary -- string |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
536 function H_b = getBoundaryQuadrature(obj, boundary) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
537 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
538 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
539 H_b = obj.(['H_', boundary]); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
540 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
541 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
542 % Returns square boundary quadrature scaling matrix, of dimension |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
543 % corresponding to the number of boundary points |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
544 % |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
545 % boundary -- string |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
546 function s_b = getBoundaryScaling(obj, boundary) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
547 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
548 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
549 s_b = obj.(['s_', boundary]); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
550 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
551 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
552 % Returns the coordinate number corresponding to the boundary |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
553 % |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
554 % boundary -- string |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
555 function m = getBoundaryNumber(obj, boundary) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
556 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
557 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
558 switch boundary |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
559 case {'w', 'e'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
560 m = 1; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
561 case {'s', 'n'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
562 m = 2; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
563 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
564 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
565 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
566 % Returns the indices of the boundary points in the grid matrix |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
567 % boundary -- string |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
568 function I = getBoundaryIndices(obj, boundary) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
569 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
570 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
571 ind = grid.funcToMatrix(obj.grid, 1:prod(obj.m)); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
572 switch boundary |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
573 case 'w' |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
574 I = ind(1,:); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
575 case 'e' |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
576 I = ind(end,:); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
577 case 's' |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
578 I = ind(:,1)'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
579 case 'n' |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
580 I = ind(:,end)'; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
581 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
582 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
583 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
584 % Returns borrowing constant gamma |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
585 % boundary -- string |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
586 function [theta_H, theta_M, theta_R] = getBoundaryBorrowing(obj, boundary) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
587 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
588 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
589 switch boundary |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
590 case {'w','e'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
591 theta_H = obj.theta_H_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
592 theta_M = obj.theta_M_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
593 theta_R = obj.theta_R_u; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
594 case {'s','n'} |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
595 theta_H = obj.theta_H_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
596 theta_M = obj.theta_M_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
597 theta_R = obj.theta_R_v; |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
598 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
599 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
600 |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
601 function N = size(obj) |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
602 N = prod(obj.m); |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
603 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
604 end |
5c5815af4b7a
Add new implementation of Laplace curvilinear
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
605 end |