www.mooseframework.org
Resurrector.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // MOOSE includes
11 #include "Resurrector.h"
12 #include "FEProblem.h"
13 #include "MooseUtils.h"
14 #include "MooseApp.h"
15 #include "NonlinearSystem.h"
16 
17 #include <stdio.h>
18 #include <sys/stat.h>
19 
20 const std::string Resurrector::MAT_PROP_EXT(".msmp");
21 const std::string Resurrector::RESTARTABLE_DATA_EXT(".rd");
22 
24  : PerfGraphInterface(fe_problem.getMooseApp().perfGraph(), "Resurrector"),
25  _fe_problem(fe_problem),
26  _restart_file_suffix("xdr"),
27  _restartable(_fe_problem),
28  _restart_from_file_timer(registerTimedSection("restartFromFile", 3)),
29  _restart_restartable_data_timer(registerTimedSection("restartRestartableData", 3))
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  TIME_SECTION(_restart_from_file_timer);
49 
50  std::string file_name(_restart_file_base + '.' + _restart_file_suffix);
53  unsigned int read_flags = EquationSystems::READ_DATA;
55  read_flags |= EquationSystems::READ_ADDITIONAL_DATA;
56 
57  // Set libHilbert renumbering flag to false. We don't support
58  // N-to-M restarts regardless, and if we're *never* going to do
59  // N-to-M restarts then libHilbert is just unnecessary computation
60  // and communication.
61  const bool renumber = false;
62 
63  // DECODE or READ based on suffix.
64  // MOOSE doesn't currently use partition-agnostic renumbering, since
65  // it can break restarts when multiple nodes are at the same point
66  _fe_problem.es().read(file_name, read_flags, renumber);
67 
69 }
70 
71 void
73 {
74  TIME_SECTION(_restart_restartable_data_timer);
75 
78 }
PerfID _restart_from_file_timer
Timers.
Definition: Resurrector.h:67
NonlinearSystemBase & getNonlinearSystemBase()
std::string _restart_file_suffix
name of the file extension that we restart from
Definition: Resurrector.h:61
Resurrector(FEProblemBase &fe_problem)
Definition: Resurrector.C:23
std::set< std::string > & getRecoverableData()
Return a reference to the recoverable data object.
Definition: MooseApp.h:487
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:1020
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:146
static const std::string MAT_PROP_EXT
Definition: Resurrector.h:70
void restartRestartableData()
Definition: Resurrector.C:72
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
Interface for objects that needs transient capabilities.
FEProblemBase & _fe_problem
Reference to a FEProblemBase being restarted.
Definition: Resurrector.h:55
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:481
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:71
void readRestartableData(const RestartableDatas &restartable_datas, const std::set< std::string > &_recoverable_data)
Read the restartable data.
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:94
RestartableDataIO _restartable
Restartable Data.
Definition: Resurrector.h:64
std::string _restart_file_base
name of the file that we restart from
Definition: Resurrector.h:58
PerfID _restart_restartable_data_timer
Definition: Resurrector.h:68
bool skipAdditionalRestartData() const
Whether or not to skip loading the additional data when restarting.