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 committed Apr 5, 2023
1 parent 5f4c091 commit 37669b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions framework/include/outputs/Checkpoint.h
Expand Up @@ -13,6 +13,7 @@
#include "FileOutput.h"
#include "RestartableDataIO.h"

#include <chrono>
#include <deque>

/**
Expand Down Expand Up @@ -124,6 +125,9 @@ 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";
};
8 changes: 8 additions & 0 deletions framework/src/outputs/Checkpoint.C
Expand Up @@ -61,6 +61,8 @@ Checkpoint::Checkpoint(const InputParameters & parameters)
_restartable_data(_app.getRestartableData()),
_restartable_data_io(RestartableDataIO(*_problem_ptr))
{
if (_is_autosave == SYSTEM_AUTOSAVE || (_is_autosave == MODIFIED_EXISTING))
start_time = std::chrono::steady_clock::now();
}

std::string
Expand Down Expand Up @@ -110,6 +112,12 @@ Checkpoint::shouldOutput(const ExecFlagType & type)
// as the autosave and that checkpoint isn't on its interval, then output.
if (_is_autosave == SYSTEM_AUTOSAVE || (_is_autosave == MODIFIED_EXISTING && !shouldOutput))
{
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 37669b5

Please sign in to comment.