walberla::gather::FileGatherScheme Class Reference

Detailed Description

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::BlockStorageblocks_
 
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...
 

Member Typedef Documentation

◆ PackInfoVector

using walberla::gather::FileGatherScheme::PackInfoVector = std::vector<shared_ptr<GatherPackInfo> >
private

Constructor & Destructor Documentation

◆ FileGatherScheme()

walberla::gather::FileGatherScheme::FileGatherScheme ( domain_decomposition::BlockStorage blockStorage,
uint_t  everyNTimestep = 1 
)

◆ ~FileGatherScheme()

walberla::gather::FileGatherScheme::~FileGatherScheme ( )

Member Function Documentation

◆ addPackInfo()

void walberla::gather::FileGatherScheme::addPackInfo ( const shared_ptr< GatherPackInfo > &  pi)
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

◆ collectFromFiles()

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.

◆ deleteTemporaryFiles()

void walberla::gather::FileGatherScheme::deleteTemporaryFiles ( )
private

Temporary files are generated by collecting processes and written in the writeToFile() member.

These files are deleted by this function.

◆ operator()()

void walberla::gather::FileGatherScheme::operator() ( )
inline

Same as communicate.

◆ writeToFile()

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.

Member Data Documentation

◆ blocks_

domain_decomposition::BlockStorage& walberla::gather::FileGatherScheme::blocks_
private

◆ everyNTimestep_

uint_t walberla::gather::FileGatherScheme::everyNTimestep_
private

if operator() is called N times, writeToFile is called N / everyNTimestep_ times

◆ fileStream_

std::ofstream walberla::gather::FileGatherScheme::fileStream_
private

Output file stream, where collected data is written to.

◆ myId_

size_t walberla::gather::FileGatherScheme::myId_
private

To generated unique filenames for every FileCollectorScheme the schemes are numbered.

number of current scheme

◆ nextId_

size_t walberla::gather::FileGatherScheme::nextId_ = 0
staticprivate

number of existing FileCollectorScheme's (to generated id's)

◆ packInfos_

PackInfoVector walberla::gather::FileGatherScheme::packInfos_
private

all registered PackInfos


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