Mercurial > repos > public > sbplib
annotate diracPrimDiscrTest.m @ 1130:99fd66ffe714 feature/laplace_curvilinear_test
Add derivative of delta functions and corresponding tests, tested for 1D.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 21 May 2019 18:44:01 -0700 |
parents | |
children | ea225a4659fe |
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 ============================== |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
261 % function testAllGP2D(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
262 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
263 % orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
264 % mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
265 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
266 % 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
|
267 % order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
268 % 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
|
269 % [xlims, ylims, m, x, X, ~, H, fs] = setup2D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
270 % H_global = kron(H{1}, H{2}); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
271 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
272 % % Test all grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
273 % x0s = X; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
274 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
275 % 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
|
276 % f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
277 % fx = f(X(:,1), X(:,2)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
278 % 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
|
279 % x0 = x0s(i,:); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
280 % 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
|
281 % 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
|
282 % err = abs(integral - f(x0(1), x0(2))); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
283 % 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
|
284 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
285 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
286 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
287 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
288 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
289 % function testAllRandom2D(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
290 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
291 % orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
292 % mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
293 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
294 % 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
|
295 % order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
296 % 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
|
297 % [xlims, ylims, m, x, X, h, H, fs] = setup2D(order, mom_cond); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
298 % H_global = kron(H{1}, H{2}); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
299 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
300 % xl = xlims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
301 % xr = xlims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
302 % yl = ylims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
303 % yr = ylims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
304 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
305 % % 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
|
306 % Npoints = 100; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
307 % 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
|
308 % (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
|
309 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
310 % 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
|
311 % f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
312 % fx = f(X(:,1), X(:,2)); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
313 % 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
|
314 % x0 = x0s(i,:); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
315 % 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
|
316 % 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
|
317 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
318 % % 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
|
319 % if x0(1) < xl || x0(1) > xr || x0(2) < yl || x0(2) > yr |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
320 % err = abs(integral - 0); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
321 % else |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
322 % err = abs(integral - f(x0(1), x0(2))); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
323 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
324 % 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
|
325 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
326 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
327 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
328 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
329 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
330 %=============== 3D tests ============================== |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
331 % function testAllGP3D(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
332 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
333 % orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
334 % mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
335 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
336 % 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
|
337 % order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
338 % 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
|
339 % [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
|
340 % 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
|
341 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
342 % % Test all grid points |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
343 % x0s = X; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
344 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
345 % 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
|
346 % f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
347 % 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
|
348 % 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
|
349 % x0 = x0s(i,:); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
350 % 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
|
351 % 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
|
352 % 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
|
353 % 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
|
354 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
355 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
356 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
357 % end |
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 % function testAllRandom3D(testCase) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
360 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
361 % orders = [2, 4, 6]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
362 % mom_conds = orders; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
363 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
364 % 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
|
365 % order = orders(o); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
366 % 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
|
367 % [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
|
368 % 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
|
369 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
370 % xl = xlims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
371 % xr = xlims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
372 % yl = ylims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
373 % yr = ylims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
374 % zl = zlims{1}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
375 % zr = zlims{2}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
376 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
377 % % 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
|
378 % Npoints = 200; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
379 % 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
|
380 % (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
|
381 % (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
|
382 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
383 % 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
|
384 % f = fs{j}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
385 % 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
|
386 % 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
|
387 % x0 = x0s(i,:); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
388 % 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
|
389 % 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
|
390 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
391 % % 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
|
392 % 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
|
393 % err = abs(integral - 0); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
394 % else |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
395 % 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
|
396 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
397 % 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
|
398 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
399 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
400 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
401 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
402 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
403 |
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 % ============== Setup functions ======================= |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
406 % ====================================================== |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
407 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
|
408 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
409 % Grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
410 xl = -3; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
411 xr = 900; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
412 L = xr-xl; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
413 m = 101; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
414 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
|
415 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
|
416 x = g.points(); |
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 % Quadrature |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
419 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
|
420 H = ops.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
421 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
422 % Moment conditions |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
423 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
|
424 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
|
425 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
426 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
|
427 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
|
428 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
429 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
430 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
|
431 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
|
432 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
|
433 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
434 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
435 end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
436 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
437 % function [xlims, ylims, m, x, X, h, H, fs] = setup2D(order, mom_cond) |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
438 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
439 % % Grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
440 % xlims = {-3, 20}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
441 % ylims = {-11,5}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
442 % 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
|
443 % 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
|
444 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
445 % m = [15, 16]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
446 % g = grid.equidistant(m, xlims, ylims); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
447 % X = g.points(); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
448 % x = g.x; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
449 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
450 % % Quadrature |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
451 % 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
|
452 % 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
|
453 % Hx = opsx.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
454 % Hy = opsy.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
455 % H = {Hx, Hy}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
456 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
457 % % Moment conditions |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
458 % 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
|
459 % 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
|
460 % fs{p+1} = @(x,y) (x/Lx + y/Ly).^p; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
461 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
462 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
463 % % Grid spacing in interior |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
464 % mm = round(m/2); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
465 % 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
|
466 % 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
|
467 % h = {hx, hy}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
468 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
469 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
470 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
471 % 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
|
472 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
473 % % Grid |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
474 % xlims = {-3, 20}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
475 % ylims = {-11,5}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
476 % zlims = {2,4}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
477 % 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
|
478 % 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
|
479 % 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
|
480 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
481 % m = [13, 14, 15]; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
482 % 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
|
483 % X = g.points(); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
484 % x = g.x; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
485 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
486 % % Quadrature |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
487 % 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
|
488 % 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
|
489 % 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
|
490 % Hx = opsx.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
491 % Hy = opsy.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
492 % Hz = opsz.H; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
493 % H = {Hx, Hy, Hz}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
494 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
495 % % Moment conditions |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
496 % 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
|
497 % 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
|
498 % 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
|
499 % end |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
500 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
501 % % Grid spacing in interior |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
502 % mm = round(m/2); |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
503 % 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
|
504 % 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
|
505 % 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
|
506 % h = {hx, hy, hz}; |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
507 |
99fd66ffe714
Add derivative of delta functions and corresponding tests, tested for 1D.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
508 % end |