annotate diracDiscrTest.m @ 1138:afd06a84b69c feature/laplace_curvilinear_test

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