40 #include "CardiacSimulationArchiver.hpp"
43 #include "ArchiveOpener.hpp"
44 #include "OutputFileHandler.hpp"
45 #include "ArchiveLocationInfo.hpp"
46 #include "DistributedVectorFactory.hpp"
48 #include "FileFinder.hpp"
50 #include "MonodomainProblem.hpp"
51 #include "BidomainProblem.hpp"
52 #include "BidomainWithBathProblem.hpp"
54 template<
class PROBLEM_CLASS>
56 const std::string& rDirectory,
68 boost::archive::text_oarchive* p_main_archive = archive_opener.
GetCommonArchive();
71 PROBLEM_CLASS*
const p_simulation_to_archive = &rSimulationToArchive;
72 (*p_main_archive) & p_simulation_to_archive;
79 std::ofstream info_file(info_path.c_str());
80 if (!info_file.is_open())
84 EXCEPTION(
"Unable to open archive information file: " + info_path);
87 unsigned archive_version = 0;
95 EXCEPTION(
"Unable to open archive information file");
102 template<
class PROBLEM_CLASS>
109 template<
class PROBLEM_CLASS>
116 template<
class PROBLEM_CLASS>
123 EXCEPTION(
"Checkpoint directory does not exist: " + dir_path);
125 assert(*(dir_path.end()-1) ==
'/');
128 std::string info_path = dir_path +
"archive.info";
129 std::ifstream info_file(info_path.c_str());
130 if (!info_file.is_open())
132 EXCEPTION(
"Unable to open archive information file: " + info_path);
134 unsigned num_procs, archive_version;
135 info_file >> num_procs >> archive_version;
137 PROBLEM_CLASS *p_unarchived_simulation;
154 boost::archive::text_iarchive* p_main_archive = archive_opener.
GetCommonArchive();
155 (*p_main_archive) >> p_unarchived_simulation;
159 assert(p_factory != NULL);
161 assert(original_num_procs == num_procs);
164 for (
unsigned archive_num=0; archive_num<original_num_procs; archive_num++)
166 if (archive_num != initial_archive)
169 std::ifstream ifs(archive_path.c_str());
170 boost::archive::text_iarchive archive(ifs);
171 p_unarchived_simulation->LoadExtraArchive(archive, archive_version);
183 return p_unarchived_simulation;
static void SetCheckNumberOfProcessesOnLoad(bool checkNumberOfProcessesOnLoad=true)
static std::string GetProcessUniqueFilePath(const std::string &rFileName, unsigned procId=PetscTools::GetMyRank())
std::string GetAbsolutePath() const
#define EXCEPTION(message)
Archive * GetCommonArchive()
static void Save(PROBLEM_CLASS &rSimulationToArchive, const std::string &rDirectory, bool clearDirectory=true)
DistributedVectorFactory * GetOriginalFactory()
std::string GetOutputDirectoryFullPath() const
static PROBLEM_CLASS * Load(const std::string &rDirectory)
static PROBLEM_CLASS * Migrate(const FileFinder &rDirectory)
unsigned GetNumProcs() const