annotate +scheme/LaplaceCurvilinearNew.m @ 1065:c2bd7f15da48 feature/laplace_curvilinear_test

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