Skip to content

Commit

Permalink
Added realtime checkpoint autosaves after 10 minutes idaholab#12722
Browse files Browse the repository at this point in the history
  • Loading branch information
socratesgorilla authored and permcody committed Oct 2, 2023
1 parent 4e9d07e commit 71a71f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions framework/include/outputs/Checkpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// MOOSE includes
#include "FileOutput.h"

#include <chrono>
#include <deque>
#include <filesystem>

Expand Down Expand Up @@ -103,4 +104,10 @@ class Checkpoint : public FileOutput

/// Vector of checkpoint filename structures
std::deque<CheckpointFileNames> _file_names;

/// Starting time compared against to see if we should automatically print out a checkpoint
std::chrono::time_point<std::chrono::steady_clock> start_time;

static constexpr auto ASCII_MESH_SUFFIX = "_mesh.cpa";
static constexpr auto BINARY_MESH_SUFFIX = "_mesh.cpr";
};
9 changes: 9 additions & 0 deletions framework/src/outputs/Checkpoint.C
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Checkpoint::Checkpoint(const InputParameters & parameters)
_num_files(getParam<unsigned int>("num_files")),
_suffix(getParam<std::string>("suffix"))
{
if (_is_autosave == SYSTEM_AUTOSAVE || (_is_autosave == MODIFIED_EXISTING))
start_time = std::chrono::steady_clock::now();
}

std::string
Expand Down Expand Up @@ -114,6 +116,13 @@ Checkpoint::shouldOutput()
// as the autosave and that checkpoint isn't on its interval, then output.
if (_is_autosave == SYSTEM_AUTOSAVE || (_is_autosave == MODIFIED_EXISTING && !should_output))
{
auto curr_time = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::minutes>(curr_time - start_time);
if (elapsed >= std::chrono::minutes(10))
{
start_time = std::chrono::steady_clock::now();
return true;
}
// If this is a pure system-created autosave through AutoCheckpointAction,
// then sync across processes and only output one time per signal received.
comm().max(Moose::interrupt_signal_number);
Expand Down

0 comments on commit 71a71f1

Please sign in to comment.