Loading src/TNL/Solvers/IterativeSolverMonitor.h +4 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ public: void setResidue( const RealType& residue ); void setVerbose( const Index& verbose ); void setVerbose( const IndexType& verbose ); void setNodesPerIteration( const IndexType& nodes ); Loading @@ -45,7 +45,7 @@ protected: std::string stage, saved_stage; std::atomic_bool saved; std::atomic_bool saved, attributes_changed; RealType time, saved_time, timeStep, saved_timeStep, residue, saved_residue, elapsed_time_before_refresh, last_mlups; //TODO: Move MLUPS to LBM solver only i.e create solver monitor for LBM Loading src/TNL/Solvers/IterativeSolverMonitor_impl.h +32 −5 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ IterativeSolverMonitor< Real, Index > :: IterativeSolverMonitor() stage( "" ), saved_stage( "" ), saved( false ), attributes_changed( false ), time( 0.0 ), saved_time( 0.0 ), timeStep( 0.0 ), Loading @@ -41,7 +42,7 @@ IterativeSolverMonitor< Real, Index > :: IterativeSolverMonitor() iterations( 0 ), saved_iterations( 0 ), iterations_before_refresh( 0 ), verbose( 1 ), verbose( 2 ), nodesPerIteration( 0 ) { } Loading @@ -64,47 +65,62 @@ void IterativeSolverMonitor< Real, Index > :: setStage( const std::string& stage this->stage = stage; saved = true; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setTime( const RealType& time ) { this->time = time; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setTimeStep( const RealType& timeStep ) { this->timeStep = timeStep; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setIterations( const Index& iterations ) { this->iterations = iterations; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setResidue( const Real& residue ) { this->residue = residue; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setVerbose( const Index& verbose ) { this->verbose = verbose; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setNodesPerIteration( const IndexType& nodes ) { this->nodesPerIteration = nodes; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: refresh() { // NOTE: We can't check if stdout is attached to a terminal or not, because // isatty(STDOUT_FILENO) *always* reports 1 under mpirun, regardless if it // runs from terminal or under SLURM or PBS. Hence, we use the verbose flag // to determine interactivity: verbose=2 expects stdout to be attached to a // terminal, verbose=1 does not use terminal features (can be used with // stdout redirected to a file, or with a terminal) and verbose=0 disables // the output completely. if( this->verbose > 0 ) { // Check if we should display the current values or the values saved after Loading @@ -129,8 +145,12 @@ void IterativeSolverMonitor< Real, Index > :: refresh() free -= width; }; if( this->verbose >= 2 ) // \33[2K erases the current line, see https://stackoverflow.com/a/35190285 std::cout << "\33[2K\r"; else if( ! attributes_changed ) // verbose == 1, attributes were not updated since the last refresh return; print_item( " ELA:" ); print_item( real_to_string( getElapsedTime(), 5 ), 8 ); Loading Loading @@ -176,8 +196,15 @@ void IterativeSolverMonitor< Real, Index > :: refresh() iterations_before_refresh = iterations; elapsed_time_before_refresh = getElapsedTime(); if( this->verbose >= 2 ) // return to the beginning of the line std::cout << "\r" << std::flush; else // linebreak and flush std::cout << "\n" << std::flush; // reset the changed flag attributes_changed = false; } } Loading src/TNL/Solvers/SolverConfig_impl.h +1 −1 Original line number Diff line number Diff line Loading @@ -147,7 +147,7 @@ bool SolverConfig< ConfigTag, ProblemConfig >::configSetup( Config::ConfigDescri } config.addDelimiter( " === Logs and messages ===" ); config.addEntry< int >( "verbose", "Set the verbose mode. The higher number the more messages are generated.", 1 ); config.addEntry< int >( "verbose", "Set the verbose mode. The higher number the more messages are generated.", 2 ); config.addEntry< String >( "log-file", "Log file for the computation.", "log.txt" ); config.addEntry< int >( "log-width", "Number of columns of the log table.", 80 ); return true; Loading src/TNL/Solvers/SolverMonitor.h +1 −1 File changed.Contains only whitespace changes. Show changes Loading
src/TNL/Solvers/IterativeSolverMonitor.h +4 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ public: void setResidue( const RealType& residue ); void setVerbose( const Index& verbose ); void setVerbose( const IndexType& verbose ); void setNodesPerIteration( const IndexType& nodes ); Loading @@ -45,7 +45,7 @@ protected: std::string stage, saved_stage; std::atomic_bool saved; std::atomic_bool saved, attributes_changed; RealType time, saved_time, timeStep, saved_timeStep, residue, saved_residue, elapsed_time_before_refresh, last_mlups; //TODO: Move MLUPS to LBM solver only i.e create solver monitor for LBM Loading
src/TNL/Solvers/IterativeSolverMonitor_impl.h +32 −5 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ IterativeSolverMonitor< Real, Index > :: IterativeSolverMonitor() stage( "" ), saved_stage( "" ), saved( false ), attributes_changed( false ), time( 0.0 ), saved_time( 0.0 ), timeStep( 0.0 ), Loading @@ -41,7 +42,7 @@ IterativeSolverMonitor< Real, Index > :: IterativeSolverMonitor() iterations( 0 ), saved_iterations( 0 ), iterations_before_refresh( 0 ), verbose( 1 ), verbose( 2 ), nodesPerIteration( 0 ) { } Loading @@ -64,47 +65,62 @@ void IterativeSolverMonitor< Real, Index > :: setStage( const std::string& stage this->stage = stage; saved = true; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setTime( const RealType& time ) { this->time = time; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setTimeStep( const RealType& timeStep ) { this->timeStep = timeStep; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setIterations( const Index& iterations ) { this->iterations = iterations; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setResidue( const Real& residue ) { this->residue = residue; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setVerbose( const Index& verbose ) { this->verbose = verbose; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: setNodesPerIteration( const IndexType& nodes ) { this->nodesPerIteration = nodes; attributes_changed = true; } template< typename Real, typename Index> void IterativeSolverMonitor< Real, Index > :: refresh() { // NOTE: We can't check if stdout is attached to a terminal or not, because // isatty(STDOUT_FILENO) *always* reports 1 under mpirun, regardless if it // runs from terminal or under SLURM or PBS. Hence, we use the verbose flag // to determine interactivity: verbose=2 expects stdout to be attached to a // terminal, verbose=1 does not use terminal features (can be used with // stdout redirected to a file, or with a terminal) and verbose=0 disables // the output completely. if( this->verbose > 0 ) { // Check if we should display the current values or the values saved after Loading @@ -129,8 +145,12 @@ void IterativeSolverMonitor< Real, Index > :: refresh() free -= width; }; if( this->verbose >= 2 ) // \33[2K erases the current line, see https://stackoverflow.com/a/35190285 std::cout << "\33[2K\r"; else if( ! attributes_changed ) // verbose == 1, attributes were not updated since the last refresh return; print_item( " ELA:" ); print_item( real_to_string( getElapsedTime(), 5 ), 8 ); Loading Loading @@ -176,8 +196,15 @@ void IterativeSolverMonitor< Real, Index > :: refresh() iterations_before_refresh = iterations; elapsed_time_before_refresh = getElapsedTime(); if( this->verbose >= 2 ) // return to the beginning of the line std::cout << "\r" << std::flush; else // linebreak and flush std::cout << "\n" << std::flush; // reset the changed flag attributes_changed = false; } } Loading
src/TNL/Solvers/SolverConfig_impl.h +1 −1 Original line number Diff line number Diff line Loading @@ -147,7 +147,7 @@ bool SolverConfig< ConfigTag, ProblemConfig >::configSetup( Config::ConfigDescri } config.addDelimiter( " === Logs and messages ===" ); config.addEntry< int >( "verbose", "Set the verbose mode. The higher number the more messages are generated.", 1 ); config.addEntry< int >( "verbose", "Set the verbose mode. The higher number the more messages are generated.", 2 ); config.addEntry< String >( "log-file", "Log file for the computation.", "log.txt" ); config.addEntry< int >( "log-width", "Number of columns of the log table.", 80 ); return true; Loading