Collects / Gathers data from multiple blocks to a single block, using temporary files.
This scheme is only suitable, if the collected data have to be available not until the end of the simulation. After every timestep writeToFile() has to be called, which collects the data and writes them to a file (one file per "sending" process). After the simulation has finished, collectFromFiles() has to be called. This function is executed on only one process, which reads all the files and unpacks the data (using the pack info's). So the unpack() function's of the pack info's are only called AFTER the simulation.
If the data has to be available after each timestep MPIGatherScheme should be used.
#include <FileGatherScheme.h>
Construction and Destruction | |
using | PackInfoVector = std::vector< shared_ptr< GatherPackInfo > > |
domain_decomposition::BlockStorage & | blocks_ |
PackInfoVector | packInfos_ |
all registered PackInfos More... | |
size_t | myId_ |
To generated unique filenames for every FileCollectorScheme the schemes are numbered. More... | |
std::ofstream | fileStream_ |
Output file stream, where collected data is written to. More... | |
uint_t | everyNTimestep_ |
if operator() is called N times, writeToFile is called N / everyNTimestep_ times More... | |
static size_t | nextId_ = 0 |
number of existing FileCollectorScheme's (to generated id's) More... | |
FileGatherScheme (domain_decomposition::BlockStorage &blockStorage, uint_t everyNTimestep=1) | |
~FileGatherScheme () | |
void | addPackInfo (const shared_ptr< GatherPackInfo > &pi) |
Registering PackInfo's The ownership of the passed pack info, is transferred to the FileCollectorScheme, i.e. More... | |
void | writeToFile () |
Each process writes the data that has to be collected to a temporary file. More... | |
void | operator() () |
Same as communicate. More... | |
void | collectFromFiles () |
Reads the temporary files generated by all collecting processes, and calls the unpack() methods of the PackInfo's Is usually executed only once at the end of the simulation. More... | |
void | deleteTemporaryFiles () |
Temporary files are generated by collecting processes and written in the writeToFile() member. More... | |
|
private |
walberla::gather::FileGatherScheme::FileGatherScheme | ( | domain_decomposition::BlockStorage & | blockStorage, |
uint_t | everyNTimestep = 1 |
||
) |
walberla::gather::FileGatherScheme::~FileGatherScheme | ( | ) |
|
inline |
Registering PackInfo's The ownership of the passed pack info, is transferred to the FileCollectorScheme, i.e.
the pack info is deleted by the scheme
void walberla::gather::FileGatherScheme::collectFromFiles | ( | ) |
Reads the temporary files generated by all collecting processes, and calls the unpack() methods of the PackInfo's Is usually executed only once at the end of the simulation.
|
private |
Temporary files are generated by collecting processes and written in the writeToFile() member.
These files are deleted by this function.
|
inline |
Same as communicate.
void walberla::gather::FileGatherScheme::writeToFile | ( | ) |
Each process writes the data that has to be collected to a temporary file.
This function is similar to the "communicate()" function of other scheme's and should be called after every timestep. The difference is, that the unpacking occurs only once at the end of the simulation when collectFromFiles() is called.
|
private |
|
private |
if operator() is called N times, writeToFile is called N / everyNTimestep_ times
|
private |
Output file stream, where collected data is written to.
|
private |
To generated unique filenames for every FileCollectorScheme the schemes are numbered.
number of current scheme
|
staticprivate |
number of existing FileCollectorScheme's (to generated id's)
|
private |
all registered PackInfos