From 6d4dc8c7559f8d48fe5e9aeb0be69acdbdae597f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Wed, 14 Mar 2018 21:00:22 +0100 Subject: [PATCH] LBM: added MLUPS to the solver monitor --- src/TNL/Solvers/IterativeSolverMonitor.h | 8 +++++-- src/TNL/Solvers/IterativeSolverMonitor_impl.h | 21 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/TNL/Solvers/IterativeSolverMonitor.h b/src/TNL/Solvers/IterativeSolverMonitor.h index 3180abb3c3..f29acee8fc 100644 --- a/src/TNL/Solvers/IterativeSolverMonitor.h +++ b/src/TNL/Solvers/IterativeSolverMonitor.h @@ -35,6 +35,8 @@ public: void setResidue( const RealType& residue ); void setVerbose( const Index& verbose ); + + void setNodesPerIteration( const IndexType& nodes ); virtual void refresh(); @@ -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 diff --git a/src/TNL/Solvers/IterativeSolverMonitor_impl.h b/src/TNL/Solvers/IterativeSolverMonitor_impl.h index ef18320193..a94c033568 100644 --- a/src/TNL/Solvers/IterativeSolverMonitor_impl.h +++ b/src/TNL/Solvers/IterativeSolverMonitor_impl.h @@ -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; } -- GitLab