Skip to content

Commit 0e250e1

Browse files
committed
Merge branch 'develop' into fix_memoryleaks_cheatsolver
2 parents 026fbff + 7fa0763 commit 0e250e1

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

SU2_CFD/include/output/COutput.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class COutput {
8080
char char_histfile[200]; /*! \brief Temporary variable to store the history filename */
8181
ofstream histFile; /*! \brief Output file stream for the history */
8282

83+
bool cauchyTimeConverged; /*! \brief: Flag indicating that solver is already converged. Needed for writing restart files. */
84+
8385
/** \brief Enum to identify the screen output format. */
8486
enum class ScreenOutputFormat {
8587
INTEGER, /*!< \brief Integer format. Example: 34 */
@@ -439,12 +441,6 @@ class COutput {
439441
*/
440442
bool MonitorTimeConvergence(CConfig *config, unsigned long Iteration);
441443

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

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

467+
/*!
468+
* \brief Get convergence time convergence of the specified windowed-time-averaged ouput of the problem.
469+
* Delays solver stop, if Cauchy time convergence criterion is fullfilled, but 2nd order
470+
* time marching is active, to ensure that enough restart files are written.
471+
* \param[in] config - Definition of the particular problem.
472+
* \return <TRUE> if Solver has converged and has run another iteration.
473+
*/
474+
bool GetCauchyCorrectedTimeConvergence(const CConfig *config);
475+
471476
/*!
472477
* \brief Allocates the appropriate file writer based on the chosen format and writes sorted data to file.
473478
* \param[in] config - Definition of the particular problem.
@@ -581,6 +586,7 @@ class COutput {
581586
volumeOutput_List.push_back(name);
582587
}
583588

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

798804
};
799-

SU2_CFD/src/drivers/CMultizoneDriver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CMultizoneDriver::CMultizoneDriver(char* confFile, unsigned short val_nZone, SU2
3737
/*--- Initialize the counter for TimeIter ---*/
3838
TimeIter = 0;
3939

40+
4041
/*--- Initialize some useful booleans ---*/
4142
fsi = false; cht = false;
4243

@@ -486,7 +487,7 @@ void CMultizoneDriver::Output(unsigned long TimeIter) {
486487
for (iZone = 0; iZone < nZone; iZone++){
487488
wrote_files = output_container[iZone]->SetResult_Files(geometry_container[iZone][INST_0][MESH_0],
488489
config_container[iZone],
489-
solver_container[iZone][INST_0][MESH_0], TimeIter, StopCalc);
490+
solver_container[iZone][INST_0][MESH_0], TimeIter, StopCalc );
490491
}
491492

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

680681
/*--- Check whether the outer time integration has reached the final time ---*/
681682
TimeConvergence = GetTimeConvergence();
683+
682684
FinalTimeReached = CurTime >= MaxTime;
683685
MaxIterationsReached = TimeIter+1 >= nTimeIter;
684686

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

700702
bool CMultizoneDriver::GetTimeConvergence() const{
701-
return driver_output->GetTimeConvergence();
703+
return output_container[ZONE_0]->GetCauchyCorrectedTimeConvergence(config_container[ZONE_0]);
702704
}

SU2_CFD/src/drivers/CSinglezoneDriver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ CSinglezoneDriver::CSinglezoneDriver(char* confFile,
3939

4040
/*--- Initialize the counter for TimeIter ---*/
4141
TimeIter = 0;
42-
4342
}
4443

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

274273
TimeConvergence = GetTimeConvergence();
274+
275275
FinalTimeReached = CurTime >= MaxTime;
276276
MaxIterationsReached = TimeIter+1 >= nTimeIter;
277277

@@ -314,5 +314,5 @@ void CSinglezoneDriver::Runtime_Options(){
314314
}
315315

316316
bool CSinglezoneDriver::GetTimeConvergence() const{
317-
return output_container[ZONE_0]->GetTimeConvergence();
317+
return output_container[ZONE_0]->GetCauchyCorrectedTimeConvergence(config_container[ZONE_0]);
318318
}

SU2_CFD/src/output/COutput.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

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

51+
cauchyTimeConverged = false;
5152
this->nDim = nDim;
5253

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

740-
741+
bool COutput::GetCauchyCorrectedTimeConvergence(const CConfig *config){
742+
if(!cauchyTimeConverged && TimeConvergence && config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND){
743+
// Change flags for 2nd order Time stepping: In case of convergence, this iter and next iter gets written out. then solver stops
744+
cauchyTimeConverged = TimeConvergence;
745+
TimeConvergence = false;
746+
}
747+
else if(cauchyTimeConverged){
748+
TimeConvergence = cauchyTimeConverged;
749+
}
750+
return TimeConvergence;
751+
}
741752

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

745-
bool writeFiles = WriteVolume_Output(config, iter, force_writing);
756+
bool writeFiles = WriteVolume_Output(config, iter, force_writing || cauchyTimeConverged);
746757

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

0 commit comments

Comments
 (0)