|
@@ -11,8 +11,9 @@
|
11
|
11
|
* @file
|
12
|
12
|
* @date 11/11/2016 01:47:25 PM
|
13
|
13
|
* @author Trevor Irons (ti)
|
14
|
|
- * @email tirons@egi.utah.edu
|
|
14
|
+ * @email Trevor.Irons@lemmasoftware.org
|
15
|
15
|
* @copyright Copyright (c) 2016, University of Utah
|
|
16
|
+ * @copyright Copyright (c) 2019, Trevor P. Irons
|
16
|
17
|
* @copyright Copyright (c) 2016, Lemma Software, LLC
|
17
|
18
|
* @copyright Copyright (c) 2008, Colorado School of Mines
|
18
|
19
|
*/
|
|
@@ -253,7 +254,7 @@ namespace Lemma {
|
253
|
254
|
} else {
|
254
|
255
|
#ifdef LEMMAUSEVTK
|
255
|
256
|
vtkHyperTreeGrid* oct = vtkHyperTreeGrid::New();
|
256
|
|
-
|
|
257
|
+ oct->SetGridSize( 1, 1, 1 ); // Important!
|
257
|
258
|
oct->SetDimension(3);
|
258
|
259
|
vtkNew<vtkDoubleArray> xcoords;
|
259
|
260
|
xcoords->SetNumberOfComponents(1);
|
|
@@ -280,59 +281,71 @@ namespace Lemma {
|
280
|
281
|
oct->SetZCoordinates(zcoords);
|
281
|
282
|
|
282
|
283
|
//vtkHyperTreeGridLevelEntry* curse2 = vtkHyperTreeGridLevelEntry::New(); // VTK 9
|
283
|
|
- //std::cout << *oct << std::endl;
|
284
|
|
- // TODO, check the index in NewCursor maybe points to which cell in the Rectilinear Grid?
|
|
284
|
+ // I belive the index in NewCursor maybe points to which cell in the Rectilinear Grid?
|
285
|
285
|
vtkHyperTreeCursor* curse = oct->NewCursor(0, true); // true creates the cursor
|
286
|
286
|
curse->ToRoot();
|
287
|
287
|
EvaluateKids2( Size, 0, cpos, VectorXcr::Ones(PulseI.size()), oct, curse );
|
288
|
288
|
|
289
|
289
|
for (int iq=0; iq<PulseI.size(); ++iq) {
|
|
290
|
+
|
290
|
291
|
// Fill in leaf data
|
291
|
292
|
vtkDoubleArray* kr = vtkDoubleArray::New();
|
292
|
293
|
kr->SetNumberOfComponents(1);
|
293
|
294
|
kr->SetName("Re($\\mathcal{K}_0$)");
|
294
|
295
|
kr->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
296
|
+
|
295
|
297
|
vtkDoubleArray* ki = vtkDoubleArray::New();
|
296
|
298
|
ki->SetNumberOfComponents(1);
|
297
|
299
|
ki->SetName("Im($\\mathcal{K}_0$)");
|
298
|
300
|
ki->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
301
|
+
|
299
|
302
|
vtkDoubleArray* km = vtkDoubleArray::New();
|
300
|
303
|
km->SetNumberOfComponents(1);
|
301
|
304
|
km->SetName("mod($\\mathcal{K}_0$)");
|
302
|
305
|
km->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
306
|
+
|
303
|
307
|
vtkIntArray* kid = vtkIntArray::New();
|
304
|
308
|
kid->SetNumberOfComponents(1);
|
305
|
309
|
kid->SetName("ID");
|
306
|
310
|
kid->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
311
|
+
|
307
|
312
|
vtkIntArray* kerr = vtkIntArray::New();
|
308
|
313
|
kerr->SetNumberOfComponents(1);
|
309
|
314
|
kerr->SetName("err");
|
310
|
315
|
kerr->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
316
|
+
|
311
|
317
|
// Ht field
|
312
|
318
|
vtkDoubleArray* htr = vtkDoubleArray::New();
|
313
|
319
|
htr->SetNumberOfComponents(3);
|
314
|
320
|
htr->SetName("Re($\\mathbf{\\mathcal{H}}_T$)");
|
315
|
321
|
htr->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
322
|
+
|
316
|
323
|
vtkDoubleArray* hti = vtkDoubleArray::New();
|
317
|
324
|
hti->SetNumberOfComponents(3);
|
318
|
325
|
hti->SetName("Im($\\mathbf{\\mathcal{H}}_T$)");
|
319
|
326
|
hti->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
327
|
+
|
320
|
328
|
// Hr field
|
321
|
329
|
vtkDoubleArray* hrr = vtkDoubleArray::New();
|
322
|
330
|
hrr->SetNumberOfComponents(3);
|
323
|
331
|
hrr->SetName("Re($\\mathbf{\\mathcal{H}}_R$)");
|
324
|
332
|
hrr->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
|
333
|
+
|
325
|
334
|
vtkDoubleArray* hri = vtkDoubleArray::New();
|
326
|
335
|
hri->SetNumberOfComponents(3);
|
327
|
336
|
hri->SetName("Im($\\mathbf{\\mathcal{H}}_R$)");
|
328
|
337
|
hri->SetNumberOfTuples( oct->GetNumberOfLeaves() );
|
329
|
338
|
//Real LeafVol(0);
|
|
339
|
+
|
|
340
|
+ //kr->Fill(0);
|
|
341
|
+ int icc(0);
|
330
|
342
|
for (auto leaf : LeafDict) {
|
331
|
343
|
kr->InsertTuple1( leaf.first, std::real(leaf.second(iq)) );
|
332
|
344
|
ki->InsertTuple1( leaf.first, std::imag(leaf.second(iq)) );
|
333
|
345
|
km->InsertTuple1( leaf.first, std::abs(leaf.second(iq)) );
|
334
|
346
|
kid->InsertTuple1( leaf.first, leaf.first );
|
335
|
347
|
//LeafVol += std::real(leaf.second);
|
|
348
|
+ ++icc;
|
336
|
349
|
}
|
337
|
350
|
|
338
|
351
|
for (auto leaf : LeafHt ) {
|
|
@@ -348,38 +361,42 @@ namespace Lemma {
|
348
|
361
|
for (auto leaf : LeafDictIdx) {
|
349
|
362
|
kerr->InsertTuple1( leaf.first, leaf.second );
|
350
|
363
|
}
|
351
|
|
-/* TODO fix
|
352
|
|
- auto kri = oct->GetCellData()->AddArray(kr);
|
353
|
|
- auto kii = oct->GetCellData()->AddArray(ki);
|
354
|
|
- auto kmi = oct->GetCellData()->AddArray(km);
|
355
|
|
- auto kidi = oct->GetCellData()->AddArray(kid);
|
356
|
|
- auto keri = oct->GetCellData()->AddArray(kerr);
|
357
|
|
- auto khtr = oct->GetCellData()->AddArray(htr);
|
358
|
|
- auto khti = oct->GetCellData()->AddArray(hti);
|
359
|
|
- auto khrr = oct->GetCellData()->AddArray(hrr);
|
360
|
|
- auto khri = oct->GetCellData()->AddArray(hri);
|
361
|
|
-*/
|
362
|
|
- std::cout << "Writing file...Number of leaves: " << oct->GetNumberOfLeaves() << std::endl;
|
|
364
|
+
|
|
365
|
+ // In VTK 8, vtkHyperTreeGrid does not support CellData.
|
|
366
|
+ // the previous class vtkHyperOctreeGrid used "LeafData",
|
|
367
|
+ // but for the new classes, PointData seems to function as LeafData.
|
|
368
|
+ // this could change in VTK 9
|
|
369
|
+ auto kri = oct->GetPointData()->AddArray(kr);
|
|
370
|
+ auto kii = oct->GetPointData()->AddArray(ki);
|
|
371
|
+ auto kmi = oct->GetPointData()->AddArray(km);
|
|
372
|
+ auto kidi = oct->GetPointData()->AddArray(kid);
|
|
373
|
+ auto keri = oct->GetPointData()->AddArray(kerr);
|
|
374
|
+ auto khtr = oct->GetPointData()->AddArray(htr);
|
|
375
|
+ auto khti = oct->GetPointData()->AddArray(hti);
|
|
376
|
+ auto khrr = oct->GetPointData()->AddArray(hrr);
|
|
377
|
+ auto khri = oct->GetPointData()->AddArray(hri);
|
|
378
|
+
|
|
379
|
+ //std::cout << *oct << std::endl;
|
363
|
380
|
auto write = vtkXMLHyperTreeGridWriter::New();
|
364
|
381
|
std::string fname = std::string("octree-") + to_string(ilay)
|
365
|
382
|
+ std::string("-") + to_string(iq) + std::string(".htg");
|
366
|
383
|
write->SetFileName(fname.c_str());
|
367
|
384
|
write->SetInputData(oct);
|
368
|
385
|
write->SetDataModeToBinary();
|
369
|
|
- //write.SetDataModeToAscii()
|
370
|
|
- //write->Update();
|
|
386
|
+ //write->SetDataModeToAscii();
|
|
387
|
+ write->Update();
|
371
|
388
|
write->Write();
|
372
|
389
|
write->Delete();
|
373
|
|
-/*
|
374
|
|
- oct->GetLeafData()->RemoveArray( kri );
|
375
|
|
- oct->GetLeafData()->RemoveArray( kii );
|
376
|
|
- oct->GetLeafData()->RemoveArray( kmi );
|
377
|
|
- oct->GetLeafData()->RemoveArray( kidi );
|
378
|
|
- oct->GetLeafData()->RemoveArray( keri );
|
379
|
|
- oct->GetLeafData()->RemoveArray( khtr );
|
380
|
|
- oct->GetLeafData()->RemoveArray( khti );
|
381
|
|
- oct->GetLeafData()->RemoveArray( khrr );
|
382
|
|
- oct->GetLeafData()->RemoveArray( khri );
|
|
390
|
+
|
|
391
|
+ oct->GetPointData()->RemoveArray( kri );
|
|
392
|
+ oct->GetPointData()->RemoveArray( kii );
|
|
393
|
+ oct->GetPointData()->RemoveArray( kmi );
|
|
394
|
+ oct->GetPointData()->RemoveArray( kidi );
|
|
395
|
+ oct->GetPointData()->RemoveArray( keri );
|
|
396
|
+ oct->GetPointData()->RemoveArray( khtr );
|
|
397
|
+ oct->GetPointData()->RemoveArray( khti );
|
|
398
|
+ oct->GetPointData()->RemoveArray( khrr );
|
|
399
|
+ oct->GetPointData()->RemoveArray( khri );
|
383
|
400
|
|
384
|
401
|
kerr->Delete();
|
385
|
402
|
kid->Delete();
|
|
@@ -390,8 +407,8 @@ namespace Lemma {
|
390
|
407
|
hti->Delete();
|
391
|
408
|
hrr->Delete();
|
392
|
409
|
hri->Delete();
|
393
|
|
-*/
|
394
|
410
|
}
|
|
411
|
+
|
395
|
412
|
curse->Delete();
|
396
|
413
|
oct->Delete();
|
397
|
414
|
#else
|
|
@@ -656,9 +673,8 @@ namespace Lemma {
|
656
|
673
|
VectorXcr ksum = kvals.colwise().sum(); // Kernel sum
|
657
|
674
|
// Evaluate whether or not furthur splitting is needed
|
658
|
675
|
if ( (((ksum - parentVal).array().abs() > tol).any() && level<maxLevel) || level < minLevel ) {
|
659
|
|
- // TODO Fix, 0 after curse is vtkIdType?
|
|
676
|
+ // 0 after curse is vtkIdType?
|
660
|
677
|
oct->SubdivideLeaf(curse, 0);
|
661
|
|
- //std::cout << "Number of leaves: " << oct->GetNumberOfLeaves() << std::endl;
|
662
|
678
|
for (int ichild=0; ichild<8; ++ichild) {
|
663
|
679
|
curse->ToChild(ichild);
|
664
|
680
|
Vector3r cp = pos; // Eigen complains about combining these
|
|
@@ -687,19 +703,15 @@ namespace Lemma {
|
687
|
703
|
/* Alternatively, subdivide the VTK octree here and stuff the children to make better
|
688
|
704
|
* visuals, but also 8x the storage...
|
689
|
705
|
*/
|
690
|
|
- // TODO Fix, 0 after curse is vtkIdType?
|
|
706
|
+
|
|
707
|
+ // 0 after curse is vtkIdType?
|
691
|
708
|
oct->SubdivideLeaf(curse, 0);
|
692
|
709
|
for (int ichild=0; ichild<8; ++ichild) {
|
693
|
710
|
curse->ToChild(ichild);
|
694
|
|
- // TODO fix, GetLeafId to GetLevel??
|
695
|
|
- //LeafDict[curse->GetLeafId()] = ksum/(8.*vol);
|
696
|
|
- //LeafHt[curse->GetLeafId()] = Ht.col(ichild);
|
697
|
|
- //LeafHr[curse->GetLeafId()] = Hr.col(ichild);
|
698
|
|
- //LeafDictIdx[curse->GetLeafId()] = nleaves;
|
699
|
|
- LeafDict[curse->GetLevel()] = ksum/(8.*vol);
|
700
|
|
- LeafHt[curse->GetLevel()] = Ht.col(ichild);
|
701
|
|
- LeafHr[curse->GetLevel()] = Hr.col(ichild);
|
702
|
|
- LeafDictIdx[curse->GetLevel()] = nleaves;
|
|
711
|
+ LeafDict[curse->GetVertexId()] = ksum/(8.*vol);
|
|
712
|
+ LeafHt[curse->GetVertexId()] = Ht.col(ichild);
|
|
713
|
+ LeafHr[curse->GetVertexId()] = Hr.col(ichild);
|
|
714
|
+ LeafDictIdx[curse->GetVertexId()] = nleaves;
|
703
|
715
|
curse->ToParent();
|
704
|
716
|
}
|
705
|
717
|
|