www.mooseframework.org
Resurrector.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
16 #include "Resurrector.h"
17 #include "FEProblem.h"
18 #include "MooseUtils.h"
19 #include "MooseApp.h"
20 #include "NonlinearSystem.h"
21 
22 #include <stdio.h>
23 #include <sys/stat.h>
24 
25 const std::string Resurrector::MAT_PROP_EXT(".msmp");
26 const std::string Resurrector::RESTARTABLE_DATA_EXT(".rd");
27 
29  : _fe_problem(fe_problem), _restart_file_suffix("xdr"), _restartable(_fe_problem)
30 {
31 }
32 
33 void
34 Resurrector::setRestartFile(const std::string & file_base)
35 {
36  _restart_file_base = file_base;
37 }
38 
39 void
40 Resurrector::setRestartSuffix(const std::string & file_ext)
41 {
42  _restart_file_suffix = file_ext;
43 }
44 
45 void
47 {
48  Moose::perf_log.push("restartFromFile()", "Setup");
49  std::string file_name(_restart_file_base + '.' + _restart_file_suffix);
52  unsigned int read_flags = EquationSystems::READ_DATA;
54  read_flags |= EquationSystems::READ_ADDITIONAL_DATA;
55 
56  // Set libHilbert renumbering flag to false. We don't support
57  // N-to-M restarts regardless, and if we're *never* going to do
58  // N-to-M restarts then libHilbert is just unnecessary computation
59  // and communication.
60  const bool renumber = false;
61 
62  // DECODE or READ based on suffix.
63  // MOOSE doesn't currently use partition-agnostic renumbering, since
64  // it can break restarts when multiple nodes are at the same point
65  _fe_problem.es().read(file_name, read_flags, renumber);
66 
68  Moose::perf_log.pop("restartFromFile()", "Setup");
69 }
70 
71 void
73 {
74  Moose::perf_log.push("restartRestartableData()", "Setup");
77  Moose::perf_log.pop("restartRestartableData()", "Setup");
78 }
NonlinearSystemBase & getNonlinearSystemBase()
std::string _restart_file_suffix
name of the file extension that we restart from
Definition: Resurrector.h:66
Resurrector(FEProblemBase &fe_problem)
Definition: Resurrector.C:28
bool skipAdditionalRestartData() const
Whether or not to skip loading the additional data when restarting.
std::set< std::string > & getRecoverableData()
Return a reference to the recoverable data object.
Definition: MooseApp.h:439
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual EquationSystems & es() override
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:665
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true)
Checks to see if a file is readable (exists and permissions)
Definition: MooseUtils.C:121
static const std::string MAT_PROP_EXT
Definition: Resurrector.h:71
void restartRestartableData()
Definition: Resurrector.C:72
PerfLog perf_log
Perflog to be used by applications.
void readRestartableDataHeader(std::string base_file_name)
Read restartable data header to verify that we are restarting on the correct number of processors and...
void setRestartFile(const std::string &file_base)
Set the file base name from which we will restart.
Definition: Resurrector.C:34
MooseApp & getMooseApp()
Get the MooseApp this object is associated with.
Definition: MooseObject.h:72
FEProblemBase & _fe_problem
Reference to a FEProblemBase being restarted.
Definition: Resurrector.h:60
void restartFromFile()
Perform a restart from a file.
Definition: Resurrector.C:46
const RestartableDatas & getRestartableData()
Return reference to the restatable data object.
Definition: MooseApp.h:433
void setRestartSuffix(const std::string &file_ext)
Set the file extension from which we will restart libMesh equation systems.
Definition: Resurrector.C:40
static const std::string RESTARTABLE_DATA_EXT
Definition: Resurrector.h:72
void readRestartableData(const RestartableDatas &restartable_datas, const std::set< std::string > &_recoverable_data)
Read the restartable data.
RestartableDataIO _restartable
Restartable Data.
Definition: Resurrector.h:69
std::string _restart_file_base
name of the file that we restart from
Definition: Resurrector.h:63