Skip to content

Commit

Permalink
Merge pull request #60 from JeenaYun/dmay/seas-checkpoint
Browse files Browse the repository at this point in the history
Allow creating outputs file when simulation starts at non-zero time
  • Loading branch information
hpc4geo authored Oct 13, 2023
2 parents 3b489de + 8596c33 commit 1dc36db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/io/BoundaryProbeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <filesystem>

namespace tndm {

Expand Down Expand Up @@ -83,7 +84,12 @@ void BoundaryProbeWriter<D>::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;
Expand Down
8 changes: 7 additions & 1 deletion src/io/ProbeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <filesystem>

namespace tndm {

Expand Down Expand Up @@ -81,7 +82,12 @@ void ProbeWriter<D>::write(double time, mneme::span<FiniteElementFunction<D>> 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;
Expand Down
8 changes: 7 additions & 1 deletion src/io/ScalarWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <iomanip>
#include <ios>
#include <filesystem>

namespace tndm {

Expand All @@ -19,7 +20,12 @@ void ScalarWriter::write(double time, mneme::span<double> 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;
Expand Down

0 comments on commit 1dc36db

Please sign in to comment.