|
@@ -128,12 +128,112 @@ namespace Lemma {
|
128
|
128
|
|
129
|
129
|
}
|
130
|
130
|
|
131
|
|
- void KernelV0::CalculateK0 ( const char* tx, const char* rx ) {
|
|
131
|
+ //--------------------------------------------------------------------------------------
|
|
132
|
+ // Class: KernelV0
|
|
133
|
+ // Method: IntegrateOnOctreeGrid
|
|
134
|
+ //--------------------------------------------------------------------------------------
|
|
135
|
+ void KernelV0::IntegrateOnOctreeGrid( const Real& tolerance) {
|
|
136
|
+
|
|
137
|
+ Vector3r Size;
|
|
138
|
+ Vector3r Origin;
|
|
139
|
+ Vector3r step;
|
|
140
|
+ Vector3r cpos;
|
|
141
|
+
|
|
142
|
+ int level;
|
|
143
|
+ int maxlevel;
|
|
144
|
+ int index;
|
|
145
|
+ int counter;
|
|
146
|
+
|
|
147
|
+ Real cvol;
|
|
148
|
+ Real tvol;
|
|
149
|
+ Real tol;
|
|
150
|
+ Complex KernelSum;
|
|
151
|
+
|
|
152
|
+ //this->tol = tolerance;
|
|
153
|
+ Real KernelSum = 0.;
|
|
154
|
+ //Cursor->ToRoot();
|
|
155
|
+ //Cubes->SetNumberOfReceivers(8);
|
|
156
|
+ EvaluateKids( 1e9 ); // Large initial number don't waste time actually computing
|
|
157
|
+ //EvaluateKids();
|
|
158
|
+ //std::cout << "Kernel Sum from Generate Mesh "
|
|
159
|
+ // << std::real(KernelSum) << "\t" << std::imag(KernelSum) << std::endl;
|
|
160
|
+
|
|
161
|
+ // old VTK thingy
|
|
162
|
+ //SetLeafDataFromGridCreation();
|
|
163
|
+ }
|
|
164
|
+
|
|
165
|
+ //--------------------------------------------------------------------------------------
|
|
166
|
+ // Class: KernelV0
|
|
167
|
+ // Method: EvaluateKids
|
|
168
|
+ //--------------------------------------------------------------------------------------
|
|
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
|
+ //std::cout.flush();
|
|
179
|
+ for (int child=0; child<8; ++child) {
|
|
180
|
+ Cursor->ToChild(child);
|
|
181
|
+ assert(Cursor->CurrentIsLeaf());
|
|
182
|
+ // Build cube
|
|
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
|
+ //std::cout << "child " << child << " cpos\t" << cpos.transpose() << std::endl;
|
|
189
|
+ //std::cout << "child " << child << " step\t" << step.transpose() << std::endl;
|
|
190
|
+ Cursor->ToSameNode(tcurse);
|
|
191
|
+ }
|
132
|
192
|
|
|
193
|
+ // make calculation
|
|
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
|
+ // stop subdividing, save result
|
|
199
|
+ for (int child=0; child < 8; ++ child) {
|
|
200
|
+ Cursor->ToChild(child);
|
|
201
|
+ leafdata.push_back( std::abs(f(child)) / Cubes->GetVolume(child) );
|
|
202
|
+ // TODO fval is just a test
|
|
203
|
+ //leafdata.push_back( fval );
|
|
204
|
+ leafids.push_back(Cursor->GetLeafId());
|
|
205
|
+ KernelSum += f(child);
|
|
206
|
+ Cursor->ToParent();
|
|
207
|
+ }
|
|
208
|
+ return;
|
|
209
|
+ }
|
|
210
|
+
|
|
211
|
+ //std::cout << std::abs(kval) << "\t" <<
|
|
212
|
+ // std::abs(f.array().abs().sum()) << "\t" << tol << std::endl;
|
|
213
|
+ for (int child=0; child < 8; ++ child) {
|
|
214
|
+ //std::cout << "Down the rabit hole " <<std::endl;
|
|
215
|
+ Cursor->ToChild(child);
|
|
216
|
+ EvaluateKids( f(child) );
|
|
217
|
+ //Cursor->ToParent();
|
|
218
|
+ Cursor->ToSameNode(tcurse);
|
|
219
|
+ }
|
|
220
|
+ tcurse->Delete();
|
|
221
|
+ }
|
|
222
|
+
|
|
223
|
+ //--------------------------------------------------------------------------------------
|
|
224
|
+ // Class: KernelV0
|
|
225
|
+ // Method: EvaluateKids
|
|
226
|
+ //--------------------------------------------------------------------------------------
|
|
227
|
+ void OctreeGrid::GetPosition( Real* p ) {
|
|
228
|
+ Real ratio=1.0/(1<<(Cursor->GetCurrentLevel()));
|
|
229
|
+ //step = ((Size).array() / std::pow(2.,Cursor->GetCurrentLevel()));
|
|
230
|
+ p[0]=(Cursor->GetIndex(0)+.5)*ratio*Size[0]+Origin[0] ;//+ .5*step[0];
|
|
231
|
+ p[1]=(Cursor->GetIndex(1)+.5)*ratio*Size[1]+Origin[1] ;//+ .5*step[1];
|
|
232
|
+ p[2]=(Cursor->GetIndex(2)+.5)*ratio*Size[2]+Origin[2] ;//+ .5*step[2];
|
133
|
233
|
}
|
134
|
234
|
|
135
|
235
|
} // ---- end of namespace Lemma ----
|
136
|
236
|
|
137
|
|
-/* vim: set tabstop=4 expandtab: */
|
138
|
|
-/* vim: set filetype=cpp: */
|
|
237
|
+/* vim: set tabstop=4 expandtab */
|
|
238
|
+/* vim: set filetype=cpp */
|
139
|
239
|
|