annotate +scheme/LaplaceCurvilinearNew.m @ 1084:d5290a056049 feature/laplace_curvilinear_test

Fix bug in new implementations that made matrices non-sparse.
author Martin Almquist <malmquist@stanford.edu>
date Wed, 27 Mar 2019 15:56:42 -0700
parents 7a55a72729e6
children 49c0b8c7330a
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
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
48 % Temporary
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
49 lambda
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
50 gamm_u, gamm_v
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
51
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
52 end
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 methods
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
55 % 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
56 % 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
57
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
58 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
59 default_arg('opSet',@sbp.D2Variable);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
60 default_arg('a', 1);
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
61 default_arg('b', @(x,y) 0*x + 1);
1063
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
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
69 if isa(b, 'function_handle')
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
70 b = grid.evalOn(g, b);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
71 b = spdiag(b);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
72 end
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
73
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
74 % If b is scalar
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
75 if length(b) == 1
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
76 b = b*speye(g.N(), g.N());
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
77 end
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
78
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
79 dim = 2;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
80 m = g.size();
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
81 m_u = m(1);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
82 m_v = m(2);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
83 m_tot = g.N();
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
84
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
85 h = g.scaling();
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
86 h_u = h(1);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
87 h_v = h(2);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
88
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
89
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90 % 1D operators
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
91 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
92 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
93
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
94 I_u = speye(m_u);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
95 I_v = speye(m_v);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
96
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
97 D1_u = ops_u.D1;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
98 D2_u = ops_u.D2;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
99 H_u = ops_u.H;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
100 Hi_u = ops_u.HI;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
101 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
102 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
103 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
104 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
105
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
106 D1_v = ops_v.D1;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
107 D2_v = ops_v.D2;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
108 H_v = ops_v.H;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
109 Hi_v = ops_v.HI;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
110 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
111 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
112 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
113 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
114
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
115
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
116 % Logical operators
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
117 Du = kr(D1_u,I_v);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
118 Dv = kr(I_u,D1_v);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
119 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
120 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
121 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
122 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
123
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
124 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
125 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
126 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
127 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
128 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
129 obj.dv_w = (e_w'*Dv)';
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
130 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
131 obj.dv_e = (e_e'*Dv)';
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
132 obj.du_s = (e_s'*Du)';
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
133 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
134 obj.du_n = (e_n'*Du)';
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
135 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
136
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 % Metric coefficients
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
139 coords = g.points();
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
140 x = coords(:,1);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
141 y = coords(:,2);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
142
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 x_u = Du*x;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
144 x_v = Dv*x;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
145 y_u = Du*y;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
146 y_v = Dv*y;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
148 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
149 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
150 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
151 a22 = 1./J .* (x_u.^2 + y_u.^2);
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
152 lambda = 1/2 * (a11 + a22 - sqrt((a11-a22).^2 + 4*a12.^2));
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
153
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
154 K = cell(dim, dim);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
155 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
156 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
157 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
158 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
159 obj.K = K;
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 obj.x_u = x_u;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
162 obj.x_v = x_v;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
163 obj.y_u = y_u;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
164 obj.y_v = y_v;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
165
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
166 % Assemble full operators
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
167 L_12 = spdiag(a12);
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
168 Duv = Du*b*L_12*Dv;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
169 Dvu = Dv*b*L_12*Du;
1063
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 Duu = sparse(m_tot);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
172 Dvv = sparse(m_tot);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
173 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
174
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
175 for i = 1:m_v
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
176 b_a11 = b*a11;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
177 D = D2_u(b_a11(ind(:,i)));
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
178 p = ind(:,i);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
179 Duu(p,p) = D;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
180 end
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 for i = 1:m_u
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
183 b_a22 = b*a22;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
184 D = D2_v(b_a22(ind(i,:)));
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
185 p = ind(i,:);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
186 Dvv(p,p) = D;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
188
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
190 % Physical operators
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
191 obj.J = spdiag(J);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192 obj.Ji = spdiag(1./J);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
193
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194 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
195 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
196 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
197
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198 obj.e_w = e_w;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 obj.e_e = e_e;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
200 obj.e_s = e_s;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 obj.e_n = e_n;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
202
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203 %% normal derivatives
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204 I_w = ind(1,:);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205 I_e = ind(end,:);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
206 I_s = ind(:,1);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
207 I_n = ind(:,end);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
208
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
209 a11_w = spdiag(a11(I_w));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
210 a12_w = spdiag(a12(I_w));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
211 a11_e = spdiag(a11(I_e));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
212 a12_e = spdiag(a12(I_e));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
213 a22_s = spdiag(a22(I_s));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
214 a12_s = spdiag(a12(I_s));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
215 a22_n = spdiag(a22(I_n));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
216 a12_n = spdiag(a12(I_n));
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
217
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
218 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
219 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
220 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
221 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
222
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
223 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
224 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
225 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
226 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
227
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228 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
229 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
230
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
231 %% Boundary inner products
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
232 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
233 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
234 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
235 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
236
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 % Misc.
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
238 obj.m = m;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239 obj.h = [h_u h_v];
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
240 obj.order = order;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
241 obj.grid = g;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
242 obj.dim = dim;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
243
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
244 obj.a = a;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
245 obj.b = b;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
246 obj.a11 = a11;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
247 obj.a12 = a12;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
248 obj.a22 = a22;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
249 obj.s_w = spdiag(s_w);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
250 obj.s_e = spdiag(s_e);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
251 obj.s_s = spdiag(s_s);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
252 obj.s_n = spdiag(s_n);
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 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
255 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
256
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
257 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
258 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
259
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
260 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
261 obj.theta_H_v = h_v*ops_v.borrowing.H11;
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
262
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
263 % Temporary
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
264 obj.lambda = lambda;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
265 obj.gamm_u = h_u*ops_u.borrowing.M.d1;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
266 obj.gamm_v = h_v*ops_v.borrowing.M.d1;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
267 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
268
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
269
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
270 % 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
271 % 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
272 % 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
273 % 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
274 % 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
275 % 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
276 % 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
277 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
278 default_arg('type','neumann');
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
279 default_arg('parameter', []);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
280
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
281 e = obj.getBoundaryOperator('e', boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
282 d = obj.getBoundaryOperator('d', boundary);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
283 H_b = obj.getBoundaryQuadrature(boundary);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
284 s_b = obj.getBoundaryScaling(boundary);
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
285 [th_H, ~, th_R] = obj.getBoundaryBorrowing(boundary);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
286 m = obj.getBoundaryNumber(boundary);
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 K = obj.K;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
289 J = obj.J;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290 Hi = obj.Hi;
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
291 a = obj.a;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
292 b_b = e'*obj.b*e;
1063
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 switch type
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
295 % Dirichlet boundary condition
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
296 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
297 tuning = 1.0;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
298
1084
d5290a056049 Fix bug in new implementations that made matrices non-sparse.
Martin Almquist <malmquist@stanford.edu>
parents: 1069
diff changeset
299 sigma = 0*b_b;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
300 for i = 1:obj.dim
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301 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
302 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
303 sigma = sigma/s_b;
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
304 % tau = tuning*(1/th_R + obj.dim/th_H)*sigma;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
305
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
306 tau_R = 1/th_R*sigma;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
307 tau_H = obj.dim*1/th_H*sigma;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
308
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
309 tau = tuning*(tau_R + tau_H);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
310
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
311 closure = a*Hi*d*b_b*H_b*e' ...
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
312 -a*Hi*e*tau*b_b*H_b*e';
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
313
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
314 penalty = -a*Hi*d*b_b*H_b ...
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
315 +a*Hi*e*tau*b_b*H_b;
1063
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
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
318 % Neumann boundary condition. Note that the penalty is for du/dn and not b*du/dn.
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
319 case {'N','n','neumann'}
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
320 tau1 = -1;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
321 tau2 = 0;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
322 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
323
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
324 closure = a*Hi*tau*b_b*d';
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
325 penalty = -a*Hi*tau*b_b;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
327
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328 % Unknown, boundary condition
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329 otherwise
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
330 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
331 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334 % 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
335 % Fields:
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336 % -- 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
337 % -- interpolation: type of interpolation, default 'none'
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338 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
339
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
340 % error('Not implemented')
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
341
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
342 defaultType.tuning = 1.0;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
343 defaultType.interpolation = 'none';
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344 default_struct('type', defaultType);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 switch type.interpolation
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
347 case {'none', ''}
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348 [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
349 case {'op','OP'}
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 [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
351 otherwise
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
352 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
353 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 end
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 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
357 tuning = type.tuning;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
358
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
359 dim = obj.dim;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
360 % 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
361 % 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
362 u = obj;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363 v = neighbour_scheme;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
364
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
365 % Boundary operators, u
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
366 e_u = u.getBoundaryOperator('e', boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
367 d_u = u.getBoundaryOperator('d', boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
368 gamm_u = u.getBoundaryBorrowing(boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
369 s_b_u = u.getBoundaryScaling(boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
370 [th_H_u, ~, th_R_u] = u.getBoundaryBorrowing(boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
371 m_u = u.getBoundaryNumber(boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
372
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
373 % Coefficients, u
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
374 K_u = u.K;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
375 J_u = u.J;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
376 b_b_u = e_u'*u.b*e_u;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
377
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
378 % Boundary operators, v
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
379 e_v = v.getBoundaryOperator('e', neighbour_boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
380 d_v = v.getBoundaryOperator('d', neighbour_boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
381 gamm_v = v.getBoundaryBorrowing(neighbour_boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
382 s_b_v = v.getBoundaryScaling(neighbour_boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
383 [th_H_v, ~, th_R_v] = v.getBoundaryBorrowing(neighbour_boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
384 m_v = v.getBoundaryNumber(neighbour_boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
385
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
386 % Coefficients, v
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
387 K_v = v.K;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
388 J_v = v.J;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
389 b_b_v = e_v'*v.b*e_v;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
390
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
391 %--- Penalty strength tau -------------
1084
d5290a056049 Fix bug in new implementations that made matrices non-sparse.
Martin Almquist <malmquist@stanford.edu>
parents: 1069
diff changeset
392 sigma_u = 0*b_b_u;
d5290a056049 Fix bug in new implementations that made matrices non-sparse.
Martin Almquist <malmquist@stanford.edu>
parents: 1069
diff changeset
393 sigma_v = 0*b_b_v;
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
394 for i = 1:obj.dim
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
395 sigma_u = sigma_u + e_u'*J_u*K_u{i,m_u}*K_u{i,m_u}*e_u;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
396 sigma_v = sigma_v + e_v'*J_v*K_v{i,m_v}*K_v{i,m_v}*e_v;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
397 end
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
398 sigma_u = sigma_u/s_b_u;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
399 sigma_v = sigma_v/s_b_v;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
400
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
401 tau_R_u = 1/th_R_u*sigma_u;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
402 tau_R_v = 1/th_R_v*sigma_v;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
403
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
404 tau_H_u = dim*1/th_H_u*sigma_u;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
405 tau_H_v = dim*1/th_H_v*sigma_v;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
406
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
407 tau = 1/4*tuning*(b_b_u*(tau_R_u + tau_H_u) + b_b_v*(tau_R_v + tau_H_v));
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
408 %--------------------------------------
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
409
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
410 % Operators/coefficients that are only required from this side
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
411 Hi = u.Hi;
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
412 H_b = u.getBoundaryQuadrature(boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
413 a = u.a;
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
414
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
415 closure = 1/2*a*Hi*d_u*b_b_u*H_b*e_u' ...
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
416 -1/2*a*Hi*e_u*H_b*b_b_u*d_u' ...
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
417 -a*Hi*e_u*tau*H_b*e_u';
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
418
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
419 penalty = -1/2*a*Hi*d_u*b_b_u*H_b*e_v' ...
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
420 -1/2*a*Hi*e_u*H_b*b_b_v*d_v' ...
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
421 +a*Hi*e_u*tau*H_b*e_v';
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
422 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
423
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
424 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
425
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
426 % 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
427 warning('LaplaceCurvilinear: Non-conforming grid interpolation only works for Cartesian grids.');
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
428 warning('LaplaceCurvilinear: Non-conforming interface uses Virtas penalty strength');
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
429 warning('LaplaceCurvilinear: Non-conforming interface assumes that b is constant');
1063
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 % 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
432 default_field(type, 'interpOpSet', @sbp.InterpOpsOP);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
433 interpOpSet = type.interpOpSet;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
434 tuning = type.tuning;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
435
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
436
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
437 % 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
438 % v denotes the solution in the neighbour domain
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
439 e_u = obj.getBoundaryOperator('e', boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
440 d_u = obj.getBoundaryOperator('d', boundary);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
441 H_b_u = obj.getBoundaryQuadrature(boundary);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
442 I_u = obj.getBoundaryIndices(boundary);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
443 gamm_u = obj.getBoundaryBorrowing(boundary);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
444
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
445 e_v = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary);
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
446 d_v = neighbour_scheme.getBoundaryOperator('d', neighbour_boundary);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
447 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
448 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
449 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
450
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
451
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
452 % 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
453 m_u = size(e_u, 2);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
454 m_v = size(e_v, 2);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
455
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
456 Hi = obj.Hi;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
457 a = obj.a;
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 u = obj;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
460 v = neighbour_scheme;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
461
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
462 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
463 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
464 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
465 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
466
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
467 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
468 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
469
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
470 tau_u = tuning * spdiag(tau_u);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
471 tau_v = tuning * spdiag(tau_v);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
472 beta_u = tau_v;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
473
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
474 % Build interpolation operators
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
475 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
476 Iu2v = intOps.Iu2v;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
477 Iv2u = intOps.Iv2u;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
478
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
479 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
480 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
481 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
482 -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
483
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
484 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
485 -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
486 -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
487 -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
488
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
489 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
490
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
491 % Returns the boundary operator op for the boundary specified by the string boundary.
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
492 % op -- string
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
493 % boundary -- string
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
494 function o = getBoundaryOperator(obj, op, boundary)
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
495 assertIsMember(op, {'e', 'd'})
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
496 assertIsMember(boundary, {'w', 'e', 's', 'n'})
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
497
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
498 o = obj.([op, '_', boundary]);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
499 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
500
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
501 % 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
502 % 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
503 %
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
504 % boundary -- string
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
505 function H_b = getBoundaryQuadrature(obj, boundary)
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
506 assertIsMember(boundary, {'w', 'e', 's', 'n'})
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
507
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
508 H_b = obj.(['H_', boundary]);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
509 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
510
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
511 % 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
512 % 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
513 %
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
514 % boundary -- string
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
515 function s_b = getBoundaryScaling(obj, boundary)
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
516 assertIsMember(boundary, {'w', 'e', 's', 'n'})
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
517
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
518 s_b = obj.(['s_', boundary]);
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
519 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
520
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
521 % 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
522 %
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
523 % boundary -- string
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
524 function m = getBoundaryNumber(obj, boundary)
1069
7a55a72729e6 Copy-paste updates from LaplCurvNewCorner to LaplCurvNew, and then modify the corner part.
Martin Almquist <malmquist@stanford.edu>
parents: 1064
diff changeset
525 assertIsMember(boundary, {'w', 'e', 's', 'n'})
1063
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
526
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
527 switch boundary
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
528 case {'w', 'e'}
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
529 m = 1;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
530 case {'s', 'n'}
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
531 m = 2;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
532 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
533 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
534
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
535 % 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
536 % boundary -- string
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
537 function I = getBoundaryIndices(obj, boundary)
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
538 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
539 switch boundary
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
540 case 'w'
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
541 I = ind(1,:);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
542 case 'e'
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
543 I = ind(end,:);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
544 case 's'
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
545 I = ind(:,1)';
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
546 case 'n'
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
547 I = ind(:,end)';
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
548 otherwise
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
549 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
550 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
551 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
552
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
553 % Returns borrowing constant gamma
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
554 % boundary -- string
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
555 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
556 switch boundary
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
557 case {'w','e'}
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
558 theta_H = obj.theta_H_u;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
559 theta_M = obj.theta_M_u;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
560 theta_R = obj.theta_R_u;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
561 case {'s','n'}
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
562 theta_H = obj.theta_H_v;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
563 theta_M = obj.theta_M_v;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
564 theta_R = obj.theta_R_v;
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
565 otherwise
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
566 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
567 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
568 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
569
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
570 function N = size(obj)
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
571 N = prod(obj.m);
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
572 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
573 end
e913cdb34dcb Add LaplaceCurvilinearNew and implement Dirichlet BC using new borrowing.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
574 end