|
@@ -252,11 +252,37 @@ namespace Lemma {
|
252
|
252
|
EvaluateKids( Size, 0, cpos, VectorXcr::Ones(PulseI.size()) );
|
253
|
253
|
} else {
|
254
|
254
|
#ifdef LEMMAUSEVTK
|
255
|
|
- vtkHyperOctree* oct = vtkHyperOctree::New();
|
|
255
|
+ vtkHyperTreeGrid* oct = vtkHyperTreeGrid::New();
|
|
256
|
+
|
256
|
257
|
oct->SetDimension(3);
|
257
|
|
- oct->SetOrigin( Origin(0), Origin(1), Origin(2) );
|
258
|
|
- oct->SetSize( Size(0), Size(1), Size(2) );
|
259
|
|
- vtkHyperOctreeCursor* curse = oct->NewCellCursor();
|
|
258
|
+ vtkNew<vtkDoubleArray> xcoords;
|
|
259
|
+ xcoords->SetNumberOfComponents(1);
|
|
260
|
+ xcoords->SetNumberOfTuples(2);
|
|
261
|
+ xcoords->SetTuple1( 0, Origin(0) );
|
|
262
|
+ xcoords->SetTuple1( 1, Origin(0) + Size(0) );
|
|
263
|
+ xcoords->SetName("northing (m)");
|
|
264
|
+ oct->SetXCoordinates(xcoords);
|
|
265
|
+
|
|
266
|
+ vtkNew<vtkDoubleArray> ycoords;
|
|
267
|
+ ycoords->SetNumberOfComponents(1);
|
|
268
|
+ ycoords->SetNumberOfTuples(2);
|
|
269
|
+ ycoords->SetTuple1( 0, Origin(1) );
|
|
270
|
+ ycoords->SetTuple1( 1, Origin(1) + Size(1) );
|
|
271
|
+ ycoords->SetName("easting (m)");
|
|
272
|
+ oct->SetYCoordinates(ycoords);
|
|
273
|
+
|
|
274
|
+ vtkNew<vtkDoubleArray> zcoords;
|
|
275
|
+ zcoords->SetNumberOfComponents(1);
|
|
276
|
+ zcoords->SetNumberOfTuples(2);
|
|
277
|
+ zcoords->SetTuple1( 0, Origin(2) );
|
|
278
|
+ zcoords->SetTuple1( 1, Origin(2) + Size(2) );
|
|
279
|
+ zcoords->SetName("depth (m)");
|
|
280
|
+ oct->SetZCoordinates(zcoords);
|
|
281
|
+
|
|
282
|
+ //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?
|
|
285
|
+ vtkHyperTreeCursor* curse = oct->NewCursor(0, true); // true creates the cursor
|
260
|
286
|
curse->ToRoot();
|
261
|
287
|
EvaluateKids2( Size, 0, cpos, VectorXcr::Ones(PulseI.size()), oct, curse );
|
262
|
288
|
|
|
@@ -322,26 +348,29 @@ namespace Lemma {
|
322
|
348
|
for (auto leaf : LeafDictIdx) {
|
323
|
349
|
kerr->InsertTuple1( leaf.first, leaf.second );
|
324
|
350
|
}
|
325
|
|
-
|
326
|
|
- auto kri = oct->GetLeafData()->AddArray(kr);
|
327
|
|
- auto kii = oct->GetLeafData()->AddArray(ki);
|
328
|
|
- auto kmi = oct->GetLeafData()->AddArray(km);
|
329
|
|
- auto kidi = oct->GetLeafData()->AddArray(kid);
|
330
|
|
- auto keri = oct->GetLeafData()->AddArray(kerr);
|
331
|
|
- auto khtr = oct->GetLeafData()->AddArray(htr);
|
332
|
|
- auto khti = oct->GetLeafData()->AddArray(hti);
|
333
|
|
- auto khrr = oct->GetLeafData()->AddArray(hrr);
|
334
|
|
- auto khri = oct->GetLeafData()->AddArray(hri);
|
335
|
|
-
|
336
|
|
- auto write = vtkXMLHyperOctreeWriter::New();
|
337
|
|
- //write.SetDataModeToAscii()
|
338
|
|
- write->SetInputData(oct);
|
|
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;
|
|
363
|
+ auto write = vtkXMLHyperTreeGridWriter::New();
|
339
|
364
|
std::string fname = std::string("octree-") + to_string(ilay)
|
340
|
|
- + std::string("-") + to_string(iq) + std::string(".vto");
|
|
365
|
+ + std::string("-") + to_string(iq) + std::string(".htg");
|
341
|
366
|
write->SetFileName(fname.c_str());
|
|
367
|
+ write->SetInputData(oct);
|
|
368
|
+ write->SetDataModeToBinary();
|
|
369
|
+ //write.SetDataModeToAscii()
|
|
370
|
+ //write->Update();
|
342
|
371
|
write->Write();
|
343
|
372
|
write->Delete();
|
344
|
|
-
|
|
373
|
+/*
|
345
|
374
|
oct->GetLeafData()->RemoveArray( kri );
|
346
|
375
|
oct->GetLeafData()->RemoveArray( kii );
|
347
|
376
|
oct->GetLeafData()->RemoveArray( kmi );
|
|
@@ -361,7 +390,7 @@ namespace Lemma {
|
361
|
390
|
hti->Delete();
|
362
|
391
|
hrr->Delete();
|
363
|
392
|
hri->Delete();
|
364
|
|
-
|
|
393
|
+*/
|
365
|
394
|
}
|
366
|
395
|
curse->Delete();
|
367
|
396
|
oct->Delete();
|
|
@@ -568,7 +597,7 @@ namespace Lemma {
|
568
|
597
|
// Method: EvaluateKids2 -- same as Evaluate Kids, but include VTK octree generation
|
569
|
598
|
//--------------------------------------------------------------------------------------
|
570
|
599
|
void KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
|
571
|
|
- const VectorXcr& parentVal, vtkHyperOctree* oct, vtkHyperOctreeCursor* curse) {
|
|
600
|
+ const VectorXcr& parentVal, vtkHyperTreeGrid* oct, vtkHyperTreeCursor* curse) {
|
572
|
601
|
|
573
|
602
|
std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
|
574
|
603
|
//std::cout.flush();
|
|
@@ -627,7 +656,9 @@ namespace Lemma {
|
627
|
656
|
VectorXcr ksum = kvals.colwise().sum(); // Kernel sum
|
628
|
657
|
// Evaluate whether or not furthur splitting is needed
|
629
|
658
|
if ( (((ksum - parentVal).array().abs() > tol).any() && level<maxLevel) || level < minLevel ) {
|
630
|
|
- oct->SubdivideLeaf(curse);
|
|
659
|
+ // TODO Fix, 0 after curse is vtkIdType?
|
|
660
|
+ oct->SubdivideLeaf(curse, 0);
|
|
661
|
+ //std::cout << "Number of leaves: " << oct->GetNumberOfLeaves() << std::endl;
|
631
|
662
|
for (int ichild=0; ichild<8; ++ichild) {
|
632
|
663
|
curse->ToChild(ichild);
|
633
|
664
|
Vector3r cp = pos; // Eigen complains about combining these
|
|
@@ -656,13 +687,19 @@ namespace Lemma {
|
656
|
687
|
/* Alternatively, subdivide the VTK octree here and stuff the children to make better
|
657
|
688
|
* visuals, but also 8x the storage...
|
658
|
689
|
*/
|
659
|
|
- oct->SubdivideLeaf(curse);
|
|
690
|
+ // TODO Fix, 0 after curse is vtkIdType?
|
|
691
|
+ oct->SubdivideLeaf(curse, 0);
|
660
|
692
|
for (int ichild=0; ichild<8; ++ichild) {
|
661
|
693
|
curse->ToChild(ichild);
|
662
|
|
- LeafDict[curse->GetLeafId()] = ksum/(8.*vol);
|
663
|
|
- LeafHt[curse->GetLeafId()] = Ht.col(ichild);
|
664
|
|
- LeafHr[curse->GetLeafId()] = Hr.col(ichild);
|
665
|
|
- LeafDictIdx[curse->GetLeafId()] = nleaves;
|
|
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;
|
666
|
703
|
curse->ToParent();
|
667
|
704
|
}
|
668
|
705
|
|
|
@@ -676,12 +713,15 @@ namespace Lemma {
|
676
|
713
|
// Class: KernelV0
|
677
|
714
|
// Method: GetPosition
|
678
|
715
|
//--------------------------------------------------------------------------------------
|
679
|
|
- void KernelV0::GetPosition( vtkHyperOctreeCursor* Cursor, Real* p ) {
|
|
716
|
+ void KernelV0::GetPosition( vtkHyperTreeCursor* Cursor, Real* p ) {
|
|
717
|
+ // TODO fix
|
|
718
|
+ /*
|
680
|
719
|
Real ratio=1.0/(1<<(Cursor->GetCurrentLevel()));
|
681
|
720
|
//step = ((Size).array() / std::pow(2.,Cursor->GetCurrentLevel()));
|
682
|
721
|
p[0]=(Cursor->GetIndex(0)+.5)*ratio*this->Size[0]+this->Origin[0] ;//+ .5*step[0];
|
683
|
722
|
p[1]=(Cursor->GetIndex(1)+.5)*ratio*this->Size[1]+this->Origin[1] ;//+ .5*step[1];
|
684
|
723
|
p[2]=(Cursor->GetIndex(2)+.5)*ratio*this->Size[2]+this->Origin[2] ;//+ .5*step[2];
|
|
724
|
+ */
|
685
|
725
|
}
|
686
|
726
|
|
687
|
727
|
#endif
|