Mercurial > repos > public > sbplib
annotate diracPrimDiscrTest.m @ 1137:2ff1f366e64a feature/laplace_curvilinear_test
Fix minimum and correct borrowing in VirtaMin scheme.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 10 Jun 2019 13:27:29 +0200 |
parents | ea225a4659fe |
children |
rev | line source |
---|---|
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
1 function tests = diracPrimDiscrTest() |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
2 tests = functiontests(localfunctions); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
3 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
4 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
5 function testLeftGP(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
6 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
7 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
8 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
9 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
10 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
11 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
12 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
13 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
14 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
15 % Test left boundary grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
16 x0s = xl + [0, h, 2*h]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
17 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
18 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
19 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
20 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
21 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
22 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
23 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
24 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
25 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
26 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
27 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
28 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
29 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
30 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
31 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
32 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
33 function testLeftRandom(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
34 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
35 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
40 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
41 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
42 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 % Test random points near left boundary |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
44 x0s = xl + 2*h*rand(1,10); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
45 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
46 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
47 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
48 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
49 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
50 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
51 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
52 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
53 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
54 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
55 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
56 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
57 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
60 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
61 function testRightGP(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
62 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
63 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
64 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
65 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
66 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
67 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
68 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
69 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
70 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
71 % Test right boundary grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
72 x0s = xr-[0, h, 2*h]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
73 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
74 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
75 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
76 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
77 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
78 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
79 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
80 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
81 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
82 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
83 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
84 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
85 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
86 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
87 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
88 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
89 function testRightRandom(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
90 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
91 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
92 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
93 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
94 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
95 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
96 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
97 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
98 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
99 % Test random points near right boundary |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
100 x0s = xr - 2*h*rand(1,10); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
101 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
102 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
103 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
104 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
105 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
106 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
107 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
108 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
109 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
110 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
111 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
112 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
113 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
114 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
115 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
116 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
117 function testInteriorGP(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
118 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
119 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
120 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
121 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
122 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
123 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
124 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
125 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
126 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
127 % Test interior grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
128 m_half = round(m/2); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
129 x0s = xl + (m_half-1:m_half+1)*h; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
130 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
131 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
132 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
133 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
134 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
135 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
136 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
137 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
138 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
139 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
140 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
141 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
142 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
143 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
144 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
145 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
146 function testInteriorRandom(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
147 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
148 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
149 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
150 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
151 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
152 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
153 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
154 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
155 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
156 % Test random points in interior |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
157 x0s = (xl+2*h) + (xr-xl-4*h)*rand(1,20); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
158 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
159 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
160 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
161 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
162 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
163 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
164 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
165 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
166 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
167 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
168 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
169 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
170 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
171 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
172 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
173 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
174 % x0 outside grid should yield 0 integral! |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
175 function testX0OutsideGrid(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
176 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
177 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
178 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
179 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
180 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
181 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
182 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
183 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
184 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
185 % Test points outisde grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
186 x0s = [xl-1.1*h, xr+1.1*h]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
187 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
188 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
189 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
190 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
191 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
192 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
193 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
194 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
195 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
196 err = abs(integral - 0); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
197 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
198 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
199 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
200 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
201 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
202 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
203 function testAllGP(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
204 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
205 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
206 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
207 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
208 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
209 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
210 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
211 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
212 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
213 % Test all grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
214 x0s = x; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
215 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
216 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
217 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
218 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
219 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
220 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
221 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
222 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
223 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
224 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
225 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
226 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
227 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
228 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
229 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
230 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
231 function testHalfGP(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
232 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
233 orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
234 mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
235 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
236 for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
237 order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
238 mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
239 [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
240 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
241 % Test halfway between all grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
242 x0s = 1/2*( x(2:end)+x(1:end-1) ); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
243 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
244 for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
245 f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
246 fp = fps{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
247 fx = f(x); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
248 for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
249 x0 = x0s(i); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
250 delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
251 integral = delta'*H*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
252 err = abs(integral + fp(x0)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
253 testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
254 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
255 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
256 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
257 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
258 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
259 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
260 %=============== 2D tests ============================== |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
261 function testAllGP2D(testCase) |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
262 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
263 orders = [2, 4, 6]; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
264 mom_conds = orders; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
265 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
266 for o = 1:length(orders) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
267 order = orders(o); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
268 mom_cond = mom_conds(o); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
269 [xlims, ylims, m, x, X, ~, H, fs, dfdxs, dfdys] = setup2D(order, mom_cond); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
270 H_global = kron(H{1}, H{2}); |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
271 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
272 % Test all grid points |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
273 x0s = X; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
274 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
275 for j = 1:length(fs) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
276 f = fs{j}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
277 dfdx = dfdxs{j}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
278 dfdy = dfdys{j}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
279 fx = f(X(:,1), X(:,2)); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
280 for i = 1:length(x0s) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
281 x0 = x0s(i,:); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
282 |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
283 delta_x = diracPrimDiscr(x0, x, mom_cond, 0, H, 1); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
284 integral1 = delta_x'*H_global*fx; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
285 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
286 delta_y = diracPrimDiscr(x0, x, mom_cond, 0, H, 2); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
287 integral2 = delta_y'*H_global*fx; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
288 |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
289 err = abs(integral1 + dfdx(x0(1), x0(2))) + abs(integral2 + dfdy(x0(1), x0(2))); |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
290 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
291 testCase.verifyLessThan(err, 1e-12); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
292 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
293 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
294 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
295 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
296 |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
297 function testAllRandom2D(testCase) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
298 |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
299 orders = [2, 4, 6]; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
300 mom_conds = orders; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
301 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
302 for o = 1:length(orders) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
303 order = orders(o); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
304 mom_cond = mom_conds(o); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
305 [xlims, ylims, m, x, X, h, H, fs, dfdxs, dfdys] = setup2D(order, mom_cond); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
306 H_global = kron(H{1}, H{2}); |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
307 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
308 xl = xlims{1}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
309 xr = xlims{2}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
310 yl = ylims{1}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
311 yr = ylims{2}; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
312 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
313 % Test random points, even outside grid |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
314 Npoints = 100; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
315 x0s = [(xl-3*h{1}) + (xr-xl+6*h{1})*rand(Npoints,1), ... |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
316 (yl-3*h{2}) + (yr-yl+6*h{2})*rand(Npoints,1) ]; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
317 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
318 for j = 1:length(fs) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
319 f = fs{j}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
320 dfdx = dfdxs{j}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
321 dfdy = dfdys{j}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
322 fx = f(X(:,1), X(:,2)); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
323 for i = 1:length(x0s) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
324 x0 = x0s(i,:); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
325 |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
326 delta_x = diracPrimDiscr(x0, x, mom_cond, 0, H, 1); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
327 integral1 = delta_x'*H_global*fx; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
328 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
329 delta_y = diracPrimDiscr(x0, x, mom_cond, 0, H, 2); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
330 integral2 = delta_y'*H_global*fx; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
331 |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
332 % Integral should be 0 if point is outside grid |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
333 if x0(1) < xl || x0(1) > xr || x0(2) < yl || x0(2) > yr |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
334 err = abs(integral1 - 0) + abs(integral2 - 0); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
335 else |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
336 err = abs(integral1 + dfdx(x0(1), x0(2))) + abs(integral2 + dfdy(x0(1), x0(2))); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
337 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
338 testCase.verifyLessThan(err, 1e-12); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
339 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
340 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
341 end |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
342 end |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
343 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
344 %=============== 3D tests ============================== |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
345 % function testAllGP3D(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
346 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
347 % orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
348 % mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
349 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
350 % for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
351 % order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
352 % mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
353 % [xlims, ylims, zlims, m, x, X, h, H, fs] = setup3D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
354 % H_global = kron(kron(H{1}, H{2}), H{3}); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
355 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
356 % % Test all grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
357 % x0s = X; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
358 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
359 % for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
360 % f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
361 % fx = f(X(:,1), X(:,2), X(:,3)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
362 % for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
363 % x0 = x0s(i,:); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
364 % delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
365 % integral = delta'*H_global*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
366 % err = abs(integral - f(x0(1), x0(2), x0(3))); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
367 % testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
368 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
369 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
370 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
371 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
372 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
373 % function testAllRandom3D(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
374 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
375 % orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
376 % mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
377 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
378 % for o = 1:length(orders) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
379 % order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
380 % mom_cond = mom_conds(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
381 % [xlims, ylims, zlims, m, x, X, h, H, fs] = setup3D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
382 % H_global = kron(kron(H{1}, H{2}), H{3}); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
383 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
384 % xl = xlims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
385 % xr = xlims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
386 % yl = ylims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
387 % yr = ylims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
388 % zl = zlims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
389 % zr = zlims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
390 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
391 % % Test random points, even outside grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
392 % Npoints = 200; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
393 % x0s = [(xl-3*h{1}) + (xr-xl+6*h{1})*rand(Npoints,1), ... |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
394 % (yl-3*h{2}) + (yr-yl+6*h{2})*rand(Npoints,1), ... |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
395 % (zl-3*h{3}) + (zr-zl+6*h{3})*rand(Npoints,1) ]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
396 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
397 % for j = 1:length(fs) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
398 % f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
399 % fx = f(X(:,1), X(:,2), X(:,3)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
400 % for i = 1:length(x0s) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
401 % x0 = x0s(i,:); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
402 % delta = diracPrimDiscr(x0, x, mom_cond, 0, H); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
403 % integral = delta'*H_global*fx; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
404 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
405 % % Integral should be 0 if point is outside grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
406 % if x0(1) < xl || x0(1) > xr || x0(2) < yl || x0(2) > yr || x0(3) < zl || x0(3) > zr |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
407 % err = abs(integral - 0); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
408 % else |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
409 % err = abs(integral - f(x0(1), x0(2), x0(3))); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
410 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
411 % testCase.verifyLessThan(err, 1e-12); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
412 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
413 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
414 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
415 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
416 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
417 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
418 % ====================================================== |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
419 % ============== Setup functions ======================= |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
420 % ====================================================== |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
421 function [xl, xr, m, h, x, H, fs, fps] = setup1D(order, mom_cond) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
422 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
423 % Grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
424 xl = -3; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
425 xr = 900; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
426 L = xr-xl; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
427 m = 101; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
428 h = (xr-xl)/(m-1); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
429 g = grid.equidistant(m, {xl, xr}); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
430 x = g.points(); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
431 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
432 % Quadrature |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
433 ops = sbp.D2Standard(m, {xl, xr}, order); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
434 H = ops.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
435 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
436 % Moment conditions |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
437 fs = cell(mom_cond+1,1); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
438 fps = cell(mom_cond+1,1); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
439 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
440 for p = 0:mom_cond |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
441 fs{p+1} = @(x) (x/L).^p; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
442 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
443 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
444 fps{1} = @(x) 0*x; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
445 for p = 1:mom_cond |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
446 fps{p+1} = @(x) p/L*(x/L).^(p-1); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
447 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
448 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
449 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
450 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
451 function [xlims, ylims, m, x, X, h, H, fs, fxs, fys] = setup2D(order, mom_cond) |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
452 |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
453 % Grid |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
454 xlims = {-3, 20}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
455 ylims = {-11,5}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
456 Lx = xlims{2} - xlims{1}; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
457 Ly = ylims{2} - ylims{1}; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
458 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
459 m = [15, 16]; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
460 g = grid.equidistant(m, xlims, ylims); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
461 X = g.points(); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
462 x = g.x; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
463 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
464 % Quadrature |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
465 opsx = sbp.D2Standard(m(1), xlims, order); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
466 opsy = sbp.D2Standard(m(2), ylims, order); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
467 Hx = opsx.H; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
468 Hy = opsy.H; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
469 H = {Hx, Hy}; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
470 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
471 % Moment conditions |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
472 fs = cell(mom_cond+1,1); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
473 fxs = cell(mom_cond+1,1); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
474 fys = cell(mom_cond+1,1); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
475 for p = 0:mom_cond |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
476 fs{p+1} = @(x,y) (x/Lx + y/Ly).^p; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
477 end |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
478 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
479 fxs{1} = @(x,y) 0*x; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
480 fys{1} = @(x,y) 0*y; |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
481 for p = 1:mom_cond |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
482 fxs{p+1} = @(x,y) p/Lx*(x/Lx + y/Ly).^(p-1); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
483 fys{p+1} = @(x,y) p/Ly*(x/Lx + y/Ly).^(p-1); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
484 end |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
485 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
486 % Grid spacing in interior |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
487 mm = round(m/2); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
488 hx = x{1}(mm(1)+1) - x{1}(mm(1)); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
489 hy = x{2}(mm(2)+1) - x{2}(mm(2)); |
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
490 h = {hx, hy}; |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
491 |
1131
ea225a4659fe
Add 2d tests for derivative of delta function, and confirm that they work.
Martin Almquist <malmquist@stanford.edu>
parents:
1130
diff
changeset
|
492 end |
1130
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
493 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
494 % function [xlims, ylims, zlims, m, x, X, h, H, fs] = setup3D(order, mom_cond) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
495 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
496 % % Grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
497 % xlims = {-3, 20}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
498 % ylims = {-11,5}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
499 % zlims = {2,4}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
500 % Lx = xlims{2} - xlims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
501 % Ly = ylims{2} - ylims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
502 % Lz = zlims{2} - zlims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
503 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
504 % m = [13, 14, 15]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
505 % g = grid.equidistant(m, xlims, ylims, zlims); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
506 % X = g.points(); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
507 % x = g.x; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
508 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
509 % % Quadrature |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
510 % opsx = sbp.D2Standard(m(1), xlims, order); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
511 % opsy = sbp.D2Standard(m(2), ylims, order); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
512 % opsz = sbp.D2Standard(m(3), zlims, order); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
513 % Hx = opsx.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
514 % Hy = opsy.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
515 % Hz = opsz.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
516 % H = {Hx, Hy, Hz}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
517 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
518 % % Moment conditions |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
519 % fs = cell(mom_cond,1); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
520 % for p = 0:mom_cond-1 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
521 % fs{p+1} = @(x,y,z) (x/Lx + y/Ly + z/Lz).^p; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
522 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
523 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
524 % % Grid spacing in interior |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
525 % mm = round(m/2); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
526 % hx = x{1}(mm(1)+1) - x{1}(mm(1)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
527 % hy = x{2}(mm(2)+1) - x{2}(mm(2)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
528 % hz = x{3}(mm(3)+1) - x{3}(mm(3)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
529 % h = {hx, hy, hz}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
530 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
531 % end |