diff --git a/src/io/BoundaryProbeWriter.cpp b/src/io/BoundaryProbeWriter.cpp index 6621d4f6..55be2cf3 100644 --- a/src/io/BoundaryProbeWriter.cpp +++ b/src/io/BoundaryProbeWriter.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace tndm { @@ -83,7 +84,12 @@ void BoundaryProbeWriter::write(double time, out_->open(probe.file_name, false); write_header(probe, functions); } else { - out_->open(probe.file_name, true); + if (std::filesystem::exists(probe.file_name)) { + out_->open(probe.file_name, true); + } else { + out_->open(probe.file_name, false); + write_header(probe, functions); + } } *out_ << time; diff --git a/src/io/ProbeWriter.cpp b/src/io/ProbeWriter.cpp index d2b3bcb8..54c6f8b3 100644 --- a/src/io/ProbeWriter.cpp +++ b/src/io/ProbeWriter.cpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace tndm { @@ -81,7 +82,12 @@ void ProbeWriter::write(double time, mneme::span> fu out_->open(probe.file_name, false); write_header(probe, functions); } else { - out_->open(probe.file_name, true); + if (std::filesystem::exists(probe.file_name)) { + out_->open(probe.file_name, true); + } else { + out_->open(probe.file_name, false); + write_header(probe, functions); + } } *out_ << time; diff --git a/src/io/ScalarWriter.cpp b/src/io/ScalarWriter.cpp index 5ba7fb28..1d779c39 100644 --- a/src/io/ScalarWriter.cpp +++ b/src/io/ScalarWriter.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace tndm { @@ -19,7 +20,12 @@ void ScalarWriter::write(double time, mneme::span scalars) const { out_->open(file_name_, false); write_header(); } else { - out_->open(file_name_, true); + if (std::filesystem::exists(file_name_)) { + out_->open(file_name_, true); + } else { + out_->open(file_name_, false); + write_header(); + } } *out_ << time;