Mercurial > repos > public > sbplib
annotate diracDiscr.m @ 1283:70939ea9a71f feature/poroelastic
Bugfix in Elastic2dVariable
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 23 Jun 2020 13:31:01 -0700 |
parents | 43a1c3ac07b1 |
children | c70131daaa6e 60c875c18de3 |
rev | line source |
---|---|
837
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
1 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
2 function d = diracDiscr(x_s, x, m_order, s_order, H) |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
3 % n-dimensional delta function |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
4 % x_s: source point coordinate vector, e.g. [x, y] or [x, y, z]. |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
5 % x: cell array of grid point column vectors for each dimension. |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
6 % m_order: Number of moment conditions |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
7 % s_order: Number of smoothness conditions |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
8 % H: cell array of 1D norm matrices |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
9 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
10 dim = length(x_s); |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
11 d_1D = cell(dim,1); |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
12 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
13 % If 1D, non-cell input is accepted |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
14 if dim == 1 && ~iscell(x) |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
15 d = diracDiscr1D(x_s, x, m_order, s_order, H); |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
16 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
17 else |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
18 for i = 1:dim |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
19 d_1D{i} = diracDiscr1D(x_s(i), x{i}, m_order, s_order, H{i}); |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
20 end |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
21 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
22 d = d_1D{dim}; |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
23 for i = dim-1: -1: 1 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
24 % Perform outer product, transpose, and then turn into column vector |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
25 d = (d_1D{i}*d')'; |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
26 d = d(:); |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
27 end |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
28 end |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
29 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
30 end |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
31 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
32 |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
33 % Helper function for 1D delta functions |
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
34 function ret = diracDiscr1D(x_0in , x , m_order, s_order, H) |
836
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
35 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 m = length(x); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 % Return zeros if x0 is outside grid |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 if(x_0in < x(1) || x_0in > x(end) ) |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
40 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
41 ret = zeros(size(x)); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
42 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 else |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
44 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
45 fnorm = diag(H); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
46 eta = abs(x-x_0in); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
47 tot = m_order+s_order; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
48 S = []; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
49 M = []; |
837
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
50 |
836
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
51 % Get interior grid spacing |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
52 middle = floor(m/2); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
53 h = x(middle+1) - x(middle); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
54 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
55 poss = find(tot*h/2 >= eta); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
56 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
57 % Ensure that poss is not too long |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 if length(poss) == (tot + 2) |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 poss = poss(2:end-1); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
60 elseif length(poss) == (tot + 1) |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
61 poss = poss(1:end-1); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
62 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
63 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
64 % Use first tot grid points |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
65 if length(poss)<tot && x_0in < x(1) + ceil(tot/2)*h; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
66 index=1:tot; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
67 pol=(x(1:tot)-x(1))/(x(tot)-x(1)); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
68 x_0=(x_0in-x(1))/(x(tot)-x(1)); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
69 norm=fnorm(1:tot)/h; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
70 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
71 % Use last tot grid points |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
72 elseif length(poss)<tot && x_0in > x(end) - ceil(tot/2)*h; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
73 index = length(x)-tot+1:length(x); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
74 pol = (x(end-tot+1:end)-x(end-tot+1))/(x(end)-x(end-tot+1)); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
75 norm = fnorm(end-tot+1:end)/h; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
76 x_0 = (x_0in-x(end-tot+1))/(x(end)-x(end-tot+1)); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
77 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
78 % Interior, compensate for round-off errors. |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
79 elseif length(poss) < tot |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
80 if poss(end)<m |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
81 poss = [poss; poss(end)+1]; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
82 else |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
83 poss = [poss(1)-1; poss]; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
84 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
85 pol = (x(poss)-x(poss(1)))/(x(poss(end))-x(poss(1))); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
86 x_0 = (x_0in-x(poss(1)))/(x(poss(end))-x(poss(1))); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
87 norm = fnorm(poss)/h; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
88 index = poss; |
837
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
89 |
836
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
90 % Interior |
837
43a1c3ac07b1
Make diracDiscr work for n dimensions. Add tests up to 3D.
Martin Almquist <malmquist@stanford.edu>
parents:
836
diff
changeset
|
91 else |
836
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
92 pol = (x(poss)-x(poss(1)))/(x(poss(end))-x(poss(1))); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
93 x_0 = (x_0in-x(poss(1)))/(x(poss(end))-x(poss(1))); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
94 norm = fnorm(poss)/h; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
95 index = poss; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
96 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
97 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
98 h_pol = pol(2)-pol(1); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
99 b = zeros(m_order+s_order,1); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
100 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
101 for i = 1:m_order |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
102 b(i,1) = x_0^(i-1); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
103 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
104 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
105 for i = 1:(m_order+s_order) |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
106 for j = 1:m_order |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
107 M(j,i) = pol(i)^(j-1)*h_pol*norm(i); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
108 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
109 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
110 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
111 for i = 1:(m_order+s_order) |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
112 for j = 1:s_order |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
113 S(j,i) = (-1)^(i-1)*pol(i)^(j-1); |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
114 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
115 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
116 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
117 A = [M;S]; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
118 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
119 d = A\b; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
120 ret = x*0; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
121 ret(index) = d/h*h_pol; |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
122 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
123 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
124 end |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
125 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
126 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
127 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
128 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
129 |
049e4c6fa630
Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
130 |