annotate diracDiscrTest.m @ 969:adae8063ea2f feature/poroelastic

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