www.mooseframework.org
RestartableDataIO.h
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 #pragma once
11 
12 // MOOSE includes
13 #include "DataIO.h"
14 #include "RestartableData.h"
15 
16 // C++ includes
17 #include <sstream>
18 #include <string>
19 #include <list>
20 
21 // Forward declarations
22 class Backup;
23 class FEProblemBase;
24 
31 {
32 public:
33  RestartableDataIO(FEProblemBase & fe_problem);
34 
35  virtual ~RestartableDataIO() = default;
36 
40  void writeRestartableData(std::string base_file_name,
41  const RestartableDatas & restartable_datas,
42  std::set<std::string> & _recoverable_data);
43 
48  void readRestartableDataHeader(std::string base_file_name);
49 
53  void readRestartableData(const RestartableDatas & restartable_datas,
54  const std::set<std::string> & _recoverable_data);
55 
59  std::shared_ptr<Backup> createBackup();
60 
64  void restoreBackup(std::shared_ptr<Backup> backup, bool for_restart = false);
65 
66 private:
71  const std::map<std::string, std::unique_ptr<RestartableDataValue>> & restartable_data,
72  std::ostream & stream);
73 
78  const std::map<std::string, std::unique_ptr<RestartableDataValue>> & restartable_data,
79  std::istream & stream,
80  const std::set<std::string> & recoverable_data);
81 
85  void serializeSystems(std::ostream & stream);
86 
90  void deserializeSystems(std::istream & stream);
91 
94 
96  std::vector<std::shared_ptr<std::ifstream>> _in_file_handles;
97 };
98 
std::vector< std::shared_ptr< std::ifstream > > _in_file_handles
A vector of file handles, one per thread.
std::vector< std::map< std::string, std::unique_ptr< RestartableDataValue > >> RestartableDatas
Container for storing material properties.
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.
void serializeRestartableData(const std::map< std::string, std::unique_ptr< RestartableDataValue >> &restartable_data, std::ostream &stream)
Serializes the data into the stream object.
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 deserializeRestartableData(const std::map< std::string, std::unique_ptr< RestartableDataValue >> &restartable_data, std::istream &stream, const std::set< std::string > &recoverable_data)
Deserializes the data from the stream object.
Helper class to hold streams for Backup and Restore operations.
Definition: Backup.h:20
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.
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.