Skip to content

feat: print out solver statistics after every cycle when log level >=2 #3773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/coreComponents/events/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/physicsSolvers/LogLevelsInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,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 ),
Expand Down Expand Up @@ -1454,7 +1457,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() ) ) // to avoid double-printing
m_solverStatistics.outputStatistics();

for( auto & timer : m_timers )
{
Expand Down
2 changes: 2 additions & 0 deletions src/coreComponents/physicsSolvers/SolverStatistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,7 @@ void SolverStatistics::outputStatistics() const
logStat( "discarded linear iterations", m_numDiscardedLinearIterations );
}
}

GEOS_LOG_RANK_0( "" ); // blank line for readability
}
} // namespace geos
Loading