Mercurial > repos > public > sbplib
annotate +scheme/Schrodinger2d.m @ 1198:2924b3a9b921 feature/d2_compatible
Add OpSet for fully compatible D2Variable, created from regular D2Variable by replacing d1 by first row of D1. Formal reduction by one order of accuracy at the boundary point.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Fri, 16 Aug 2019 14:30:28 -0700 |
parents | 8d73fcdb07a5 |
children |
rev | line source |
---|---|
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
1 classdef Schrodinger2d < scheme.Scheme |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
3 % Discretizes the Laplacian with constant coefficent, |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
4 % in the Schrödinger equation way (i.e., the discretization matrix is not necessarily |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
5 % definite) |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
6 % u_t = a*i*Laplace u |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
7 % opSet should be cell array of opSets, one per dimension. This |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
8 % is useful if we have periodic BC in one direction. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
9 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
10 properties |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
11 m % Number of points in each direction, possibly a vector |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
12 h % Grid spacing |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
13 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
14 grid |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
15 dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
16 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
17 order % Order of accuracy for the approximation |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
18 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
19 % Diagonal matrix for variable coefficients |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
20 a % Constant coefficient |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
21 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
22 D % Total operator |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
23 D1 % First derivatives |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
24 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
25 % Second derivatives |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
26 D2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
27 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
28 H, Hi % Inner products |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
29 e_l, e_r |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
30 d1_l, d1_r % Normal derivatives at the boundary |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
31 e_w, e_e, e_s, e_n |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
32 d_w, d_e, d_s, d_n |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
33 |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
34 H_boundary % Boundary inner products |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
35 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 methods |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
40 function obj = Schrodinger2d(g ,order, a, opSet) |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
41 default_arg('opSet',{@sbp.D2Variable, @sbp.D2Variable}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
42 default_arg('a',1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 dim = 2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
44 |
948
3dd7f87c9a1b
Use assertType(...) instead of assert(isa(...))
Jonatan Werpers <jonatan@werpers.com>
parents:
941
diff
changeset
|
45 assertType(g, 'grid.Cartesian'); |
743
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
46 if isa(a, 'function_handle') |
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
47 a = grid.evalOn(g, a); |
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
48 a = spdiag(a); |
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
49 end |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
50 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
51 m = g.size(); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
52 m_tot = g.N(); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
53 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
54 h = g.scaling(); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
55 xlim = {g.x{1}(1), g.x{1}(end)}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
56 ylim = {g.x{2}(1), g.x{2}(end)}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
57 lim = {xlim, ylim}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 % 1D operators |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
60 ops = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
61 for i = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
62 ops{i} = opSet{i}(m(i), lim{i}, order); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
63 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
64 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
65 I = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
66 D1 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
67 D2 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
68 H = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
69 Hi = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
70 e_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
71 e_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
72 d1_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
73 d1_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
74 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
75 for i = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
76 I{i} = speye(m(i)); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
77 D1{i} = ops{i}.D1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
78 D2{i} = ops{i}.D2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
79 H{i} = ops{i}.H; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
80 Hi{i} = ops{i}.HI; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
81 e_l{i} = ops{i}.e_l; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
82 e_r{i} = ops{i}.e_r; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
83 d1_l{i} = ops{i}.d1_l; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
84 d1_r{i} = ops{i}.d1_r; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
85 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
86 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
87 % Constant coeff D2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
88 for i = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
89 D2{i} = D2{i}(ones(m(i),1)); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
90 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
91 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
92 %====== Assemble full operators ======== |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
93 obj.D1 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
94 obj.D2 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
95 obj.e_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
96 obj.e_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
97 obj.d1_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
98 obj.d1_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
99 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
100 % D1 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
101 obj.D1{1} = kron(D1{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
102 obj.D1{2} = kron(I{1},D1{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
103 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
104 % Boundary operators |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
105 obj.e_l{1} = kron(e_l{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
106 obj.e_l{2} = kron(I{1},e_l{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
107 obj.e_r{1} = kron(e_r{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
108 obj.e_r{2} = kron(I{1},e_r{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
109 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
110 obj.d1_l{1} = kron(d1_l{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
111 obj.d1_l{2} = kron(I{1},d1_l{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
112 obj.d1_r{1} = kron(d1_r{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
113 obj.d1_r{2} = kron(I{1},d1_r{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
114 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
115 % D2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
116 obj.D2{1} = kron(D2{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
117 obj.D2{2} = kron(I{1},D2{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
118 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
119 % Quadratures |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
120 obj.H = kron(H{1},H{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
121 obj.Hi = inv(obj.H); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
122 obj.H_boundary = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
123 obj.H_boundary{1} = H{2}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
124 obj.H_boundary{2} = H{1}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
125 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
126 % Differentiation matrix D (without SAT) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
127 D2 = obj.D2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
128 D = sparse(m_tot,m_tot); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
129 for j = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
130 D = D + a*1i*D2{j}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
131 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
132 obj.D = D; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
133 %=========================================% |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
134 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
135 % Misc. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
136 obj.m = m; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
137 obj.h = h; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
138 obj.order = order; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
139 obj.grid = g; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
140 obj.dim = dim; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
141 obj.a = a; |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
142 obj.e_w = obj.e_l{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
143 obj.e_e = obj.e_r{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
144 obj.e_s = obj.e_l{2}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
145 obj.e_n = obj.e_r{2}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
146 obj.d_w = obj.d1_l{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
147 obj.d_e = obj.d1_r{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
148 obj.d_s = obj.d1_l{2}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
149 obj.d_n = obj.d1_r{2}; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
150 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
151 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
152 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
153 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
154 % Closure functions return the operators applied to the own domain to close the boundary |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
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 doamin. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
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'. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
157 % type is a string specifying the type of boundary condition. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
158 % data is a function returning the data that should be applied at the boundary. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
159 % neighbour_scheme is an instance of Scheme that should be interfaced to. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
160 % neighbour_boundary is a string specifying which boundary to interface to. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
161 function [closure, penalty] = boundary_condition(obj, boundary, type, parameter) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
162 default_arg('type','Neumann'); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
163 default_arg('parameter', []); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
164 |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
165 % nj: outward unit normal component. |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
166 % nj = -1 for west, south, bottom boundaries |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
167 % nj = 1 for east, north, top boundaries |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
168 nj = obj.getBoundarySign(boundary); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
169 [e, d] = obj.getBoundaryOperator({'e', 'd'}, boundary); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
170 H_gamma = obj.getBoundaryQuadrature(boundary); |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
171 Hi = obj.Hi; |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
172 a = e'*obj.a*e; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
173 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
174 switch type |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
175 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
176 % Dirichlet boundary condition |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
177 case {'D','d','dirichlet','Dirichlet'} |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
178 closure = nj*Hi*d*a*1i*H_gamma*(e' ); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
179 penalty = -nj*Hi*d*a*1i*H_gamma; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
180 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
181 % Free boundary condition |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
182 case {'N','n','neumann','Neumann'} |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
183 closure = -nj*Hi*e*a*1i*H_gamma*(d' ); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
184 penalty = nj*Hi*e*a*1i*H_gamma; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
185 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
186 % Unknown boundary condition |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
187 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
188 error('No such boundary condition: type = %s',type); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
189 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
190 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
191 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
192 % type Struct that specifies the interface coupling. |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
193 % Fields: |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
194 % -- interpolation: type of interpolation, default 'none' |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
195 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
196 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
197 defaultType.interpolation = 'none'; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
198 default_struct('type', defaultType); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
199 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
200 switch type.interpolation |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
201 case {'none', ''} |
940
31186559236d
Add forgotten type argument in call to interfaceStandard in Schrodinger2d and LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
939
diff
changeset
|
202 [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type); |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
203 case {'op','OP'} |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
204 [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
205 otherwise |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
206 error('Unknown type of interpolation: %s ', type.interpolation); |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
207 end |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
208 end |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
209 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
210 function [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
211 % u denotes the solution in the own domain |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
212 % v denotes the solution in the neighbour domain |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
213 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
214 % Get boundary operators |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
215 [e_v, d_v] = neighbour_scheme.getBoundaryOperator({'e', 'd'}, neighbour_boundary); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
216 [e_u, d_u] = obj.getBoundaryOperator({'e', 'd'}, boundary); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
217 H_gamma = obj.getBoundaryQuadrature(boundary); |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
218 Hi = obj.Hi; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
219 a = obj.a; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
220 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
221 % Get outward unit normal component |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
222 n = obj.getBoundarySign(boundary); |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
223 |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
224 Hi = obj.Hi; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
225 sigma = -n*1i*a/2; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
226 tau = -n*(1i*a)'/2; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
227 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
228 closure = tau*Hi*d*H_gamma*e' + sigma*Hi*e*H_gamma*d'; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
229 penalty = -tau*Hi*d*H_gamma*e_neighbour' ... |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
230 -sigma*Hi*e*H_gamma*d_neighbour'; |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
231 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
232 end |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
233 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
234 function [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
235 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
236 % User can request special interpolation operators by specifying type.interpOpSet |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
237 default_field(type, 'interpOpSet', @sbp.InterpOpsOP); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
238 interpOpSet = type.interpOpSet; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
239 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
240 % u denotes the solution in the own domain |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
241 % v denotes the solution in the neighbour domain |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
242 [e_v, d_v] = neighbour_scheme.getBoundaryOperator({'e', 'd'}, neighbour_boundary); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
243 [e_u, d_u] = obj.getBoundaryOperator({'e', 'd'}, boundary); |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
244 H_gamma = obj.getBoundaryQuadrature(boundary); |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
245 Hi = obj.Hi; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
246 a = obj.a; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
247 |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
248 % Get outward unit normal component |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
249 n = obj.getBoundarySign(boundary); |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
250 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
251 % Find the number of grid points along the interface |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
252 m_u = size(e_u, 2); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
253 m_v = size(e_v, 2); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
254 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
255 % Build interpolation operators |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
256 intOps = interpOpSet(m_u, m_v, obj.order, neighbour_scheme.order); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
257 Iu2v = intOps.Iu2v; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
258 Iv2u = intOps.Iv2u; |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
259 |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
260 sigma = -n*1i*a/2; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
261 tau = -n*(1i*a)'/2; |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
262 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
263 closure = tau*Hi*d_u*H_gamma*e_u' + sigma*Hi*e_u*H_gamma*d_u'; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
264 penalty = -tau*Hi*d_u*H_gamma*Iv2u.good*e_v' ... |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
265 -sigma*Hi*e_u*H_gamma*Iv2u.bad*d_v'; |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
266 |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
267 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
268 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
269 % Returns the coordinate number and outward normal component for the boundary specified by the string boundary. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
270 function [j, nj] = get_boundary_number(obj, boundary) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
271 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
272 switch boundary |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
273 case {'w','W','west','West', 'e', 'E', 'east', 'East'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
274 j = 1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
275 case {'s','S','south','South', 'n', 'N', 'north', 'North'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
276 j = 2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
277 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
278 error('No such boundary: boundary = %s',boundary); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
279 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
280 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
281 switch boundary |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
282 case {'w','W','west','West','s','S','south','South'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
283 nj = -1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
284 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
285 nj = 1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
286 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
287 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
288 |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
289 % Returns the boundary operator op for the boundary specified by the string boundary. |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
290 % op -- string or a cell array of strings |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
291 % boundary -- string |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
292 function varargout = getBoundaryOperator(obj, op, boundary) |
1042
8d73fcdb07a5
Add asserts to boundary identifier inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
997
diff
changeset
|
293 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
294 |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
295 if ~iscell(op) |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
296 op = {op}; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
297 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
298 |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
299 for i = 1:numel(op) |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
300 switch op{i} |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
301 case 'e' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
302 switch boundary |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
303 case 'w' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
304 e = obj.e_w; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
305 case 'e' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
306 e = obj.e_e; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
307 case 's' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
308 e = obj.e_s; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
309 case 'n' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
310 e = obj.e_n; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
311 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
312 varargout{i} = e; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
313 |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
314 case 'd' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
315 switch boundary |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
316 case 'w' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
317 d = obj.d_w; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
318 case 'e' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
319 d = obj.d_e; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
320 case 's' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
321 d = obj.d_s; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
322 case 'n' |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
323 d = obj.d_n; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
324 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
325 varargout{i} = d; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
326 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
327 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
328 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
329 |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
330 % Returns square boundary quadrature matrix, of dimension |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
331 % corresponding to the number of boundary points |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
332 % |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
333 % boundary -- string |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
334 function H_b = getBoundaryQuadrature(obj, boundary) |
1042
8d73fcdb07a5
Add asserts to boundary identifier inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
997
diff
changeset
|
335 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
336 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
337 switch boundary |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
338 case 'w' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
339 H_b = obj.H_boundary{1}; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
340 case 'e' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
341 H_b = obj.H_boundary{1}; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
342 case 's' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
343 H_b = obj.H_boundary{2}; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
344 case 'n' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
345 H_b = obj.H_boundary{2}; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
346 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
347 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
348 |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
349 % Returns the boundary sign. The right boundary is considered the positive boundary |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
350 % boundary -- string |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
351 function s = getBoundarySign(obj, boundary) |
1042
8d73fcdb07a5
Add asserts to boundary identifier inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
997
diff
changeset
|
352 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
8d73fcdb07a5
Add asserts to boundary identifier inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
997
diff
changeset
|
353 |
997
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
354 switch boundary |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
355 case {'e','n'} |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
356 s = 1; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
357 case {'w','s'} |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
358 s = -1; |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
359 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
360 end |
78db023a7fe3
Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents:
948
diff
changeset
|
361 |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
362 function N = size(obj) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
363 N = prod(obj.m); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
364 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
365 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
366 end |