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

+ 30
- 6
src/KernelV0.cpp View File

236
             }
236
             }
237
         }
237
         }
238
 
238
 
239
-        std::cout << "Calculating K0 kernel\n";
239
+        std::cout << "Calculating K0 kernel";
240
         Kern = MatrixXcr::Zero( Interfaces.size()-1, PulseI.size() );
240
         Kern = MatrixXcr::Zero( Interfaces.size()-1, PulseI.size() );
241
         //for (ilay=0; ilay<Interfaces.size()-1; ++ilay) {
241
         //for (ilay=0; ilay<Interfaces.size()-1; ++ilay) {
242
+        std::cout.precision(3);
242
         for (ilay=0; ilay<Interfaces.size()-1; ++ilay) {
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
             Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
246
             Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
246
             Origin(2) = Interfaces(ilay);
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
             IntegrateOnOctreeGrid( vtkOutput );
255
             IntegrateOnOctreeGrid( vtkOutput );
256
+            #endif
248
             //std::cout << "Kernel row " << Kern.row(ilay);
257
             //std::cout << "Kernel row " << Kern.row(ilay);
249
         }
258
         }
250
         std::cout << "\nFinished KERNEL\n";
259
         std::cout << "\nFinished KERNEL\n";
427
         #endif
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
     void KernelV0::EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
555
     void KernelV0::EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
547
         const VectorXcr& parentVal ) {
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
         std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
565
         std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
566
+        #endif
550
         //std::cout.flush();
567
         //std::cout.flush();
551
 
568
 
552
         // Next level step, interested in one level below
569
         // Next level step, interested in one level below
627
     void KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
644
     void KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
628
         const VectorXcr& parentVal, vtkHyperTreeGrid* oct, vtkHyperTreeCursor* curse) {
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
         std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
654
         std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
631
-        //std::cout.flush();
655
+        #endif
632
 
656
 
633
         // Next level step, interested in one level below
657
         // Next level step, interested in one level below
634
         // bitshift requires one extra, faster than, and equivalent to std::pow(2, level+1)
658
         // bitshift requires one extra, faster than, and equivalent to std::pow(2, level+1)

Loading…
Cancel
Save