|
3 | 3 | % density rhohat to the requested depth using the backward recursion |
4 | 4 | % |
5 | 5 | % When using an RCIP preconditioner (in the style of eq 34 of the RCIP |
6 | | -% tutorial), the resulting coarse level density is |
7 | | -% accurate for interactions separated from the vertex |
8 | | -% *at the coarse scale*. |
| 6 | +% tutorial), the resulting coarse level density is accurate for |
| 7 | +% interactions separated from the vertex *at the coarse scale*. |
| 8 | +% |
9 | 9 | % By running the recursion for the RCIP preconditioner backwards, an |
10 | 10 | % equivalent density can be reconstructed on the fine mesh which is |
11 | 11 | % appropriate for closer interactions (at a distance well-separated from |
|
53 | 53 | % wts - a set of weights for integrating functions sampled at these |
54 | 54 | % points |
55 | 55 |
|
56 | | - % author: Travis Askham |
| 56 | +% author: Travis Askham |
57 | 57 |
|
58 | | -rhohatinterp = []; |
59 | | -srcinfo = []; |
60 | | -wts = []; |
61 | | - |
62 | | -k = rcipsav.k; |
63 | | -ndim = rcipsav.ndim; |
64 | 58 | nedge = rcipsav.nedge; |
65 | 59 | Pbc = rcipsav.Pbc; |
66 | | -PWbc = rcipsav.PWbc; |
67 | | -starL = rcipsav.starL; |
68 | | -starL1 = rcipsav.starL1; |
69 | | -starS = rcipsav.starS; |
70 | | -circL = rcipsav.circL; |
71 | | -circL1 = rcipsav.circL1; |
72 | | -circS = rcipsav.circS; |
73 | | -ilist = rcipsav.ilist; |
| 60 | + |
| 61 | +starL1 = sort(rcipsav.starL1); |
| 62 | +starS = sort(rcipsav.starS); |
| 63 | + |
| 64 | +circL1 = sort(rcipsav.circL1); |
| 65 | +circS = sort(rcipsav.circS); |
| 66 | + |
| 67 | +nrho = numel([circS,starS]); |
| 68 | +ndens = numel(rhohat)/nrho; |
| 69 | +rhohat = reshape(rhohat,[nrho, ndens]); |
| 70 | + |
74 | 71 | nsub = rcipsav.nsub; |
75 | 72 |
|
| 73 | +rhohatinterp = cell(nedge,1); |
| 74 | +srcinfo = cell(nedge,1); |
| 75 | +wts = cell(nedge,1); |
| 76 | + |
| 77 | +ileftright = rcipsav.ileftright; |
| 78 | + |
| 79 | +% figure out which edge the indices belong to |
| 80 | +% THIS ASSUMES WE HAVE THE SAME ORDER ON EDGES |
| 81 | +circSedge = cell(nedge,1); ncS = numel(circS)/nedge; |
| 82 | +circL1edge = cell(nedge,1); ncL1 = numel(circL1)/nedge; |
| 83 | +starSedge = cell(nedge,1); nsS = numel(starS)/nedge; |
| 84 | +starL1edge = cell(nedge,1); nsL1 = numel(starL1)/nedge; |
| 85 | +for j = 1:nedge |
| 86 | + circSedge{j} = circS((j-1)*ncS+1:j*ncS); |
| 87 | + circL1edge{j} = circL1((j-1)*ncL1+1:j*ncL1); |
| 88 | + starSedge{j} = starS((j-1)*nsS+1:j*nsS); |
| 89 | + starL1edge{j} = starL1((j-1)*nsL1+1:j*nsL1); |
| 90 | +end |
| 91 | + |
76 | 92 | if nargin < 3 |
77 | 93 | ndepth = nsub; |
78 | 94 | end |
|
84 | 100 | ndepth = nsub; |
85 | 101 | end |
86 | 102 |
|
87 | | -savedeep = rcipsav.savedeep; |
| 103 | +savedepth = rcipsav.savedepth; |
88 | 104 |
|
89 | | -if savedeep |
| 105 | +if ndepth <= savedepth |
90 | 106 |
|
91 | 107 | % all relevant quantities are stored, just run backward recursion |
92 | 108 |
|
93 | 109 | rhohat0 = rhohat; |
94 | | - rhohatinterp = [rhohatinterp; rhohat0(circS)]; |
95 | | - r = []; |
96 | | - d = []; |
97 | | - d2 = []; |
98 | | - n = []; |
99 | | - h = []; |
100 | 110 | cl = rcipsav.chnkrlocals{nsub}; |
101 | 111 | wt = weights(cl); |
102 | | - r = [r, cl.rstor(:,circL1)]; |
103 | | - d = [d, cl.dstor(:,circL1)]; |
104 | | - d2 = [d2, cl.d2stor(:,circL1)]; |
105 | | - n = [n, cl.nstor(:,circL1)]; |
106 | | - wts = [wts; wt(circL1(:))]; |
| 112 | + |
| 113 | + for j = 1:nedge |
| 114 | + rhohatinterp{j} = rhohat0(circSedge{j},:); |
| 115 | + srcinfo{j}.r = cl.rstor(:,circL1edge{j}); |
| 116 | + srcinfo{j}.d = cl.dstor(:,circL1edge{j}); |
| 117 | + srcinfo{j}.d2 = cl.d2stor(:,circL1edge{j}); |
| 118 | + srcinfo{j}.n = cl.nstor(:,circL1edge{j}); |
| 119 | + wts{j} = wt(circL1edge{j}); |
| 120 | + end |
107 | 121 |
|
108 | 122 | R0 = rcipsav.R{nsub+1}; |
109 | 123 | for i = 1:ndepth |
110 | 124 | R1 = rcipsav.R{nsub-i+1}; |
111 | 125 | MAT = rcipsav.MAT{nsub-i+1}; |
112 | 126 | rhotemp = R0\rhohat0; |
113 | | - rhohat0 = R1*(Pbc*rhotemp(starS) - MAT*rhohat0(circS)); |
| 127 | + rhohat0 = R1*(Pbc*rhotemp(starS,:) - MAT*rhohat0(circS,:)); |
114 | 128 | if i == ndepth |
115 | | - rhohatinterp = [rhohatinterp; rhohat0]; |
116 | | - r = [r, cl.rstor(:,starL1)]; |
117 | | - d = [d, cl.dstor(:,starL1)]; |
118 | | - d2 = [d2, cl.d2stor(:,starL1)]; |
119 | | - n = [n, cl.nstor(:,starL1)]; |
120 | 129 | wt = weights(cl); |
121 | | - |
122 | | - wts = [wts; wt(starL1(:))]; |
| 130 | + for j = 1:nedge |
| 131 | + if ileftright(j) == 1 |
| 132 | + rhohatinterp{j} = [rhohatinterp{j}; rhohat0([circSedge{j} starSedge{j}],:)]; |
| 133 | + else |
| 134 | + rhohatinterp{j} = [rhohatinterp{j}; rhohat0([starSedge{j} circSedge{j}],:)]; |
| 135 | + end |
| 136 | + srcinfo{j}.r = [srcinfo{j}.r, cl.rstor(:,starL1edge{j})]; |
| 137 | + srcinfo{j}.d = [srcinfo{j}.d, cl.dstor(:,starL1edge{j})]; |
| 138 | + srcinfo{j}.d2 = [srcinfo{j}.d2, cl.d2stor(:,starL1edge{j})]; |
| 139 | + srcinfo{j}.n = [srcinfo{j}.n, cl.nstor(:,starL1edge{j})]; |
| 140 | + wts{j} = [wts{j}, wt(starL1edge{j})]; |
| 141 | + end |
123 | 142 | else |
124 | 143 | cl = rcipsav.chnkrlocals{nsub-i}; |
125 | | - rhohatinterp = [rhohatinterp; rhohat0(circS)]; |
126 | | - r = [r, cl.rstor(:,circL1)]; |
127 | | - d = [d, cl.dstor(:,circL1)]; |
128 | | - d2 = [d2, cl.d2stor(:,circL1)]; |
129 | | - n = [n, cl.nstor(:,circL1)]; |
130 | 144 | wt = weights(cl); |
131 | | - wts = [wts; wt(circL1(:))]; |
| 145 | + for j = 1:nedge |
| 146 | + rhohatinterp{j} = [rhohatinterp{j}; rhohat0(circSedge{j},:)]; |
| 147 | + srcinfo{j}.r = [srcinfo{j}.r, cl.rstor(:,circL1edge{j})]; |
| 148 | + srcinfo{j}.d = [srcinfo{j}.d, cl.dstor(:,circL1edge{j})]; |
| 149 | + srcinfo{j}.d2 = [srcinfo{j}.d2, cl.d2stor(:,circL1edge{j})]; |
| 150 | + srcinfo{j}.n = [srcinfo{j}.n, cl.nstor(:,circL1edge{j})]; |
| 151 | + wts{j} = [wts{j}, wt(circL1edge{j})]; |
| 152 | + end |
132 | 153 | end |
133 | 154 | R0 = R1; |
134 | 155 | end |
135 | 156 |
|
136 | | - srcinfo.r = r; |
137 | | - srcinfo.d = d; |
138 | | - srcinfo.d2 = d2; |
139 | | - srcinfo.n = n; |
140 | | - |
141 | 157 | end |
0 commit comments