|
@@ -114,6 +114,8 @@ namespace Lemma {
|
114
|
114
|
|
115
|
115
|
EmEarth->SetHankelTransformMethod(ANDERSON801);
|
116
|
116
|
|
|
117
|
+ IntegrateOnOctreeGrid( 1e-2 );
|
|
118
|
+
|
117
|
119
|
|
118
|
120
|
|
119
|
121
|
|
|
@@ -134,102 +136,78 @@ namespace Lemma {
|
134
|
136
|
|
135
|
137
|
void KernelV0::IntegrateOnOctreeGrid( const Real& tolerance) {
|
136
|
138
|
|
|
139
|
+ this->tol = tolerance;
|
137
|
140
|
Vector3r Size;
|
138
|
|
- Vector3r Origin;
|
139
|
|
- Vector3r step;
|
|
141
|
+ Size << 100,100,100;
|
|
142
|
+
|
140
|
143
|
Vector3r cpos;
|
141
|
|
-
|
142
|
|
- int level;
|
|
144
|
+ cpos << 50,50,50;
|
143
|
145
|
int maxlevel;
|
144
|
|
- int index;
|
145
|
|
- int counter;
|
146
|
|
-
|
147
|
|
- Real cvol;
|
148
|
|
- Real tvol;
|
149
|
|
- Real tol;
|
150
|
|
- Complex KernelSum;
|
151
|
|
-
|
152
|
|
-
|
153
|
|
- Real KernelSum = 0.;
|
154
|
|
-
|
155
|
|
-
|
156
|
|
- EvaluateKids( 1e9 );
|
157
|
|
-
|
158
|
|
-
|
159
|
|
-
|
160
|
|
-
|
161
|
|
-
|
162
|
|
-
|
|
146
|
+
|
|
147
|
+ SUM = 0;
|
|
148
|
+ nleaves = 0;
|
|
149
|
+ EvaluateKids( Size, 0, cpos, -1e2 );
|
|
150
|
+ std::cout << "SUM\t" << SUM << "\t" << 100*100*100 << "\t" << SUM - Complex(100.*100.*100.) << std::endl;
|
|
151
|
+ std::cout << "nleaves\t" << nleaves << std::endl;
|
|
152
|
+
|
163
|
153
|
}
|
164
|
154
|
|
165
|
155
|
|
166
|
156
|
|
167
|
|
-
|
|
157
|
+
|
168
|
158
|
|
169
|
|
- void KernelV0::EvaluateKids(const Complex& kval) {
|
170
|
|
-
|
171
|
|
- assert("Evaluate Kids pre" && Cursor->CurrentIsLeaf());
|
172
|
|
- vtkHyperOctreeCursor *tcurse = Cursor->Clone();
|
173
|
|
- Real p[3];
|
174
|
|
- Octree->SubdivideLeaf(Cursor);
|
175
|
|
- tcurse->ToSameNode(Cursor);
|
176
|
|
- std::cout << "\rPredivide Leaf count: " << Octree->GetNumberOfLeaves();
|
177
|
|
-
|
178
|
|
-
|
179
|
|
- for (int child=0; child<8; ++child) {
|
180
|
|
- Cursor->ToChild(child);
|
181
|
|
- assert(Cursor->CurrentIsLeaf());
|
182
|
|
-
|
183
|
|
- GetPosition(p);
|
184
|
|
- cpos << p[0], p[1], p[2];
|
185
|
|
- step = ((Size).array() / std::pow(2.,Cursor->GetCurrentLevel()));
|
186
|
|
- Cubes->SetLocation(child, cpos);
|
187
|
|
- Cubes->SetLength(child, step);
|
188
|
|
-
|
189
|
|
-
|
190
|
|
- Cursor->ToSameNode(tcurse);
|
191
|
|
- }
|
192
|
|
-
|
193
|
|
-
|
194
|
|
- Cubes->ClearFields();
|
195
|
|
- VectorXcr f = SenseKernel->ComputeSensitivity();
|
196
|
|
- if ( std::abs(std::abs(kval) - std::abs(f.array().abs().sum())) <= tol ||
|
197
|
|
- Cursor->GetCurrentLevel() >= maxlevel ) {
|
198
|
|
-
|
199
|
|
- for (int child=0; child < 8; ++ child) {
|
200
|
|
- Cursor->ToChild(child);
|
201
|
|
- leafdata.push_back( std::abs(f(child)) / Cubes->GetVolume(child) );
|
202
|
|
-
|
203
|
|
-
|
204
|
|
- leafids.push_back(Cursor->GetLeafId());
|
205
|
|
- KernelSum += f(child);
|
206
|
|
- Cursor->ToParent();
|
207
|
|
- }
|
208
|
|
- return;
|
209
|
|
- }
|
210
|
|
-
|
211
|
|
-
|
212
|
|
-
|
213
|
|
- for (int child=0; child < 8; ++ child) {
|
214
|
|
-
|
215
|
|
- Cursor->ToChild(child);
|
216
|
|
- EvaluateKids( f(child) );
|
217
|
|
-
|
218
|
|
- Cursor->ToSameNode(tcurse);
|
219
|
|
- }
|
220
|
|
- tcurse->Delete();
|
|
159
|
+ Complex KernelV0::f( const Vector3r& r, const Real& volume ) {
|
|
160
|
+ return Complex(volume);
|
221
|
161
|
}
|
222
|
162
|
|
223
|
163
|
|
224
|
164
|
|
225
|
165
|
|
226
|
166
|
|
227
|
|
- void OctreeGrid::GetPosition( Real* p ) {
|
228
|
|
- Real ratio=1.0/(1<<(Cursor->GetCurrentLevel()));
|
229
|
|
-
|
230
|
|
- p[0]=(Cursor->GetIndex(0)+.5)*ratio*Size[0]+Origin[0] ;
|
231
|
|
- p[1]=(Cursor->GetIndex(1)+.5)*ratio*Size[1]+Origin[1] ;
|
232
|
|
- p[2]=(Cursor->GetIndex(2)+.5)*ratio*Size[2]+Origin[2] ;
|
|
167
|
+ bool KernelV0::EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
|
|
168
|
+ const Complex& parentVal ) {
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+ Vector3r step = size.array() / (Real)(1 << (level+2) );
|
|
173
|
+
|
|
174
|
+ Real vol = step(0)*step(1)*step(2);
|
|
175
|
+
|
|
176
|
+ Vector3r pos = cpos - step/2.;
|
|
177
|
+ Eigen::Matrix<Real, 8, 3> posadd = (Eigen::Matrix<Real, 8, 3>() <<
|
|
178
|
+ 0, 0, 0,
|
|
179
|
+ step[0], 0, 0,
|
|
180
|
+ 0, step[1], 0,
|
|
181
|
+ step[0], step[1], 0,
|
|
182
|
+ 0, 0, step[2],
|
|
183
|
+ step[0], 0, step[2],
|
|
184
|
+ 0, step[1], step[2],
|
|
185
|
+ step[0], step[1], step[2] ).finished();
|
|
186
|
+
|
|
187
|
+ VectorXcr kvals(8);
|
|
188
|
+ for (int ichild=0; ichild<8; ++ichild) {
|
|
189
|
+ Vector3r cp = pos;
|
|
190
|
+ cp += posadd.row(ichild);
|
|
191
|
+ kvals(ichild) = f(cp, vol);
|
|
192
|
+ }
|
|
193
|
+ Complex ksum = kvals.sum();
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+ if ( std::abs(ksum - parentVal) > tol || level < 5 ) {
|
|
197
|
+ for (int ichild=0; ichild<8; ++ichild) {
|
|
198
|
+ Vector3r cp = pos;
|
|
199
|
+ cp += posadd.row(ichild);
|
|
200
|
+ bool isleaf = EvaluateKids( size, level+1, pos, kvals(ichild) );
|
|
201
|
+ if (isleaf) {
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+ SUM += ksum;
|
|
205
|
+ nleaves += 1;
|
|
206
|
+ }
|
|
207
|
+ }
|
|
208
|
+ return false;
|
|
209
|
+ }
|
|
210
|
+ return true;
|
233
|
211
|
}
|
234
|
212
|
|
235
|
213
|
}
|