Commit 6d4dc8c7 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

LBM: added MLUPS to the solver monitor

parent e638c8f8
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ public:

   void setVerbose( const Index& verbose );

   void setNodesPerIteration( const IndexType& nodes );
 
   virtual void refresh();

protected:
@@ -45,11 +47,13 @@ protected:

   std::atomic_bool saved;

   RealType time, saved_time, timeStep, saved_timeStep, residue, saved_residue;
   RealType time, saved_time, timeStep, saved_timeStep, residue, saved_residue, elapsed_time_before_refresh;

   IndexType iterations, saved_iterations;
   IndexType iterations, saved_iterations, iterations_before_refresh;

   IndexType verbose;

   IndexType nodesPerIteration;
};

} // namespace Solvers
+19 −2
Original line number Diff line number Diff line
@@ -37,9 +37,12 @@ IterativeSolverMonitor< Real, Index > :: IterativeSolverMonitor()
  saved_timeStep( 0.0 ),
  residue( 0.0 ),
  saved_residue( 0.0 ),
  elapsed_time_before_refresh( 0.0 ),
  iterations( 0 ),
  saved_iterations( 0 ),
  verbose( 1 )
  iterations_before_refresh( 0 ),
  verbose( 1 ),
  nodesPerIteration( 0 )
{
}

@@ -93,6 +96,12 @@ void IterativeSolverMonitor< Real, Index > :: setVerbose( const Index& verbose )
   this->verbose = verbose;
}

template< typename Real, typename Index>
void IterativeSolverMonitor< Real, Index > :: setNodesPerIteration( const IndexType& nodes )
{
   this->nodesPerIteration = nodes;
}

template< typename Real, typename Index>
void IterativeSolverMonitor< Real, Index > :: refresh()
{
@@ -133,7 +142,7 @@ void IterativeSolverMonitor< Real, Index > :: refresh()
      if( (saved) ? saved_timeStep : timeStep > 0 ) {
//         print_item( " TAU:" );
         print_item( " TAU:", 0 );
         print_item( real_to_string( (saved) ? saved_timeStep : timeStep, 5 ), 8 );
         print_item( real_to_string( (saved) ? saved_timeStep : timeStep, 5 ), 10 );
      }

      const std::string displayed_stage = (saved) ? saved_stage : stage;
@@ -159,6 +168,14 @@ void IterativeSolverMonitor< Real, Index > :: refresh()
         print_item( real_to_string( (saved) ? saved_residue : residue, 5 ), 12 );
      }

      if( nodesPerIteration ) {
         const RealType mlups = nodesPerIteration * (iterations - iterations_before_refresh) / (getElapsedTime() - elapsed_time_before_refresh) * 1e-6;
         print_item( " MLUPS:", 0 );
         print_item( real_to_string( mlups, 5 ), 7 );
      }
      iterations_before_refresh = iterations;
      elapsed_time_before_refresh = getElapsedTime();

      // return to the beginning of the line
      std::cout << "\r" << std::flush;
   }