Browse Source

update of progress bar for kernel

master
Trevor Irons 5 years ago
parent
commit
2266d68316
2 changed files with 35 additions and 6 deletions
  1. 5
    0
      include/KernelV0.h
  2. 30
    6
      src/KernelV0.cpp

+ 5
- 0
include/KernelV0.h View File

@@ -384,6 +384,11 @@ namespace Lemma {
384 384
         std::map< int, Real >                     LeafDictErr;   // error value
385 385
         #endif
386 386
 
387
+        #ifdef HAVE_BOOST_PROGRESS
388
+        boost::progress_display* disp;
389
+        int percent_done;
390
+        #endif
391
+
387 392
         // Physical constants and conversion factors
388 393
         static constexpr Real GAMMA = 2.67518e8;                  // MKS units
389 394
         static constexpr Real INVSQRT2 = 0.70710678118654746;     // 1/sqrt(2)

+ 30
- 6
src/KernelV0.cpp View File

@@ -236,15 +236,24 @@ namespace Lemma {
236 236
             }
237 237
         }
238 238
 
239
-        std::cout << "Calculating K0 kernel\n";
239
+        std::cout << "Calculating K0 kernel";
240 240
         Kern = MatrixXcr::Zero( Interfaces.size()-1, PulseI.size() );
241 241
         //for (ilay=0; ilay<Interfaces.size()-1; ++ilay) {
242
+        std::cout.precision(3);
242 243
         for (ilay=0; ilay<Interfaces.size()-1; ++ilay) {
243
-            std::cout << "Layer " << ilay << "\tfrom " << Interfaces(ilay) <<" to "
244
-                      << Interfaces(ilay+1) << std::endl;
244
+            std::cout << "\n\nLayer " << ilay << "\tfrom " << Interfaces(ilay) <<" to "
245
+                      << Interfaces(ilay+1); // << std::endl;
245 246
             Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
246 247
             Origin(2) = Interfaces(ilay);
248
+
249
+            #ifdef HAVE_BOOST_PROGRESS
250
+            percent_done = 0;
251
+            disp = new boost::progress_display( 100 );
252
+            IntegrateOnOctreeGrid( vtkOutput );
253
+            delete disp;
254
+            #else
247 255
             IntegrateOnOctreeGrid( vtkOutput );
256
+            #endif
248 257
             //std::cout << "Kernel row " << Kern.row(ilay);
249 258
         }
250 259
         std::cout << "\nFinished KERNEL\n";
@@ -427,8 +436,8 @@ namespace Lemma {
427 436
         #endif
428 437
 
429 438
         }
430
-        std::cout << "\nVOLSUM=" << VOLSUM << "\tActual=" <<  Size(0)*Size(1)*Size(2)
431
-                  << "\tDifference=" << VOLSUM - (Size(0)*Size(1)*Size(2)) <<  std::endl;
439
+        //std::cout << "\nVOLSUM=" << VOLSUM << "\tActual=" <<  Size(0)*Size(1)*Size(2)
440
+        //          << "\tDifference=" << VOLSUM - (Size(0)*Size(1)*Size(2)) <<  std::endl;
432 441
     }
433 442
 
434 443
     //--------------------------------------------------------------------------------------
@@ -546,7 +555,15 @@ namespace Lemma {
546 555
     void KernelV0::EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
547 556
         const VectorXcr& parentVal ) {
548 557
 
558
+        #ifdef HAVE_BOOST_PROGRESS
559
+        int pdone =  (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2]));
560
+        if (pdone > percent_done ) {
561
+            percent_done = pdone;
562
+            ++(*disp);
563
+        }
564
+        #else
549 565
         std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
566
+        #endif
550 567
         //std::cout.flush();
551 568
 
552 569
         // Next level step, interested in one level below
@@ -627,8 +644,15 @@ namespace Lemma {
627 644
     void KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
628 645
         const VectorXcr& parentVal, vtkHyperTreeGrid* oct, vtkHyperTreeCursor* curse) {
629 646
 
647
+        #ifdef HAVE_BOOST_PROGRESS
648
+        int pdone =  (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2]));
649
+        if (pdone > percent_done ) {
650
+            percent_done = pdone;
651
+            ++(*disp);
652
+        }
653
+        #else
630 654
         std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
631
-        //std::cout.flush();
655
+        #endif
632 656
 
633 657
         // Next level step, interested in one level below
634 658
         // bitshift requires one extra, faster than, and equivalent to std::pow(2, level+1)

Loading…
Cancel
Save