Skip to content

Commit 8f6b9f1

Browse files
authored
Check if implicit diagnostics file exist before writing the header (BLAST-WarpX#5750)
This is a small fix to prevent the implicit diagnostics file from being overwritten during a restart.
1 parent 230c542 commit 8f6b9f1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Source/NonlinearSolvers/NewtonSolver.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ void NewtonSolver<Vec,Ops>::Define ( const Vec& a_U,
204204
this->m_is_defined = true;
205205

206206
// Create diagnostic file and write header
207-
if (!this->m_diagnostic_file.empty() && amrex::ParallelDescriptor::IOProcessor()) {
207+
if (amrex::ParallelDescriptor::IOProcessor()
208+
&& !this->m_diagnostic_file.empty()
209+
&& !amrex::FileExists(this->m_diagnostic_file)) {
208210

209211
std::filesystem::path const diagnostic_path(this->m_diagnostic_file);
210212
std::filesystem::path const diagnostic_dir = diagnostic_path.parent_path();

Source/NonlinearSolvers/PicardSolver.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ void PicardSolver<Vec,Ops>::Define ( const Vec& a_U,
118118
this->m_is_defined = true;
119119

120120
// Create diagnostic file and write header
121-
if (!this->m_diagnostic_file.empty() && amrex::ParallelDescriptor::IOProcessor()) {
121+
if (amrex::ParallelDescriptor::IOProcessor()
122+
&& !this->m_diagnostic_file.empty()
123+
&& !amrex::FileExists(this->m_diagnostic_file)) {
122124

123125
std::filesystem::path const diagnostic_path(this->m_diagnostic_file);
124126
std::filesystem::path const diagnostic_dir = diagnostic_path.parent_path();

0 commit comments

Comments
 (0)