Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
ArchiveOpener< Archive, Stream > Class Template Reference

#include <ArchiveOpener.hpp>

+ Collaboration diagram for ArchiveOpener< Archive, Stream >:

Public Member Functions

 ArchiveOpener (const FileFinder &rDirectory, const std::string &rFileNameBase, unsigned procId=PetscTools::GetMyRank())
 
 ~ArchiveOpener ()
 
Archive * GetCommonArchive ()
 
 ArchiveOpener (const FileFinder &rDirectory, const std::string &rFileNameBase, unsigned procId)
 
 ArchiveOpener (const FileFinder &rDirectory, const std::string &rFileNameBase, unsigned procId)
 

Private Attributes

Stream * mpCommonStream
 
Stream * mpPrivateStream
 
Archive * mpCommonArchive
 
Archive * mpPrivateArchive
 

Friends

class TestArchivingHelperClasses
 

Detailed Description

template<class Archive, class Stream>
class ArchiveOpener< Archive, Stream >

A convenience class to assist with managing archives for parallel checkpointing.

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 61 of file ArchiveOpener.hpp.

Constructor & Destructor Documentation

◆ ArchiveOpener() [1/3]

template<class Archive , class Stream >
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.

Note
Must be called collectively, i.e. by all processes!

If writing, and rDirectory is relative to CHASTE_TEST_OUTPUT, it will be created if it doesn't exist.

Parameters
rDirectoryfolder containing archive files.
rFileNameBasebase 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.
procIdthis can be specified to read a specific secondary archive, rather than this process' default. Should not be used for writing!

◆ ~ArchiveOpener() [1/3]

template<class Archive , class Stream >
ArchiveOpener< Archive, Stream >::~ArchiveOpener ( )

Close the opened archives.

◆ ArchiveOpener() [2/3]

◆ ~ArchiveOpener() [2/3]

ArchiveOpener< boost::archive::text_iarchive, std::ifstream >::~ArchiveOpener ( )

Definition at line 113 of file ArchiveOpener.cpp.

◆ ArchiveOpener() [3/3]

◆ ~ArchiveOpener() [3/3]

ArchiveOpener< boost::archive::text_oarchive, std::ofstream >::~ArchiveOpener ( )

Definition at line 197 of file ArchiveOpener.cpp.

Member Function Documentation

◆ GetCommonArchive()

template<class Archive , class Stream >
Archive * ArchiveOpener< Archive, Stream >::GetCommonArchive ( )
inline

Friends And Related Symbol Documentation

◆ TestArchivingHelperClasses

template<class Archive , class Stream >
friend class TestArchivingHelperClasses
friend

Definition at line 64 of file ArchiveOpener.hpp.

Member Data Documentation

◆ mpCommonArchive

template<class Archive , class Stream >
Archive* ArchiveOpener< Archive, Stream >::mpCommonArchive
private

◆ mpCommonStream

template<class Archive , class Stream >
Stream* ArchiveOpener< Archive, Stream >::mpCommonStream
private

The file stream for the main archive.

Definition at line 107 of file ArchiveOpener.hpp.

Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener().

◆ mpPrivateArchive

template<class Archive , class Stream >
Archive* ArchiveOpener< Archive, Stream >::mpPrivateArchive
private

The secondary archive.

Definition at line 116 of file ArchiveOpener.hpp.

Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener().

◆ mpPrivateStream

template<class Archive , class Stream >
Stream* ArchiveOpener< Archive, Stream >::mpPrivateStream
private

The file stream for the secondary archive.

Definition at line 110 of file ArchiveOpener.hpp.

Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener().


The documentation for this class was generated from the following file: