#include <ArchiveOpener.hpp>
Public Member Functions | |
ArchiveOpener (const FileFinder &rDirectory, const std::string &rFileNameBase, unsigned procId=PetscTools::GetMyRank()) | |
~ArchiveOpener () | |
Archive * | GetCommonArchive () |
template<> | |
ArchiveOpener (const FileFinder &rDirectory, const std::string &rFileNameBase, unsigned procId) | |
template<> | |
ArchiveOpener (const FileFinder &rDirectory, const std::string &rFileNameBase, unsigned procId) | |
Private Attributes | |
Stream * | mpCommonStream |
Stream * | mpPrivateStream |
Archive * | mpCommonArchive |
Archive * | mpPrivateArchive |
Friends | |
class | TestArchivingHelperClasses |
When checkpointing a parallel simulation, there are two kinds of data that need to be saved: replicated (same for every process) and distributed (different on each process). We wish to write these to separate archive files. This class hides the complexity of doing so, such that all a user needs to do is create an instance of this class, call GetCommonArchive, and read from/write to the returned archive. When done, just destroy the instance (e.g. by closing the scope).
Internally the class uses ProcessSpecificArchive<Archive> to store the secondary archive.
Note also that implementations of this templated class only exist for text archives, i.e. Archive = boost::archive::text_iarchive (with Stream = std::ifstream), or Archive = boost::archive::text_oarchive (with Stream = std::ofstream).
Definition at line 54 of file ArchiveOpener.hpp.
ArchiveOpener< Archive, Stream >::ArchiveOpener | ( | const FileFinder & | rDirectory, | |
const std::string & | rFileNameBase, | |||
unsigned | procId = PetscTools::GetMyRank() | |||
) |
Open the archives for this process, either for reading or writing depending on the template parameter Archive.
Note that when writing, only the master process writes to the main archive. For other processes the main archive is a dummy, writing to /dev/null.
rDirectory | folder containing archive files. | |
rFileNameBase | base name of archive files. This will be used for the main archive (for replicated data) with ".n" (where n is the process index) being appended for the secondary archive. | |
procId | this can be specified to read a specific secondary archive, rather than this process' default. Should not be used for writing! |
ArchiveOpener< Archive, Stream >::~ArchiveOpener | ( | ) |
Close the opened archives.
ArchiveOpener< boost::archive::text_iarchive, std::ifstream >::ArchiveOpener | ( | const FileFinder & | rDirectory, | |
const std::string & | rFileNameBase, | |||
unsigned | procId | |||
) | [inline] |
Specialization for input archives.
rDirectory | ||
rFileNameBase | ||
procId |
Definition at line 49 of file ArchiveOpener.cpp.
References EXCEPTION, ArchiveLocationInfo::GetArchiveDirectory(), ArchiveLocationInfo::GetProcessUniqueFilePath(), ArchiveOpener< Archive, Stream >::mpCommonArchive, ArchiveOpener< Archive, Stream >::mpCommonStream, ArchiveOpener< Archive, Stream >::mpPrivateArchive, ArchiveOpener< Archive, Stream >::mpPrivateStream, ProcessSpecificArchive< Archive >::Set(), and ArchiveLocationInfo::SetArchiveDirectory().
ArchiveOpener< boost::archive::text_oarchive, std::ofstream >::ArchiveOpener | ( | const FileFinder & | rDirectory, | |
const std::string & | rFileNameBase, | |||
unsigned | procId | |||
) | [inline] |
Specialization for output archives.
rDirectory | ||
rFileNameBase | ||
procId |
Definition at line 123 of file ArchiveOpener.cpp.
References PetscTools::AmMaster(), EXCEPTION, ArchiveLocationInfo::GetArchiveDirectory(), ArchiveLocationInfo::GetArchiveRelativePath(), ArchiveLocationInfo::GetIsDirRelativeToChasteTestOutput(), PetscTools::GetMyRank(), ArchiveLocationInfo::GetProcessUniqueFilePath(), ArchiveOpener< Archive, Stream >::mpCommonArchive, ArchiveOpener< Archive, Stream >::mpCommonStream, ArchiveOpener< Archive, Stream >::mpPrivateArchive, ArchiveOpener< Archive, Stream >::mpPrivateStream, ProcessSpecificArchive< Archive >::Set(), and ArchiveLocationInfo::SetArchiveDirectory().
Archive* ArchiveOpener< Archive, Stream >::GetCommonArchive | ( | ) | [inline] |
Get the main archive for replicated data.
Definition at line 90 of file ArchiveOpener.hpp.
References ArchiveOpener< Archive, Stream >::mpCommonArchive.
Referenced by CryptSimulationArchiver< DIM, SIM >::Load(), CellBasedSimulationArchiver< DIM, SIM >::Load(), CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate(), and CardiacSimulationArchiver< PROBLEM_CLASS >::Save().
Stream* ArchiveOpener< Archive, Stream >::mpCommonStream [private] |
The file stream for the main archive
Definition at line 97 of file ArchiveOpener.hpp.
Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener().
Stream* ArchiveOpener< Archive, Stream >::mpPrivateStream [private] |
The file stream for the secondary archive
Definition at line 99 of file ArchiveOpener.hpp.
Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener().
Archive* ArchiveOpener< Archive, Stream >::mpCommonArchive [private] |
The main archive
Definition at line 101 of file ArchiveOpener.hpp.
Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener(), and ArchiveOpener< Archive, Stream >::GetCommonArchive().
Archive* ArchiveOpener< Archive, Stream >::mpPrivateArchive [private] |
The secondary archive
Definition at line 103 of file ArchiveOpener.hpp.
Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener().