annotate +scheme/LaplaceCurvilinearVirtaMin.m @ 1210:5e7692ed7c7c feature/laplace_curvilinear_test

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