From 812c739c3f120e8ede2f1a2da974b66c340a7da7 Mon Sep 17 00:00:00 2001 From: Hsi-Yu Schive Date: Wed, 25 Dec 2024 18:03:01 +0800 Subject: [PATCH 1/6] Reset END_T when using the dump table --- src/Init/Init_Load_DumpTable.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/Init/Init_Load_DumpTable.cpp b/src/Init/Init_Load_DumpTable.cpp index 0307bdf2ac..54f715460d 100644 --- a/src/Init/Init_Load_DumpTable.cpp +++ b/src/Init/Init_Load_DumpTable.cpp @@ -46,23 +46,41 @@ void Init_Load_DumpTable() // stop the reading if ( input_line[0] == 42 ) // '*' == 42 { - // ensure that at least one data dump time is loaded if ( line == 0 ) Aux_Error( ERROR_INFO, "please provide at least one data dump time in the dump table !!\n" ); - DumpTable_NDump = line; // record the number of data dumps - DumpTable[line] = __FLT_MAX__; // set the next dump as an extremely large number + DumpTable_NDump = line; // record the number of data dumps + DumpTable[line] = __FLT_MAX__; // set the next dump as an extremely large number - if ( DumpTable[line-1] < END_T ) +// for END_T < 0.0, reset the ending time as the time of the last dump + if ( END_T < 0.0 ) { - END_T = DumpTable[line-1]; // reset the ending time as the time of the last dump + END_T = DumpTable[line-1]; if ( MPI_Rank == 0 ) - Aux_Message( stdout, "NOTE : the END_T is reset to the time of the last data dump = %13.7e\n", - END_T ); + Aux_Message( stdout, "NOTE : END_T is reset to the time of the last data dump in %s: %13.7e\n", + FileName, END_T ); } +// for END_T >= 0.0, reset the ending time to the largest data dump time not greater than the input END_T + else + { + for (int t=line-1; t>=0; t--) + { + if ( END_T > DumpTable[t] ) + { + END_T = DumpTable[t]; + + if ( MPI_Rank == 0 ) + Aux_Message( stdout, "NOTE : END_T is reset to the largest time in %s not greater " + "than the input END_T: %13.7e\n", + FileName, END_T ); + break; + } + } + } // if ( END_T < 0.0 ) ... else ... + // verify the loaded dump table for (int t=1; t<=line; t++) From fb7b53e58341d8efeecb2e48631357fd937561fc Mon Sep 17 00:00:00 2001 From: vivi235711 Date: Thu, 17 Apr 2025 16:44:26 +0800 Subject: [PATCH 2/6] Insert initial time into the dump table This ensures the initial time is always included in the dump table without duplications or disrupting order. --- src/Init/Init_Load_DumpTable.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Init/Init_Load_DumpTable.cpp b/src/Init/Init_Load_DumpTable.cpp index 54f715460d..9801f621e9 100644 --- a/src/Init/Init_Load_DumpTable.cpp +++ b/src/Init/Init_Load_DumpTable.cpp @@ -104,6 +104,24 @@ void Init_Load_DumpTable() if ( input_line != NULL ) free( input_line ); +// insert initial time Time[0] + for (int t=0; t DumpTable[t-1] ) ) + { + for (int s=DumpTable_NDump; s>t; s--) + DumpTable[s] = DumpTable[s-1]; + DumpTable[t] = Time[0]; + DumpTable_NDump++; + Aux_Message( stdout, "NOTE : initial time %13.7e is inserted into the dump table\n", Time[0] ); + break; + } + } if ( MPI_Rank == 0 ) Aux_Message( stdout, "Init_Load_DumpTable ... done\n" ); From b95702134a09a58311f3938eda36b09bd42e8ade Mon Sep 17 00:00:00 2001 From: Hsi-Yu Schive Date: Sun, 27 Apr 2025 15:35:24 +0800 Subject: [PATCH 3/6] Minor --- src/Init/Init_Load_DumpTable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Init/Init_Load_DumpTable.cpp b/src/Init/Init_Load_DumpTable.cpp index 54f715460d..dbf02c999c 100644 --- a/src/Init/Init_Load_DumpTable.cpp +++ b/src/Init/Init_Load_DumpTable.cpp @@ -97,7 +97,7 @@ void Init_Load_DumpTable() if ( line == MaxLine ) - Aux_Error( ERROR_INFO, "please prepare a symbol * in the end of the file <%s> !!\n", FileName ); + Aux_Error( ERROR_INFO, "please prepare a * symbol at the end of the file <%s> !!\n", FileName ); fclose( File ); From 50708e314c47ffa436fe2990d81c045089156ca3 Mon Sep 17 00:00:00 2001 From: Hsi-Yu Schive Date: Sun, 27 Apr 2025 15:53:01 +0800 Subject: [PATCH 4/6] Handle the case END_T==DumpTable[t] --- src/Init/Init_Load_DumpTable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Init/Init_Load_DumpTable.cpp b/src/Init/Init_Load_DumpTable.cpp index dbf02c999c..2a364b3356 100644 --- a/src/Init/Init_Load_DumpTable.cpp +++ b/src/Init/Init_Load_DumpTable.cpp @@ -68,7 +68,7 @@ void Init_Load_DumpTable() { for (int t=line-1; t>=0; t--) { - if ( END_T > DumpTable[t] ) + if ( END_T >= DumpTable[t] ) { END_T = DumpTable[t]; From cd38b85a29e0a800199b69bc6873a99c307e10fd Mon Sep 17 00:00:00 2001 From: Hsi-Yu Schive Date: Sun, 27 Apr 2025 16:01:39 +0800 Subject: [PATCH 5/6] Raise an error if duplicate values are found in the dump table --- src/Init/Init_Load_DumpTable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Init/Init_Load_DumpTable.cpp b/src/Init/Init_Load_DumpTable.cpp index 2a364b3356..97e3dbd1e0 100644 --- a/src/Init/Init_Load_DumpTable.cpp +++ b/src/Init/Init_Load_DumpTable.cpp @@ -85,7 +85,7 @@ void Init_Load_DumpTable() // verify the loaded dump table for (int t=1; t<=line; t++) { - if ( DumpTable[t] < DumpTable[t-1] ) + if ( DumpTable[t] <= DumpTable[t-1] ) Aux_Error( ERROR_INFO, "values recorded in \"%s\" must be monotonically increasing !!\n", FileName ); } From c12eb00765a8697aafd46c083a2325364abd8aed Mon Sep 17 00:00:00 2001 From: Hsi-Yu Schive Date: Sun, 27 Apr 2025 17:03:55 +0800 Subject: [PATCH 6/6] Minor --- src/Init/Init_Load_DumpTable.cpp | 18 +++++++++++------- src/Output/Output_DumpData.cpp | 12 ++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Init/Init_Load_DumpTable.cpp b/src/Init/Init_Load_DumpTable.cpp index 4838198c80..dc056ab47c 100644 --- a/src/Init/Init_Load_DumpTable.cpp +++ b/src/Init/Init_Load_DumpTable.cpp @@ -104,25 +104,29 @@ void Init_Load_DumpTable() if ( input_line != NULL ) free( input_line ); + // insert initial time Time[0] for (int t=0; t DumpTable[t-1] ) ) + if ( ( Time[0] < DumpTable[t] ) && ( t == 0 || Time[0] > DumpTable[t-1] ) ) { - for (int s=DumpTable_NDump; s>t; s--) - DumpTable[s] = DumpTable[s-1]; + for (int s=DumpTable_NDump; s>t; s--) DumpTable[s] = DumpTable[s-1]; DumpTable[t] = Time[0]; - DumpTable_NDump++; - Aux_Message( stdout, "NOTE : initial time %13.7e is inserted into the dump table\n", Time[0] ); + DumpTable_NDump ++; + + if ( MPI_Rank == 0 ) + Aux_Message( stdout, "NOTE : initial time %13.7e is inserted into the dump table\n", Time[0] ); + break; } } + if ( MPI_Rank == 0 ) Aux_Message( stdout, "Init_Load_DumpTable ... done\n" ); } // FUNCTION : Init_Load_DumpTable diff --git a/src/Output/Output_DumpData.cpp b/src/Output/Output_DumpData.cpp index 8a319031a0..b5cee8364e 100644 --- a/src/Output/Output_DumpData.cpp +++ b/src/Output/Output_DumpData.cpp @@ -56,9 +56,9 @@ void Output_DumpData( const int Stage ) DumpTime = round( int(Time[0]/OUTPUT_DT) + 1.0 )*OUTPUT_DT; // be careful about round-off errors - if ( ( DumpTime <= Time[0] ) || - ( Time[0] != 0.0 && fabs( (Time[0]-DumpTime)/Time[0] ) < 1.0e-8 ) || - ( Time[0] == 0.0 && fabs( Time[0]-DumpTime ) < 1.0e-12 ) ) DumpTime += OUTPUT_DT; + if ( ( DumpTime <= Time[0] ) || + ( Time[0] != 0.0 && fabs( (Time[0]-DumpTime)/Time[0] ) < 1.0e-8 ) || + ( Time[0] == 0.0 && fabs( Time[0]-DumpTime ) < 1.0e-12 ) ) DumpTime += OUTPUT_DT; } } break; @@ -71,9 +71,9 @@ void Output_DumpData( const int Stage ) { DumpTime = DumpTable[DumpTableID]; - if ( ( DumpTime >= Time[0] ) || - ( Time[0] != 0.0 && fabs( (Time[0]-DumpTime)/Time[0] ) < 1.0e-8 ) || - ( Time[0] == 0.0 && fabs( Time[0]-DumpTime ) < 1.0e-12 ) ) break; + if ( ( DumpTime >= Time[0] ) || + ( Time[0] != 0.0 && fabs( (Time[0]-DumpTime)/Time[0] ) < 1.0e-8 ) || + ( Time[0] == 0.0 && fabs( Time[0]-DumpTime ) < 1.0e-12 ) ) break; } }