From eb0bd3a3fb37cef8fcb334382c4f727a5edc40fa Mon Sep 17 00:00:00 2001 From: Justin Angus Date: Sun, 30 Aug 2026 18:01:56 -0700 Subject: [PATCH 1/2] append to dt_updates. --- Source/Evolve/WarpXComputeDt.cpp | 38 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Source/Evolve/WarpXComputeDt.cpp b/Source/Evolve/WarpXComputeDt.cpp index 5d733942c24..87b09d9467d 100644 --- a/Source/Evolve/WarpXComputeDt.cpp +++ b/Source/Evolve/WarpXComputeDt.cpp @@ -237,31 +237,37 @@ WarpX::WriteDtUpdateFileHeader () // If not a restart, discard the file if already exists. auto file_mode = std::ofstream::out; - if (IsNotRestart) { file_mode |= std::ofstream::trunc; } + if (IsNotRestart) { + file_mode = std::ofstream::out | std::ofstream::trunc; + } else { + file_mode = std::ofstream::out | std::ofstream::app; + } std::ofstream diagnostic_file{m_dt_update_diagnostic_file, file_mode}; if (!diagnostic_file.is_open()) { amrex::Abort("Failed to open file: " + m_dt_update_diagnostic_file); } - int c = 0; - diagnostic_file << "#"; - diagnostic_file << "[" << c++ << "]step()"; - diagnostic_file << " "; - diagnostic_file << "[" << c++ << "]time(s)"; - diagnostic_file << " "; - diagnostic_file << "[" << c++ << "]new_dt"; - diagnostic_file << " "; - diagnostic_file << "[" << c++ << "]vmax_dt"; - if (m_max_omegap_dt.has_value()) { + if (IsNotRestart) { + int c = 0; + diagnostic_file << "#"; + diagnostic_file << "[" << c++ << "]step()"; diagnostic_file << " "; - diagnostic_file << "[" << c++ << "]omegap_dt"; - } - if (m_max_omegac_dt.has_value()) { + diagnostic_file << "[" << c++ << "]time(s)"; diagnostic_file << " "; - diagnostic_file << "[" << c++ << "]omegac_dt"; + diagnostic_file << "[" << c++ << "]new_dt"; + diagnostic_file << " "; + diagnostic_file << "[" << c++ << "]vmax_dt"; + if (m_max_omegap_dt.has_value()) { + diagnostic_file << " "; + diagnostic_file << "[" << c++ << "]omegap_dt"; + } + if (m_max_omegac_dt.has_value()) { + diagnostic_file << " "; + diagnostic_file << "[" << c++ << "]omegac_dt"; + } + diagnostic_file << "\n"; } - diagnostic_file << "\n"; diagnostic_file.close(); } From 49a8fffbde156266beaf21f92a6b7d0914de6451 Mon Sep 17 00:00:00 2001 From: Justin Angus Date: Mon, 31 Aug 2026 10:59:35 -0700 Subject: [PATCH 2/2] clean up logic. --- Source/Evolve/WarpXComputeDt.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Source/Evolve/WarpXComputeDt.cpp b/Source/Evolve/WarpXComputeDt.cpp index 87b09d9467d..68cde5c7fce 100644 --- a/Source/Evolve/WarpXComputeDt.cpp +++ b/Source/Evolve/WarpXComputeDt.cpp @@ -236,19 +236,13 @@ WarpX::WriteDtUpdateFileHeader () const bool IsNotRestart = restart_chkfile.empty(); // If not a restart, discard the file if already exists. - auto file_mode = std::ofstream::out; if (IsNotRestart) { - file_mode = std::ofstream::out | std::ofstream::trunc; - } else { - file_mode = std::ofstream::out | std::ofstream::app; - } - - std::ofstream diagnostic_file{m_dt_update_diagnostic_file, file_mode}; - if (!diagnostic_file.is_open()) { - amrex::Abort("Failed to open file: " + m_dt_update_diagnostic_file); - } + auto file_mode = std::ofstream::out | std::ofstream::trunc; + std::ofstream diagnostic_file{m_dt_update_diagnostic_file, file_mode}; + if (!diagnostic_file.is_open()) { + amrex::Abort("Failed to open file: " + m_dt_update_diagnostic_file); + } - if (IsNotRestart) { int c = 0; diagnostic_file << "#"; diagnostic_file << "[" << c++ << "]step()"; @@ -267,8 +261,8 @@ WarpX::WriteDtUpdateFileHeader () diagnostic_file << "[" << c++ << "]omegac_dt"; } diagnostic_file << "\n"; + diagnostic_file.close(); } - diagnostic_file.close(); } }