From 2b0fca1be745cb39587958c7fa40ef79a7cc7737 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Wed, 13 Aug 2025 12:06:45 -0500 Subject: [PATCH 1/6] feat: print out solver statistics after every cycle when log level >=2 --- src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp | 5 ++++- src/coreComponents/physicsSolvers/SolverStatistics.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp b/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp index 07056cdd12b..027d3cf06ad 100644 --- a/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp @@ -28,8 +28,8 @@ #if defined(GEOS_USE_PYGEOSX) #include "python/PySolverType.hpp" -#endif +#endif namespace geos { @@ -376,6 +376,9 @@ void PhysicsSolverBase::logEndOfCycleInformation( integer const cycleNumber, logpart.addEndDescription( "- substep dts ", logMessage.str() ); logpart.end(); + + if( isLogLevelActive< logInfo::SolverExecutionDetails >( getLogLevel())) + m_solverStatistics.outputStatistics(); } real64 PhysicsSolverBase::setNextDt( real64 const & GEOS_UNUSED_PARAM( currentTime ), diff --git a/src/coreComponents/physicsSolvers/SolverStatistics.cpp b/src/coreComponents/physicsSolvers/SolverStatistics.cpp index 9928a95bec7..25dba099d00 100644 --- a/src/coreComponents/physicsSolvers/SolverStatistics.cpp +++ b/src/coreComponents/physicsSolvers/SolverStatistics.cpp @@ -155,5 +155,7 @@ void SolverStatistics::outputStatistics() const logStat( "discarded linear iterations", m_numDiscardedLinearIterations ); } } + + GEOS_LOG_RANK_0( "" ); // blank line for readability } } // namespace geos From 5639abbc6626ff4b21877901dbca473f7709a027 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Wed, 13 Aug 2025 12:48:10 -0500 Subject: [PATCH 2/6] avoid double-printing --- src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp b/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp index 027d3cf06ad..6b0671ac5d1 100644 --- a/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp @@ -1464,7 +1464,8 @@ void PhysicsSolverBase::cleanup( real64 const GEOS_UNUSED_PARAM( time_n ), real64 const GEOS_UNUSED_PARAM( eventProgress ), DomainPartition & GEOS_UNUSED_PARAM( domain ) ) { - m_solverStatistics.outputStatistics(); + if( !isLogLevelActive< logInfo::SolverExecutionDetails >( getLogLevel() ) ) + m_solverStatistics.outputStatistics(); for( auto & timer : m_timers ) { From 99cd9c270696103da18a181a657befb1ad54f4e8 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Wed, 13 Aug 2025 12:50:12 -0500 Subject: [PATCH 3/6] missed that --- src/coreComponents/common/format/LogPart.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreComponents/common/format/LogPart.cpp b/src/coreComponents/common/format/LogPart.cpp index a9ce3c69da6..1813653de16 100644 --- a/src/coreComponents/common/format/LogPart.cpp +++ b/src/coreComponents/common/format/LogPart.cpp @@ -190,14 +190,13 @@ void LogPart::begin( std::ostream & os ) if( !m_enableOutput ) return; - if( !m_startDescription.m_names.empty()) { formatDescriptions( m_startDescription, m_formattedStartDescription ); } string const line = string( m_width, m_borderCharacter ); - os << '\n' << line; + os << line; os << outputTitle( m_formattedStartDescription ); os << line << '\n'; os << outputDescription( m_formattedStartDescription ) << '\n'; From db97d0d4df53a5fe5a3aec79888058e439ae5540 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Wed, 13 Aug 2025 12:52:28 -0500 Subject: [PATCH 4/6] revert --- src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp b/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp index 6b0671ac5d1..810057c235f 100644 --- a/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp @@ -28,8 +28,8 @@ #if defined(GEOS_USE_PYGEOSX) #include "python/PySolverType.hpp" - #endif + namespace geos { @@ -1464,7 +1464,7 @@ void PhysicsSolverBase::cleanup( real64 const GEOS_UNUSED_PARAM( time_n ), real64 const GEOS_UNUSED_PARAM( eventProgress ), DomainPartition & GEOS_UNUSED_PARAM( domain ) ) { - if( !isLogLevelActive< logInfo::SolverExecutionDetails >( getLogLevel() ) ) + if( !isLogLevelActive< logInfo::SolverExecutionDetails >( getLogLevel() ) ) // to avoid double-printing m_solverStatistics.outputStatistics(); for( auto & timer : m_timers ) From 4ee086f08d0a300a670b0a09a3f92266a7736366 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Wed, 13 Aug 2025 13:18:54 -0500 Subject: [PATCH 5/6] do it this way --- src/coreComponents/common/format/LogPart.cpp | 3 ++- src/coreComponents/events/EventManager.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/coreComponents/common/format/LogPart.cpp b/src/coreComponents/common/format/LogPart.cpp index 1813653de16..a9ce3c69da6 100644 --- a/src/coreComponents/common/format/LogPart.cpp +++ b/src/coreComponents/common/format/LogPart.cpp @@ -190,13 +190,14 @@ void LogPart::begin( std::ostream & os ) if( !m_enableOutput ) return; + if( !m_startDescription.m_names.empty()) { formatDescriptions( m_startDescription, m_formattedStartDescription ); } string const line = string( m_width, m_borderCharacter ); - os << line; + os << '\n' << line; os << outputTitle( m_formattedStartDescription ); os << line << '\n'; os << outputDescription( m_formattedStartDescription ) << '\n'; diff --git a/src/coreComponents/events/EventManager.cpp b/src/coreComponents/events/EventManager.cpp index 7f4f1322358..6d6d88e5434 100644 --- a/src/coreComponents/events/EventManager.cpp +++ b/src/coreComponents/events/EventManager.cpp @@ -267,32 +267,32 @@ void EventManager::outputTime( LogPart & logPart ) const // We are keeping the old outputs to keep compatibility with current log reading scripts. if( m_timeOutputFormat==TimeOutputFormat::full ) { - GEOS_LOG_RANK_0( GEOS_FMT( "Time: {} years, {} days, {} hrs, {} min, {} s, dt: {} s, Cycle: {}\n", + GEOS_LOG_RANK_0( GEOS_FMT( "Time: {} years, {} days, {} hrs, {} min, {} s, dt: {} s, Cycle: {}", timeInfo.m_years, timeInfo.m_days, timeInfo.m_hours, timeInfo.m_minutes, timeInfo.m_seconds, m_dt, m_cycle ) ); } else if( m_timeOutputFormat==TimeOutputFormat::years ) { real64 const yearsOut = m_time / units::YearSeconds; - GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} years, dt: {} s, Cycle: {}\n", yearsOut, m_dt, m_cycle ) ); + GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} years, dt: {} s, Cycle: {}", yearsOut, m_dt, m_cycle ) ); } else if( m_timeOutputFormat==TimeOutputFormat::days ) { real64 const daysOut = m_time / units::DaySeconds; - GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} days, dt: {} s, Cycle: {}\n", daysOut, m_dt, m_cycle ) ); + GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} days, dt: {} s, Cycle: {}", daysOut, m_dt, m_cycle ) ); } else if( m_timeOutputFormat==TimeOutputFormat::hours ) { real64 const hoursOut = m_time / units::HourSeconds; - GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} hrs, dt: {} s, Cycle: {}\n", hoursOut, m_dt, m_cycle ) ); + GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} hrs, dt: {} s, Cycle: {}", hoursOut, m_dt, m_cycle ) ); } else if( m_timeOutputFormat==TimeOutputFormat::minutes ) { real64 const minutesOut = m_time / units::MinuteSeconds; - GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} min, dt: {} s, Cycle: {}\n", minutesOut, m_dt, m_cycle ) ); + GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:.2f} min, dt: {} s, Cycle: {}", minutesOut, m_dt, m_cycle ) ); } else if( m_timeOutputFormat == TimeOutputFormat::seconds ) { - GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:4.2e} s, dt: {} s, Cycle: {}\n", m_time, m_dt, m_cycle ) ); + GEOS_LOG_RANK_0( GEOS_FMT( "Time: {:4.2e} s, dt: {} s, Cycle: {}", m_time, m_dt, m_cycle ) ); } else { From 5d3ca2e3c7f106b68c7b54cd6595d0666801e6f4 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Tue, 19 Aug 2025 09:43:48 -0500 Subject: [PATCH 6/6] Update LogLevelsInfo.hpp --- src/coreComponents/physicsSolvers/LogLevelsInfo.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/physicsSolvers/LogLevelsInfo.hpp b/src/coreComponents/physicsSolvers/LogLevelsInfo.hpp index e506139cfe7..216fcc5f0d2 100644 --- a/src/coreComponents/physicsSolvers/LogLevelsInfo.hpp +++ b/src/coreComponents/physicsSolvers/LogLevelsInfo.hpp @@ -110,7 +110,7 @@ struct SolverExecution struct SolverExecutionDetails { static constexpr int getMinLogLevel() { return 2; } - static constexpr std::string_view getDescription() { return "More precise information on solver execution"; } + static constexpr std::string_view getDescription() { return "More precise information on solver execution, including iterations statistics after every cycle"; } }; struct SolverSteps