|
@@ -138,9 +138,9 @@ namespace Lemma {
|
138
|
138
|
}
|
139
|
139
|
|
140
|
140
|
std::cout << "Calculating K0 kernel\n";
|
141
|
|
- MatrixXcr Kern = MatrixXcr::Zero( Interfaces.size() - 1, PulseI.size() );
|
142
|
|
- for (int ilay=0; ilay< Interfaces.size()-1; ++ilay) {
|
143
|
|
- for (int iq=0; iq< PulseI.size()-1; ++iq) {
|
|
141
|
+ MatrixXcr Kern = MatrixXcr::Zero( Interfaces.size()-1, PulseI.size() );
|
|
142
|
+ for (int ilay=0; ilay<Interfaces.size()-1; ++ilay) {
|
|
143
|
+ for (int iq=0; iq< PulseI.size(); ++iq) {
|
144
|
144
|
std::cout << "Layer " << ilay << " q " << iq << std::endl;
|
145
|
145
|
Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
|
146
|
146
|
Origin(2) = Interfaces(ilay);
|
|
@@ -162,7 +162,7 @@ namespace Lemma {
|
162
|
162
|
//--------------------------------------------------------------------------------------
|
163
|
163
|
Complex KernelV0::IntegrateOnOctreeGrid( const int& ilay, const int& iq, bool vtkOutput) {
|
164
|
164
|
|
165
|
|
- Vector3r cpos = (Size-Origin).array() / 2.;
|
|
165
|
+ Vector3r cpos = Origin + Size/2.;
|
166
|
166
|
|
167
|
167
|
SUM = 0;
|
168
|
168
|
VOLSUM = 0;
|
|
@@ -200,12 +200,15 @@ namespace Lemma {
|
200
|
200
|
kerr->SetNumberOfComponents(1);
|
201
|
201
|
kerr->SetName("nleaf");
|
202
|
202
|
|
|
203
|
+ //Real LeafVol(0);
|
203
|
204
|
for (auto leaf : LeafDict) {
|
204
|
205
|
kr->InsertTuple1( leaf.first, std::real(leaf.second) );
|
205
|
206
|
ki->InsertTuple1( leaf.first, std::imag(leaf.second) );
|
206
|
207
|
km->InsertTuple1( leaf.first, std::abs(leaf.second) );
|
207
|
208
|
kid->InsertTuple1( leaf.first, leaf.first );
|
|
209
|
+ //LeafVol += std::real(leaf.second);
|
208
|
210
|
}
|
|
211
|
+ //std::cout << "\n\nLeafVol=" << LeafVol << std::endl;
|
209
|
212
|
|
210
|
213
|
for (auto leaf : LeafDictIdx) {
|
211
|
214
|
kerr->InsertTuple1( leaf.first, leaf.second );
|
|
@@ -427,9 +430,10 @@ namespace Lemma {
|
427
|
430
|
// Next level step, interested in one level below
|
428
|
431
|
// bitshift requires one extra, faster than, and equivalent to std::pow(2, level+1)
|
429
|
432
|
Vector3r step = size.array() / (Real)(1 << (level+1) );
|
430
|
|
- Vector3r step2 = size.array() / (Real)(1 << (level+2) );
|
|
433
|
+ Real vol = (step(0)*step(1)*step(2)); // volume of each child
|
431
|
434
|
|
432
|
|
- Real vol = (step2(0)*step2(1)*step2(2)); // volume of each child
|
|
435
|
+ Vector3r step2 = size.array() / (Real)(1 << (level+2) );
|
|
436
|
+ Real vol2 = (step2(0)*step2(1)*step2(2)); // volume of each child
|
433
|
437
|
|
434
|
438
|
Vector3r pos = cpos - step/2.;
|
435
|
439
|
Eigen::Matrix<Real, 8, 3> posadd = (Eigen::Matrix<Real, 8, 3>() <<
|
|
@@ -479,31 +483,44 @@ namespace Lemma {
|
479
|
483
|
|
480
|
484
|
Complex ksum = kvals.sum(); // Kernel sum
|
481
|
485
|
// Evaluate whether or not furthur splitting is needed
|
482
|
|
- Real err = std::abs(ksum - parentVal);
|
483
|
|
- if ( std::abs(ksum - parentVal) > tol || level < minLevel && level < maxLevel ) {
|
|
486
|
+ if ( std::abs(ksum-parentVal) > tol ) { // || level < minLevel && level < maxLevel ) {
|
|
487
|
+ //if ( std::abs(ksum.real()-parentVal.real())>tol || std::abs(ksum.imag()-parentVal.imag()) >tol ) {
|
|
488
|
+ //if ( std::abs(ksum) > tol && level < maxLevel ) {
|
484
|
489
|
oct->SubdivideLeaf(curse);
|
485
|
490
|
for (int ichild=0; ichild<8; ++ichild) {
|
486
|
491
|
curse->ToChild(ichild);
|
487
|
492
|
Vector3r cp = pos; // Eigen complains about combining these
|
488
|
493
|
cp += posadd.row(ichild);
|
489
|
|
- /* Test for position via alternative means
|
|
494
|
+ /* Test for position via alternative means */
|
|
495
|
+ /*
|
490
|
496
|
Real p[3];
|
491
|
497
|
GetPosition(curse, p);
|
492
|
|
- std::cout << cp[0] << "\t" << p[0] << "\t" << cp[1] << "\t" << p[1]
|
493
|
|
- << "\t" << cp[2] << "\t" << p[2] << "\t" << vol<< std::endl;
|
|
498
|
+ if ( (Vector3r(p) - cp).norm() > 1e-8 ) {
|
|
499
|
+ std::cout << "ERROR @ nleaves" << nleaves << "\n" << cp[0] << "\t" << p[0] << "\t" << cp[1] << "\t" << p[1]
|
|
500
|
+ << "\t" << cp[2] << "\t" << p[2] << "\t" << vol<< std::endl;
|
|
501
|
+ throw std::runtime_error("doom");
|
|
502
|
+ }
|
494
|
503
|
*/
|
|
504
|
+ /* End of position test */
|
495
|
505
|
bool isleaf = EvaluateKids2( size, level+1, cp, kvals(ichild), oct, curse );
|
|
506
|
+ /*
|
496
|
507
|
if (isleaf) { // Include result in final integral
|
497
|
|
- LeafDict[curse->GetLeafId()] = kvals(ichild); // VTK
|
498
|
|
- LeafDictIdx[curse->GetLeafId()] = nleaves; // VTK
|
|
508
|
+ LeafDict[curse->GetLeafId()] = ksum/(8.*vol); //kvals(ichild) / vol; // VTK
|
|
509
|
+ LeafDictIdx[curse->GetLeafId()] = nleaves; // VTK
|
499
|
510
|
SUM += ksum;
|
500
|
511
|
VOLSUM += 8*vol;
|
501
|
512
|
nleaves += 1;
|
502
|
513
|
}
|
|
514
|
+ */
|
503
|
515
|
curse->ToParent();
|
504
|
516
|
}
|
505
|
517
|
return false; // not leaf
|
506
|
518
|
}
|
|
519
|
+ LeafDict[curse->GetLeafId()] = ksum/(8.*vol); //kvals(ichild) / vol; // VTK
|
|
520
|
+ LeafDictIdx[curse->GetLeafId()] = nleaves; // VTK
|
|
521
|
+ SUM += ksum;
|
|
522
|
+ VOLSUM += 8*vol;
|
|
523
|
+ nleaves += 1;
|
507
|
524
|
return true; // leaf
|
508
|
525
|
}
|
509
|
526
|
|