annotate +scheme/LaplaceCurvilinearNewCorner.m @ 1085:49c0b8c7330a feature/laplace_curvilinear_test

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