Skip to content
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
2 changes: 2 additions & 0 deletions SU2_CFD/include/output/COutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class COutput {
ofstream histFile; /*!< \brief Output file stream for the history */

bool cauchyTimeConverged; /*! \brief: Flag indicating that solver is already converged. Needed for writing restart files. */
bool maxTimeDelayActive; /*! \brief: Flag for delaying stop at max_time with 2nd order time stepping. */

/** \brief Enum to identify the screen output format. */
enum class ScreenOutputFormat {
Expand Down Expand Up @@ -591,6 +592,7 @@ class COutput {
* \param[in] solver_container - Container vector with all the solutions.
* \param[in] iter - The current time, outer or inner iteration index.
* \param[in] force_writing - If <TRUE>, writing of output files is forced without checking the output frequency.
* \param[in] write_restart_only - If <TRUE>, only restart (and CSV restart) volume files are written.
* \return <TRUE> if output files have been written to disk.
*/
bool SetResultFiles(CGeometry *geometry, CConfig *config, CSolver** solver_container,
Expand Down
21 changes: 21 additions & 0 deletions SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output):
us_units(config->GetSystemMeasurements() == US) {

cauchyTimeConverged = false;
maxTimeDelayActive = false;

convergenceTable = new PrintingToolbox::CTablePrinter(&std::cout);
multiZoneHeaderTable = new PrintingToolbox::CTablePrinter(&std::cout);
Expand Down Expand Up @@ -793,6 +794,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE form
}

bool COutput::GetCauchyCorrectedTimeConvergence(const CConfig *config){
// Handle Cauchy convergence delay for 2nd order time stepping
if(!cauchyTimeConverged && TimeConvergence && config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND){
// Change flags for 2nd order Time stepping: In case of convergence, this iter and next iter gets written out. then solver stops
cauchyTimeConverged = TimeConvergence;
Expand All @@ -801,6 +803,25 @@ bool COutput::GetCauchyCorrectedTimeConvergence(const CConfig *config){
else if(cauchyTimeConverged){
TimeConvergence = cauchyTimeConverged;
}

// Handle max time delay for 2nd order time stepping
// Delay stopping at max_time to ensure both timestep N and N-1 are written for proper restart
if(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND){
const su2double cur_time = GetHistoryFieldValue("CUR_TIME");
const su2double max_time = config->GetMax_Time();
const bool final_time_reached = (cur_time >= max_time);

// If max_time is reached on first detection, delay the stop
if(final_time_reached && !maxTimeDelayActive){
maxTimeDelayActive = true;
TimeConvergence = false; // Delay stop to run one more iteration
}
else if(maxTimeDelayActive){
TimeConvergence = true; // Now allow stop
maxTimeDelayActive = false; // Reset for next run
}
}

return TimeConvergence;
}

Expand Down