www.mooseframework.org
SetupRecoverFileBaseAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
17 #include "MooseApp.h"
18 #include "OutputWarehouse.h"
19 #include "Checkpoint.h"
20 #include "MooseObjectAction.h"
21 
22 template <>
25 {
27  return params;
28 }
29 
31 
32 void
34 {
35  // Do nothing if the App is not recovering
36  // Don't look for a checkpoint file unless we're the ultimate master app
38  return;
39 
40  // Get the most current file, if it hasn't been set directly
41  if (!_app.hasRecoverFileBase())
42  {
43  // Build the list of all possible checkpoint files for recover
44  std::list<std::string> checkpoint_files = _app.getCheckpointFiles();
45 
46  // Grab the most recent one
47  std::string recovery_file_base = MooseUtils::getLatestAppCheckpointFileBase(checkpoint_files);
48 
49  if (recovery_file_base.empty())
50  mooseError("Unable to find suitable recovery file!");
51 
52  _app.setRecoverFileBase(recovery_file_base);
53  }
54 
55  // Set the recover file base in the App
56  _console << "\nUsing " << _app.getRecoverFileBase() << " for recovery.\n\n";
57 }
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:607
std::list< std::string > getCheckpointFiles()
Extract all possible checkpoint file names.
Definition: MooseApp.C:779
std::string getRecoverFileBase()
The file_base for the recovery file.
Definition: MooseApp.h:318
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for actions.
Definition: Action.h:39
std::string getLatestAppCheckpointFileBase(const std::list< std::string > &checkpoint_files)
Definition: MooseUtils.C:503
SetupRecoverFileBaseAction(InputParameters params)
Class constructor.
bool hasRecoverFileBase()
Return true if the recovery file base is set.
Definition: MooseApp.C:619
void setRecoverFileBase(std::string recover_base)
mutator for recover_base (set by RecoverBaseAction)
Definition: MooseApp.h:323
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
InputParameters validParams< SetupRecoverFileBaseAction >()
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:98
bool isUltimateMaster()
Whether or not this app is the ultimate master app.
Definition: MooseApp.h:476
InputParameters validParams< Action >()
Definition: Action.C:23