www.mooseframework.org
RestartableDataIO.h
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 #ifndef RESTARTABLEDATAIO_H
16 #define RESTARTABLEDATAIO_H
17 
18 // MOOSE includes
19 #include "DataIO.h"
20 
21 // C++ includes
22 #include <sstream>
23 #include <string>
24 #include <list>
25 
26 // Forward declarations
27 class Backup;
28 class RestartableDatas;
30 class FEProblemBase;
31 
38 {
39 public:
40  RestartableDataIO(FEProblemBase & fe_problem);
41 
42  virtual ~RestartableDataIO() = default;
43 
47  void writeRestartableData(std::string base_file_name,
48  const RestartableDatas & restartable_datas,
49  std::set<std::string> & _recoverable_data);
50 
55  void readRestartableDataHeader(std::string base_file_name);
56 
60  void readRestartableData(const RestartableDatas & restartable_datas,
61  const std::set<std::string> & _recoverable_data);
62 
66  std::shared_ptr<Backup> createBackup();
67 
71  void restoreBackup(std::shared_ptr<Backup> backup, bool for_restart = false);
72 
73 private:
77  void
78  serializeRestartableData(const std::map<std::string, RestartableDataValue *> & restartable_data,
79  std::ostream & stream);
80 
84  void
85  deserializeRestartableData(const std::map<std::string, RestartableDataValue *> & restartable_data,
86  std::istream & stream,
87  const std::set<std::string> & recoverable_data);
88 
92  void serializeSystems(std::ostream & stream);
93 
97  void deserializeSystems(std::istream & stream);
98 
101 
103  std::vector<std::shared_ptr<std::ifstream>> _in_file_handles;
104 };
105 
106 #endif /* RESTARTABLEDATAIO_H */
std::vector< std::shared_ptr< std::ifstream > > _in_file_handles
A vector of file handles, one per thread.
void serializeSystems(std::ostream &stream)
Serializes the data for the Systems in FEProblemBase.
void writeRestartableData(std::string base_file_name, const RestartableDatas &restartable_datas, std::set< std::string > &_recoverable_data)
Write out the restartable data.
virtual ~RestartableDataIO()=default
FEProblemBase & _fe_problem
Reference to a FEProblemBase being restarted.
Class for doing restart.
RestartableDataIO(FEProblemBase &fe_problem)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Container for storing material properties.
void readRestartableDataHeader(std::string base_file_name)
Read restartable data header to verify that we are restarting on the correct number of processors and...
Helper class to hold streams for Backup and Restore operations.
Definition: Backup.h:25
void deserializeRestartableData(const std::map< std::string, RestartableDataValue * > &restartable_data, std::istream &stream, const std::set< std::string > &recoverable_data)
Deserializes the data from the stream object.
void serializeRestartableData(const std::map< std::string, RestartableDataValue * > &restartable_data, std::ostream &stream)
Serializes the data into the stream object.
void readRestartableData(const RestartableDatas &restartable_datas, const std::set< std::string > &_recoverable_data)
Read the restartable data.
std::shared_ptr< Backup > createBackup()
Create a Backup for the current system.
Abstract definition of a RestartableData value.
void restoreBackup(std::shared_ptr< Backup > backup, bool for_restart=false)
Restore a Backup for the current system.
void deserializeSystems(std::istream &stream)
Deserializes the data for the Systems in FEProblemBase.