Skip to content

Commit

Permalink
feat: add log at the end of the timestep with substeps info. (#3303)
Browse files Browse the repository at this point in the history
  • Loading branch information
CusiniM authored Aug 27, 2024
1 parent cbe9c5d commit 42966e9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/coreComponents/physicsSolvers/SolverBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "mesh/DomainPartition.hpp"
#include "math/interpolation/Interpolation.hpp"
#include "common/Timer.hpp"
#include "common/Units.hpp"

#if defined(GEOS_USE_PYGEOSX)
#include "python/PySolverType.hpp"
Expand Down Expand Up @@ -251,6 +252,10 @@ bool SolverBase::execute( real64 const time_n,

integer const maxSubSteps = m_nonlinearSolverParameters.m_maxSubSteps;

// Keep track of substeps. It is useful to output these.
std::vector< real64 > subStepDt( maxSubSteps, 0.0 );
integer numOfSubSteps = 0;

for( integer subStep = 0; subStep < maxSubSteps && dtRemaining > 0.0; ++subStep )
{
// reset number of nonlinear and linear iterations
Expand All @@ -260,6 +265,8 @@ bool SolverBase::execute( real64 const time_n,
nextDt,
cycleNumber,
domain );
numOfSubSteps++;
subStepDt[subStep] = dtAccepted;

// increment the cumulative number of nonlinear and linear iterations
m_solverStatistics.saveTimeStepStatistics();
Expand Down Expand Up @@ -304,9 +311,29 @@ bool SolverBase::execute( real64 const time_n,
// Decide what to do with the next Dt for the event running the solver.
m_nextDt = setNextDt( nextDt, domain );

logEndOfCycleInformation( cycleNumber, numOfSubSteps, subStepDt );

return false;
}

void SolverBase::logEndOfCycleInformation( integer const cycleNumber,
integer const numOfSubSteps,
std::vector< real64 > const & subStepDt ) const
{
// The formating here is a work in progress.
GEOS_LOG_RANK_0( "\n------------------------- TIMESTEP END -------------------------" );
GEOS_LOG_RANK_0( GEOS_FMT( " - Cycle: {}", cycleNumber ) );
GEOS_LOG_RANK_0( GEOS_FMT( " - N substeps: {}", numOfSubSteps ) );
std::string logMessage = " - dt:";
for( integer i = 0; i < numOfSubSteps; ++i )
{
logMessage += " " + units::TimeFormatInfo::fromSeconds( subStepDt[i] ).toString();
}
// Log the complete message once
GEOS_LOG_RANK_0( logMessage );
GEOS_LOG_RANK_0( "------------------------------------------------------------------\n" );
}

real64 SolverBase::setNextDt( real64 const & currentDt,
DomainPartition & domain )
{
Expand Down
4 changes: 4 additions & 0 deletions src/coreComponents/physicsSolvers/SolverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,10 @@ class SolverBase : public ExecutableGroup
integer const cycleNumber,
DomainPartition & domain );

void logEndOfCycleInformation( integer const cycleNumber,
integer const numOfSubSteps,
std::vector< real64 > const & subStepDt ) const;

};

template< typename CONSTITUTIVE_BASE_TYPE >
Expand Down

0 comments on commit 42966e9

Please sign in to comment.