Mercurial > repos > public > sbplib
annotate +scheme/Staggered1DAcousticsVariable.m @ 1081:9c74d96fc9e2 feature/d1_staggered
Bugfix in interface SATs, Staggered1DAcousticsVariable
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 05 Mar 2019 11:18:44 -0800 |
parents | 18e10217dca9 |
children |
rev | line source |
---|---|
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
1 classdef Staggered1DAcousticsVariable < scheme.Scheme |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
2 properties |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
3 m % Number of points of primal grid in each direction, possibly a vector |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
4 h % Grid spacing |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
5 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
6 % Grids |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
7 grid % Total grid object |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
8 grid_primal |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
9 grid_dual |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
10 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
11 order % Order accuracy for the approximation |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
12 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
13 H % Combined norm |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
14 Hi % Inverse |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
15 D % Semi-discrete approximation matrix |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
16 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
17 D1_primal |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
18 D1_dual |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
19 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
20 % Pick out left or right boundary |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
21 e_l |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
22 e_r |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
23 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
24 % Initial data |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
25 v0 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
26 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
27 % Pick out primal or dual component |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
28 e_primal |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
29 e_dual |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
30 |
653
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
31 % System matrices, cell matrices of function handles |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
32 A |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
33 B |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
34 |
653
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
35 % Variable coefficient matrices evaluated at boundaries. |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 A_l, A_r |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 B_l, B_r |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
40 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
41 methods |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
42 % Scheme for A*u_t + B u_x = 0, |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 % u = [p, v]; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
44 % A: Diagonal and A > 0, |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
45 % A = [a1, 0; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
46 % 0, a2] |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
47 % |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
48 % B = B^T and with diagonal entries = 0. |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
49 % B = [0 b |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
50 % b 0] |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
51 % Here we store p on the primal grid and v on the dual |
653
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
52 % A and B are cell matrices of function handles |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
53 function obj = Staggered1DAcousticsVariable(g, order, A, B) |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
54 default_arg('B',{@(x)0*x, @(x)0*x+1; @(x)0*x+1, @(x)0*x}); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
55 default_arg('A',{@(x)0*x+1, @(x)0*x; @(x)0*x, @(x)0*x+1}); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
56 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
57 obj.order = order; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 obj.A = A; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 obj.B = B; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
60 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
61 % Grids |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
62 obj.m = g.size(); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
63 xl = g.getBoundary('l'); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
64 xr = g.getBoundary('r'); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
65 xlim = {xl, xr}; |
653
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
66 obj.grid = g; |
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
67 obj.grid_primal = g.grids{1}; |
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
68 obj.grid_dual = g.grids{2}; |
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
69 x_primal = obj.grid_primal.points(); |
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
70 x_dual = obj.grid_dual.points(); |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
71 |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
72 % If coefficients are function handles, evaluate them |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
73 if isa(A{1,1}, 'function_handle') |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
74 A{1,1} = A{1,1}(x_primal); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
75 A{1,2} = A{1,2}(x_dual); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
76 A{2,1} = A{2,1}(x_primal); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
77 A{2,2} = A{2,2}(x_dual); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
78 end |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
79 |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
80 if isa(B{1,1}, 'function_handle') |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
81 B{1,1} = B{1,1}(x_primal); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
82 B{1,2} = B{1,2}(x_primal); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
83 B{2,1} = B{2,1}(x_dual); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
84 B{2,2} = B{2,2}(x_dual); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
85 end |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
86 |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
87 % If coefficents are vectors, turn them into diagonal matrices |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
88 [m, n] = size(A{1,1}); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
89 if m==1 || n == 1 |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
90 A{1,1} = spdiag(A{1,1}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
91 A{2,1} = spdiag(A{2,1}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
92 A{1,2} = spdiag(A{1,2}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
93 A{2,2} = spdiag(A{2,2}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
94 end |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
95 |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
96 [m, n] = size(B{1,1}); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
97 if m==1 || n == 1 |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
98 B{1,1} = spdiag(B{1,1}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
99 B{2,1} = spdiag(B{2,1}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
100 B{1,2} = spdiag(B{1,2}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
101 B{2,2} = spdiag(B{2,2}, 0); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
102 end |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
103 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
104 % Boundary matrices |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
105 obj.A_l = full([A{1,1}(1,1), A{1,2}(1,1);.... |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
106 A{2,1}(1,1), A{2,2}(1,1)]); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
107 obj.A_r = full([A{1,1}(end,end), A{1,2}(end,end);.... |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
108 A{2,1}(end,end), A{2,2}(end,end)]); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
109 obj.B_l = full([B{1,1}(1,1), B{1,2}(1,1);.... |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
110 B{2,1}(1,1), B{2,2}(1,1)]); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
111 obj.B_r = full([B{1,1}(end,end), B{1,2}(end,end);.... |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
112 B{2,1}(end,end), B{2,2}(end,end)]); |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
113 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
114 % Get operators |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
115 ops = sbp.D1StaggeredUpwind(obj.m, xlim, order); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
116 obj.h = ops.h; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
117 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
118 % Build combined operators |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
119 H_primal = ops.H_primal; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
120 H_dual = ops.H_dual; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
121 obj.H = blockmatrix.toMatrix( {H_primal, []; [], H_dual } ); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
122 obj.Hi = inv(obj.H); |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
123 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
124 D1_primal = ops.D1_primal; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
125 D1_dual = ops.D1_dual; |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
126 A11_B12 = -A{1,1}\B{1,2}; |
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
127 A22_B21 = -A{2,2}\B{2,1}; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
128 D = {[], A11_B12*D1_primal;... |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
129 A22_B21*D1_dual, []}; |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
130 obj.D = blockmatrix.toMatrix(D); |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
131 obj.D1_primal = D1_primal; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
132 obj.D1_dual = D1_dual; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
133 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
134 % Combined boundary operators |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
135 e_primal_l = ops.e_primal_l; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
136 e_primal_r = ops.e_primal_r; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
137 e_dual_l = ops.e_dual_l; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
138 e_dual_r = ops.e_dual_r; |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
139 e_l = {e_primal_l, [];... |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
140 [] , e_dual_l}; |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
141 e_r = {e_primal_r, [];... |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
142 [] , e_dual_r}; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
143 obj.e_l = blockmatrix.toMatrix(e_l); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
144 obj.e_r = blockmatrix.toMatrix(e_r); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
145 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
146 % Pick out first or second component of solution |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
147 N_primal = obj.grid_primal.N(); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
148 N_dual = obj.grid_dual.N(); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
149 obj.e_primal = [speye(N_primal, N_primal); sparse(N_dual, N_primal)]; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
150 obj.e_dual = [sparse(N_primal, N_dual); speye(N_dual, N_dual)]; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
151 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
152 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
153 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
154 % Closure functions return the operators applied to the own domain to close the boundary |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
155 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other domain. |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
156 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
157 % type is a string specifying the type of boundary condition if there are several. |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
158 % neighbour_scheme is an instance of Scheme that should be interfaced to. |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
159 % neighbour_boundary is a string specifying which boundary to interface to. |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
160 function [closure, penalty] = boundary_condition(obj, boundary, type) |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
161 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
162 default_arg('type','p'); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
163 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
164 % type = 'p' => boundary condition for p |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
165 % type = 'v' => boundary condition for v |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
166 % No other types implemented yet |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
167 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
168 % BC on the form Lu - g = 0; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
169 |
682
ec0ac76006e2
Modify BC in Staggered 1D acoustics to ensure that only physically meaningful changes of variables are used. See hypsyst varcoeff sec 3.
Martin Almquist <malmquist@stanford.edu>
parents:
672
diff
changeset
|
170 % Need a transformation T such that w = T^{−1}*u is a |
ec0ac76006e2
Modify BC in Staggered 1D acoustics to ensure that only physically meaningful changes of variables are used. See hypsyst varcoeff sec 3.
Martin Almquist <malmquist@stanford.edu>
parents:
672
diff
changeset
|
171 % meaningful change of variables and T^T*B*T is block-diagonal, |
ec0ac76006e2
Modify BC in Staggered 1D acoustics to ensure that only physically meaningful changes of variables are used. See hypsyst varcoeff sec 3.
Martin Almquist <malmquist@stanford.edu>
parents:
672
diff
changeset
|
172 % For linear acoustics, T = T_C meets these criteria. |
ec0ac76006e2
Modify BC in Staggered 1D acoustics to ensure that only physically meaningful changes of variables are used. See hypsyst varcoeff sec 3.
Martin Almquist <malmquist@stanford.edu>
parents:
672
diff
changeset
|
173 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
174 % Get boundary matrices |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
175 switch boundary |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
176 case 'l' |
653
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
177 A = obj.A_l; |
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
178 B = obj.B_l; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
179 case 'r' |
653
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
180 A = obj.A_r; |
2351a7690e8a
Clean up and improve comments in StaggeredVariable
Martin Almquist <malmquist@stanford.edu>
parents:
652
diff
changeset
|
181 B = obj.B_r; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
182 end |
672
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
183 C = inv(A)*B; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
184 |
682
ec0ac76006e2
Modify BC in Staggered 1D acoustics to ensure that only physically meaningful changes of variables are used. See hypsyst varcoeff sec 3.
Martin Almquist <malmquist@stanford.edu>
parents:
672
diff
changeset
|
185 % Diagonalize C and use T_C to diagonalize B |
ec0ac76006e2
Modify BC in Staggered 1D acoustics to ensure that only physically meaningful changes of variables are used. See hypsyst varcoeff sec 3.
Martin Almquist <malmquist@stanford.edu>
parents:
672
diff
changeset
|
186 [T, ~] = eig(C); |
ec0ac76006e2
Modify BC in Staggered 1D acoustics to ensure that only physically meaningful changes of variables are used. See hypsyst varcoeff sec 3.
Martin Almquist <malmquist@stanford.edu>
parents:
672
diff
changeset
|
187 Lambda = T'*B*T; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
188 lambda = diag(Lambda); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
189 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
190 % Identify in- and outgoing characteristic variables |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
191 Iplus = lambda > 0; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
192 Iminus = lambda < 0; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
193 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
194 switch boundary |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
195 case 'l' |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
196 Iin = Iplus; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
197 case 'r' |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
198 Iin = Iminus; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
199 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
200 Tin = T(:,Iin); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
201 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
202 switch type |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
203 case 'p' |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
204 L = [1, 0]; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
205 case 'v' |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
206 L = [0, 1]; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
207 case 'characteristic' |
672
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
208 % Diagonalize C |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
209 [T_C, Lambda_C] = eig(C); |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
210 lambda_C = diag(Lambda_C); |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
211 % Identify in- and outgoing characteristic variables |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
212 Iplus = lambda_C > 0; |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
213 Iminus = lambda_C < 0; |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
214 |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
215 switch boundary |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
216 case 'l' |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
217 Iin_C = Iplus; |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
218 case 'r' |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
219 Iin_C = Iminus; |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
220 end |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
221 T_C_inv = inv(T_C); |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
222 L = T_C_inv(Iin_C,:); |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
223 otherwise |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
224 error('Boundary condition not implemented.'); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
225 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
226 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
227 % Penalty parameters |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
228 sigma = [0; 0]; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
229 sigma(Iin) = lambda(Iin); |
672
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
230 |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
231 % Sparsify |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
232 A = sparse(A); |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
233 T = sparse(T); |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
234 sigma = sparse(sigma); |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
235 L = sparse(L); |
82024d32e333
Correct char BC in staggered acoustics 1D variable coeff.
Martin Almquist <malmquist@stanford.edu>
parents:
653
diff
changeset
|
236 Tin = sparse(Tin); |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
237 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
238 switch boundary |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
239 case 'l' |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
240 tau = -1*obj.e_l * inv(A) * inv(T)' * sigma * inv(L*Tin); |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
241 closure = obj.Hi*tau*L*obj.e_l'; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
242 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
243 case 'r' |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
244 tau = 1*obj.e_r * inv(A) * inv(T)' * sigma * inv(L*Tin); |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
245 closure = obj.Hi*tau*L*obj.e_r'; |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
246 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
247 end |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
248 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
249 penalty = -obj.Hi*tau; |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
250 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
251 end |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
252 |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
253 % Uses the hat variable method for the interface coupling, |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
254 % see hypsyst_varcoeff.pdf in the hypsyst repository. |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
255 % Notation: u for left side of interface, v for right side. |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
256 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
257 |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
258 % Get boundary matrices |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
259 switch boundary |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
260 case 'l' |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
261 A_v = obj.A_l; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
262 B_v = obj.B_l; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
263 Hi_v = obj.Hi; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
264 e_v = obj.e_l; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
265 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
266 A_u = neighbour_scheme.A_r; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
267 B_u = neighbour_scheme.B_r; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
268 Hi_u = neighbour_scheme.Hi; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
269 e_u = neighbour_scheme.e_r; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
270 case 'r' |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
271 A_u = obj.A_r; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
272 B_u = obj.B_r; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
273 Hi_u = obj.Hi; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
274 e_u = obj.e_r; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
275 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
276 A_v = neighbour_scheme.A_l; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
277 B_v = neighbour_scheme.B_l; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
278 Hi_v = neighbour_scheme.Hi; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
279 e_v = neighbour_scheme.e_l; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
280 end |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
281 C_u = inv(A_u)*B_u; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
282 C_v = inv(A_v)*B_v; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
283 |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
284 % Diagonalize C |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
285 [T_u, ~] = eig(C_u); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
286 Lambda_u = inv(T_u)*C_u*T_u; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
287 lambda_u = diag(Lambda_u); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
288 S_u = inv(T_u); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
289 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
290 [T_v, ~] = eig(C_v); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
291 Lambda_v = inv(T_v)*C_v*T_v; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
292 lambda_v = diag(Lambda_v); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
293 S_v = inv(T_v); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
294 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
295 % Identify in- and outgoing characteristic variables |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
296 Im_u = lambda_u < 0; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
297 Ip_u = lambda_u > 0; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
298 Im_v = lambda_v < 0; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
299 Ip_v = lambda_v > 0; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
300 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
301 Tp_u = T_u(:,Ip_u); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
302 Tm_u = T_u(:,Im_u); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
303 Sp_u = S_u(Ip_u,:); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
304 Sm_u = S_u(Im_u,:); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
305 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
306 Tp_v = T_v(:,Ip_v); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
307 Tm_v = T_v(:,Im_v); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
308 Sp_v = S_v(Ip_v,:); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
309 Sm_v = S_v(Im_v,:); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
310 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
311 % Create S_tilde and T_tilde |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
312 Stilde = [Sp_u; Sm_v]; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
313 Ttilde = inv(Stilde); |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
314 Ttilde_p = Ttilde(:,1); |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
315 Ttilde_m = Ttilde(:,2); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
316 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
317 % Solve for penalty parameters theta_1,2 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
318 LHS = Ttilde_m*Sm_v*Tm_u; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
319 RHS = B_u*Tm_u; |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
320 th_u = RHS./LHS; |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
321 TH_u = diag(th_u); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
322 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
323 LHS = Ttilde_p*Sp_u*Tp_v; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
324 RHS = -B_v*Tp_v; |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
325 th_v = RHS./LHS; |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
326 TH_v = diag(th_v); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
327 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
328 % Construct penalty matrices |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
329 Z_u = TH_u*Ttilde_m*Sm_v; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
330 Z_u = sparse(Z_u); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
331 |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
332 Z_v = TH_v*Ttilde_p*Sp_u; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
333 Z_v = sparse(Z_v); |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
334 |
1081
9c74d96fc9e2
Bugfix in interface SATs, Staggered1DAcousticsVariable
Martin Almquist <malmquist@stanford.edu>
parents:
885
diff
changeset
|
335 closure_u = Hi_u*e_u*(A_u\Z_u)*e_u'; |
9c74d96fc9e2
Bugfix in interface SATs, Staggered1DAcousticsVariable
Martin Almquist <malmquist@stanford.edu>
parents:
885
diff
changeset
|
336 penalty_u = -Hi_u*e_u*(A_u\Z_u)*e_v'; |
9c74d96fc9e2
Bugfix in interface SATs, Staggered1DAcousticsVariable
Martin Almquist <malmquist@stanford.edu>
parents:
885
diff
changeset
|
337 closure_v = Hi_v*e_v*(A_v\Z_v)*e_v'; |
9c74d96fc9e2
Bugfix in interface SATs, Staggered1DAcousticsVariable
Martin Almquist <malmquist@stanford.edu>
parents:
885
diff
changeset
|
338 penalty_v = -Hi_v*e_v*(A_v\Z_v)*e_u'; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
339 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
340 switch boundary |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
341 case 'l' |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
342 closure = closure_v; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
343 penalty = penalty_v; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
344 case 'r' |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
345 closure = closure_u; |
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
346 penalty = penalty_u; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
347 end |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
348 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
349 end |
885
18e10217dca9
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
Martin Almquist <malmquist@stanford.edu>
parents:
761
diff
changeset
|
350 |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
351 function N = size(obj) |
761
8ed102db8e9c
Add discont interface in 1D acoustics staggered, using the hat variable interface coupling.
Martin Almquist <malmquist@stanford.edu>
parents:
682
diff
changeset
|
352 N = 2*obj.m+1; |
652
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
353 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
354 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
355 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
356 |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
357 methods(Static) |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
358 % Calculates the matrices needed for the inteface coupling between boundary bound_u of scheme schm_u |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
359 % and bound_v of scheme schm_v. |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
360 % [uu, uv, vv, vu] = inteface_coupling(A,'r',B,'l') |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
361 function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v) |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
362 [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
363 [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u); |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
364 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
365 end |
be941bb0a11a
Add staggered 1D variable coefficient. Convergence study working.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
366 end |