Skip to content
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

Fix restart file writing for time convergence and 2nd order time stepping #1237

Merged
merged 4 commits into from
Apr 9, 2021
Merged
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
19 changes: 12 additions & 7 deletions SU2_CFD/include/output/COutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class COutput {
char char_histfile[200]; /*! \brief Temporary variable to store the history filename */
ofstream histFile; /*! \brief Output file stream for the history */

bool cauchyTimeConverged; /*! \brief: Flag indicating that solver is already converged. Needed for writing restart files. */

/** \brief Enum to identify the screen output format. */
enum class ScreenOutputFormat {
INTEGER, /*!< \brief Integer format. Example: 34 */
Expand Down Expand Up @@ -439,12 +441,6 @@ class COutput {
*/
bool MonitorTimeConvergence(CConfig *config, unsigned long Iteration);

/*!
* \brief Get time convergence of the specified windowed-time-averaged ouput of the problem.
* Indicates, if the time loop is converged. COnvergence criterion: Windowed time average
* \return Boolean indicating whether the problem is converged.
*/
bool GetTimeConvergence() const {return TimeConvergence;}

/*!
* \brief Print a list of all history output fields to screen.
Expand All @@ -468,6 +464,15 @@ class COutput {
bool SetResult_Files(CGeometry *geometry, CConfig *config, CSolver** solver_container,
unsigned long iter, bool force_writing = false);

/*!
* \brief Get convergence time convergence of the specified windowed-time-averaged ouput of the problem.
* Delays solver stop, if Cauchy time convergence criterion is fullfilled, but 2nd order
* time marching is active, to ensure that enough restart files are written.
* \param[in] config - Definition of the particular problem.
* \return <TRUE> if Solver has converged and has run another iteration.
*/
bool GetCauchyCorrectedTimeConvergence(const CConfig *config);

/*!
* \brief Allocates the appropriate file writer based on the chosen format and writes sorted data to file.
* \param[in] config - Definition of the particular problem.
Expand Down Expand Up @@ -581,6 +586,7 @@ class COutput {
volumeOutput_List.push_back(name);
}


/*!
* \brief Set the value of a volume output field
* \param[in] name - Name of the field.
Expand Down Expand Up @@ -796,4 +802,3 @@ class COutput {
inline virtual void SetAdditionalScreenOutput(CConfig *config){}

};

6 changes: 4 additions & 2 deletions SU2_CFD/src/drivers/CMultizoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ CMultizoneDriver::CMultizoneDriver(char* confFile, unsigned short val_nZone, SU2
/*--- Initialize the counter for TimeIter ---*/
TimeIter = 0;


/*--- Initialize some useful booleans ---*/
fsi = false; cht = false;

Expand Down Expand Up @@ -486,7 +487,7 @@ void CMultizoneDriver::Output(unsigned long TimeIter) {
for (iZone = 0; iZone < nZone; iZone++){
wrote_files = output_container[iZone]->SetResult_Files(geometry_container[iZone][INST_0][MESH_0],
config_container[iZone],
solver_container[iZone][INST_0][MESH_0], TimeIter, StopCalc);
solver_container[iZone][INST_0][MESH_0], TimeIter, StopCalc );
}

if (wrote_files){
Expand Down Expand Up @@ -679,6 +680,7 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){

/*--- Check whether the outer time integration has reached the final time ---*/
TimeConvergence = GetTimeConvergence();

FinalTimeReached = CurTime >= MaxTime;
MaxIterationsReached = TimeIter+1 >= nTimeIter;

Expand All @@ -698,5 +700,5 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){
}

bool CMultizoneDriver::GetTimeConvergence() const{
return driver_output->GetTimeConvergence();
return output_container[ZONE_0]->GetCauchyCorrectedTimeConvergence(config_container[ZONE_0]);
}
4 changes: 2 additions & 2 deletions SU2_CFD/src/drivers/CSinglezoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ CSinglezoneDriver::CSinglezoneDriver(char* confFile,

/*--- Initialize the counter for TimeIter ---*/
TimeIter = 0;

}

CSinglezoneDriver::~CSinglezoneDriver(void) {
Expand Down Expand Up @@ -272,6 +271,7 @@ bool CSinglezoneDriver::Monitor(unsigned long TimeIter){
/*--- Check whether the outer time integration has reached the final time ---*/

TimeConvergence = GetTimeConvergence();

FinalTimeReached = CurTime >= MaxTime;
MaxIterationsReached = TimeIter+1 >= nTimeIter;

Expand Down Expand Up @@ -314,5 +314,5 @@ void CSinglezoneDriver::Runtime_Options(){
}

bool CSinglezoneDriver::GetTimeConvergence() const{
return output_container[ZONE_0]->GetTimeConvergence();
return output_container[ZONE_0]->GetCauchyCorrectedTimeConvergence(config_container[ZONE_0]);
}
15 changes: 13 additions & 2 deletions SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

COutput::COutput(CConfig *config, unsigned short nDim, bool fem_output): femOutput(fem_output) {

cauchyTimeConverged = false;
this->nDim = nDim;

rank = SU2_MPI::GetRank();
Expand Down Expand Up @@ -737,12 +738,22 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f
}
}


bool COutput::GetCauchyCorrectedTimeConvergence(const CConfig *config){
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;
TimeConvergence = false;
}
else if(cauchyTimeConverged){
TimeConvergence = cauchyTimeConverged;
}
return TimeConvergence;
}

bool COutput::SetResult_Files(CGeometry *geometry, CConfig *config, CSolver** solver_container,
unsigned long iter, bool force_writing){

bool writeFiles = WriteVolume_Output(config, iter, force_writing);
bool writeFiles = WriteVolume_Output(config, iter, force_writing || cauchyTimeConverged);

/*--- Check if the data sorters are allocated, if not, allocate them. --- */

Expand Down